Skip to content

Commit

Permalink
PUBLIC: Add a test demonstrating b/308614050 (bug with parameter cast…
Browse files Browse the repository at this point in the history
…ing).

PiperOrigin-RevId: 578507433
  • Loading branch information
kluever authored and Error Prone Team committed Nov 1, 2023
1 parent 1991070 commit a63bf9f
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,48 @@ public void varArgs_b268215956() {
.doTest();
}

@Test
public void paramCast_b308614050() {
refactoringTestHelper
.addInputLines(
"Client.java",
"package com.google.foo;",
"import com.google.errorprone.annotations.InlineMe;",
"public final class Client {",
" @InlineMe(",
" replacement = \"Client.after(value.doubleValue())\",",
" imports = {\"com.google.foo.Client\"})",
" public static void before(Long value) {",
" after(value.doubleValue());",
" }",
" public static void after(double value) {",
" // do nothing",
" }",
"}")
.expectUnchanged()
.addInputLines(
"Caller.java",
"import com.google.foo.Client;",
"public final class Caller {",
" public void doTest() {",
" Object value = 42L;",
" Client.before((Long) value);",
" }",
"}")
.addOutputLines(
"Caller.java",
"import com.google.foo.Client;",
"public final class Caller {",
" public void doTest() {",
" Object value = 42L;",
// TODO(b/308614050): this is a bug! you can't call doubleValue() on an Object!
" Client.after((Long) value.doubleValue());",
" }",
"}")
.allowBreakingChanges()
.doTest();
}

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

0 comments on commit a63bf9f

Please sign in to comment.