Skip to content

Commit ed6b121

Browse files
swegnerError Prone Team
authored andcommitted
Add a repro test for broken behavior inlining the parameter value into the fully-qualified type package in the replacement.
PiperOrigin-RevId: 689427470
1 parent a931fa3 commit ed6b121

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

core/src/test/java/com/google/errorprone/bugpatterns/inlineme/InlinerTest.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,59 @@ public void doTest() {
15111511
.doTest();
15121512
}
15131513

1514+
@Test
1515+
public void inlinerReplacesParameterValueInPackageName_b375421323() {
1516+
refactoringTestHelper
1517+
.addInputLines(
1518+
"Bar.java",
1519+
"""
1520+
package foo;
1521+
1522+
public class Bar {
1523+
public static void baz(String s) {}
1524+
}
1525+
""")
1526+
.expectUnchanged()
1527+
.addInputLines(
1528+
"Client.java",
1529+
"""
1530+
import com.google.errorprone.annotations.InlineMe;
1531+
import foo.Bar;
1532+
1533+
public class Client {
1534+
@InlineMe(replacement = "Bar.baz(foo)", imports = "foo.Bar")
1535+
public static void inlinedMethod(String foo) {
1536+
Bar.baz(foo);
1537+
}
1538+
}
1539+
""")
1540+
.expectUnchanged()
1541+
.addInputLines(
1542+
"Caller.java",
1543+
"""
1544+
class Caller {
1545+
class Bar {}
1546+
1547+
void doTest() {
1548+
Client.inlinedMethod("abc");
1549+
}
1550+
}
1551+
""")
1552+
.addOutputLines(
1553+
"out/Caller.java",
1554+
"""
1555+
class Caller {
1556+
class Bar {}
1557+
1558+
void doTest() {
1559+
"abc".Bar.baz("abc");
1560+
}
1561+
}
1562+
""")
1563+
.allowBreakingChanges()
1564+
.doTest();
1565+
}
1566+
15141567
private BugCheckerRefactoringTestHelper bugCheckerWithPrefixFlag(String prefix) {
15151568
return BugCheckerRefactoringTestHelper.newInstance(Inliner.class, getClass())
15161569
.setArgs("-XepOpt:" + PREFIX_FLAG + "=" + prefix);

0 commit comments

Comments
 (0)