Skip to content

Commit

Permalink
[apache#3466] do not show Convert Type to Var hint for method references
Browse files Browse the repository at this point in the history
  • Loading branch information
oyarzun committed Jan 18, 2022
1 parent 0d32f3f commit 29dc0d4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Expand Up @@ -204,6 +204,8 @@ private static boolean isValidVarType(HintContext ctx) {
break;
case LAMBDA_EXPRESSION:
return false;
case MEMBER_REFERENCE:
return false;
default:
break;
}
Expand Down
Expand Up @@ -121,6 +121,24 @@ public void testLambdaExprRefToVar() throws Exception {

}

@Test
public void testMethodRefToVar() throws Exception {

HintTest.create()
.setCaretMarker('^')
.input("package test;\n"
+ "import java.util.function.Consumer;\n"
+ "public class Test {\n"
+ " void m2() {\n"
+ " final Consumer<String> println = System.out::println^;\n"
+ " }\n"
+ "}\n")
.sourceLevel("1.10")
.run(ConvertToVarHint.class)
.assertNotContainsWarnings(VAR_CONV_DESC);

}

@Test
public void testArrayInitializerVar() throws Exception {

Expand Down

0 comments on commit 29dc0d4

Please sign in to comment.