Skip to content

Commit

Permalink
Add a tests for Dagger Component.Builders and `Subcomponent.Builder…
Browse files Browse the repository at this point in the history
…`s to `CanIgnoreReturnValueSuggesterTest`.

#checkreturnvalue

PiperOrigin-RevId: 595416843
  • Loading branch information
kluever authored and Error Prone Team committed Jan 3, 2024
1 parent 2bd7859 commit 195b3d6
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -872,4 +872,58 @@ public void exemptedByCustomAnnotation() {
.setArgs("-XepOpt:CanIgnoreReturnValue:ExemptingMethodAnnotations=example.Foo")
.doTest();
}

@Test
public void daggerComponentBuilder_b318407972() {
helper
.addInputLines(
"Builder.java",
"package com.google.frobber;",
"import dagger.Component;",
"@Component.Builder",
"interface Builder {",
" Builder setName(String name);",
" String build();",
"}")
.addOutputLines(
"Builder.java",
"package com.google.frobber;",
"import com.google.errorprone.annotations.CanIgnoreReturnValue;",
"import dagger.Component;",
"@Component.Builder",
"interface Builder {",
// TODO(b/318407972): we shouldn't suggest @CIRV on Dagger Component.Builder setters
" @CanIgnoreReturnValue",
" Builder setName(String name);",
" String build();",
"}")
.doTest();
}

@Test
public void daggerSubcomponentBuilder_b318407972() {
helper
.addInputLines(
"Builder.java",
"package com.google.frobber;",
"import dagger.Subcomponent;",
"@Subcomponent.Builder",
"interface Builder {",
" Builder setName(String name);",
" String build();",
"}")
.addOutputLines(
"Builder.java",
"package com.google.frobber;",
"import com.google.errorprone.annotations.CanIgnoreReturnValue;",
"import dagger.Subcomponent;",
"@Subcomponent.Builder",
"interface Builder {",
// TODO(b/318407972): we shouldn't suggest @CIRV on Dagger Subcomponent.Builder setters
" @CanIgnoreReturnValue",
" Builder setName(String name);",
" String build();",
"}")
.doTest();
}
}

0 comments on commit 195b3d6

Please sign in to comment.