Skip to content

Commit

Permalink
Add a repro test for broken behavior inlining the parameter value int…
Browse files Browse the repository at this point in the history
…o the fully-qualified type package in the replacement.

PiperOrigin-RevId: 689427470
  • Loading branch information
swegner authored and Error Prone Team committed Oct 24, 2024
1 parent a931fa3 commit ed6b121
Showing 1 changed file with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,59 @@ public void doTest() {
.doTest();
}

@Test
public void inlinerReplacesParameterValueInPackageName_b375421323() {
refactoringTestHelper
.addInputLines(
"Bar.java",
"""
package foo;
public class Bar {
public static void baz(String s) {}
}
""")
.expectUnchanged()
.addInputLines(
"Client.java",
"""
import com.google.errorprone.annotations.InlineMe;
import foo.Bar;
public class Client {
@InlineMe(replacement = "Bar.baz(foo)", imports = "foo.Bar")
public static void inlinedMethod(String foo) {
Bar.baz(foo);
}
}
""")
.expectUnchanged()
.addInputLines(
"Caller.java",
"""
class Caller {
class Bar {}
void doTest() {
Client.inlinedMethod("abc");
}
}
""")
.addOutputLines(
"out/Caller.java",
"""
class Caller {
class Bar {}
void doTest() {
"abc".Bar.baz("abc");
}
}
""")
.allowBreakingChanges()
.doTest();
}

private BugCheckerRefactoringTestHelper bugCheckerWithPrefixFlag(String prefix) {
return BugCheckerRefactoringTestHelper.newInstance(Inliner.class, getClass())
.setArgs("-XepOpt:" + PREFIX_FLAG + "=" + prefix);
Expand Down

0 comments on commit ed6b121

Please sign in to comment.