Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ ERR_splitIfCondition=ERR_splitIfCondition

HINT_ConvertIfToSwitch=HINT_ConvertIfToSwitch
FIX_ConvertIfsToSwitch=FIX_ConvertIfsToSwitch

ERR_ConvertVarLambdaParameters=ERR_ConvertVarLambdaParameters
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,14 @@ public void testExplicitParameterTypes() throws Exception {
"}\n");
}

//Todo: Verification is pending on nb-javac of JDK11
@Test
public void testImplicitVarParameterTypes1() throws Exception {
HintTest.create()
.setCaretMarker('^')
.input("package test;\n" +
"import java.util.function.IntBinaryOperator;\n" +
"public class Test {\n" +
" public void main(String list) {\n" +
" public void main(String[] args) {\n" +
" IntBinaryOperator calc3 = (int x, int y)^ -> x + y;\n" +
" }\n" +
"}\n")
Expand All @@ -572,38 +571,53 @@ public void testImplicitVarParameterTypes1() throws Exception {
.assertVerbatimOutput("package test;\n" +
"import java.util.function.IntBinaryOperator;\n" +
"public class Test {\n" +
" public void main(List<String> list) {\n" +
" public void main(String[] args) {\n" +
" IntBinaryOperator calc3 = (var x, var y) -> x + y;\n" +
" }\n" +
"}\n");
}

//Todo: Verification is pending on nb-javac of JDK11
@Test
public void testImplicitVarParameterTypes2() throws Exception {
HintTest.create()
.setCaretMarker('^')
.input("package test;\n" +
"import java.util.function.IntBinaryOperator;\n" +
"public class Test {\n" +
" public void main(String list) {\n" +
" public void main(String[] args) {\n" +
" IntBinaryOperator calc3 = (x, y)^ -> x + y;\n" +
" }\n" +
"}\n")
.sourceLevel("1.11")
.run(Lambda.class)
.findWarning("4:48-4:48:verifier:ERR_ConvertVarLambdaParameters")
.findWarning("4:40-4:40:verifier:ERR_ConvertVarLambdaParameters")
.applyFix()
.assertCompilable()
.assertVerbatimOutput("package test;\n" +
"import java.util.function.IntBinaryOperator;\n" +
"public class Test {\n" +
" public void main(List<String> list) {\n" +
" public void main(String[] args) {\n" +
" IntBinaryOperator calc3 = (var x, var y) -> x + y;\n" +
" }\n" +
"}\n");
}

@Test
public void testImplicitVarParameterTypes3() throws Exception {
HintTest.create()
.setCaretMarker('^')
.input("package test;\n" +
"import java.util.function.IntBinaryOperator;\n" +
"public class Test {\n" +
" public void main(String[] args) {\n" +
" IntBinaryOperator calc3 = (var x, var y)^ -> x + y;\n" +
" }\n" +
"}\n")
.sourceLevel("1.11")
.run(Lambda.class)
.assertNotContainsWarnings("ERR_ConvertVarLambdaParameters");
}

static {
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
}
Expand Down