Skip to content

Commit

Permalink
Add a test demonstrating a bug in the Inliner.
Browse files Browse the repository at this point in the history
#inlineme

PiperOrigin-RevId: 671794396
  • Loading branch information
kluever authored and Error Prone Team committed Sep 6, 2024
1 parent dab4089 commit 5d475b3
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,35 @@ public void paramCast_b308614050() {
.doTest();
}

@Test
public void b365094947() {
refactoringTestHelper
.addInputLines(
"Caller.java",
"import static java.nio.charset.StandardCharsets.UTF_8;",
"import com.google.common.io.Files;",
"import java.io.File;",
"public final class Caller {",
" public void doTest(File file, String text) throws Exception {",
" Files.write(text, file, UTF_8);",
" }",
"}")
.addOutputLines(
"Caller.java",
"import static java.nio.charset.StandardCharsets.UTF_8;",
"import com.google.common.io.Files;",
"import java.io.File;",
"public final class Caller {",
" public void doTest(File file, String text) throws Exception {",
// TODO(b/365094947): this is a bug; it clearly does not compile. It should be:
// Files.asCharSink(file, UTF_8).write(text);
" Files.asCharSink(to, charset).write(from);",
" }",
"}")
.allowBreakingChanges()
.doTest();
}

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

0 comments on commit 5d475b3

Please sign in to comment.