mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8211148: var in implicit lambdas shouldn't be accepted for source < 11
Reviewed-by: mcimadamore
This commit is contained in:
parent
73a6313038
commit
2589e9733e
8 changed files with 80 additions and 27 deletions
|
@ -107,8 +107,8 @@ public class LambdaParserTest extends ComboInstance<LambdaParserTest> {
|
|||
}
|
||||
|
||||
enum SourceKind {
|
||||
SOURCE_9("9"),
|
||||
SOURCE_10("10");
|
||||
SOURCE_10("10"),
|
||||
SOURCE_11("11");
|
||||
|
||||
String sourceNumber;
|
||||
|
||||
|
@ -121,9 +121,9 @@ public class LambdaParserTest extends ComboInstance<LambdaParserTest> {
|
|||
|
||||
IMPLICIT_1("", ExplicitKind.IMPLICIT),
|
||||
IMPLICIT_2("var", ExplicitKind.IMPLICIT_VAR),
|
||||
EXPLIICT_SIMPLE("A", ExplicitKind.EXPLICIT),
|
||||
EXPLIICT_SIMPLE_ARR1("A[]", ExplicitKind.EXPLICIT),
|
||||
EXPLIICT_SIMPLE_ARR2("A[][]", ExplicitKind.EXPLICIT),
|
||||
EXPLICIT_SIMPLE("A", ExplicitKind.EXPLICIT),
|
||||
EXPLICIT_SIMPLE_ARR1("A[]", ExplicitKind.EXPLICIT),
|
||||
EXPLICIT_SIMPLE_ARR2("A[][]", ExplicitKind.EXPLICIT),
|
||||
EXPLICIT_VARARGS("A...", ExplicitKind.EXPLICIT),
|
||||
EXPLICIT_GENERIC1("A<X>", ExplicitKind.EXPLICIT),
|
||||
EXPLICIT_GENERIC2("A<? extends X, ? super Y>", ExplicitKind.EXPLICIT),
|
||||
|
@ -157,13 +157,7 @@ public class LambdaParserTest extends ComboInstance<LambdaParserTest> {
|
|||
}
|
||||
|
||||
ExplicitKind explicitKind(SourceKind sk) {
|
||||
switch (explicitKind) {
|
||||
case IMPLICIT_VAR:
|
||||
return (sk == SourceKind.SOURCE_9) ?
|
||||
ExplicitKind.EXPLICIT : ExplicitKind.IMPLICIT_VAR;
|
||||
default:
|
||||
return explicitKind;
|
||||
}
|
||||
return explicitKind;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,6 +293,15 @@ public class LambdaParserTest extends ComboInstance<LambdaParserTest> {
|
|||
errorExpected |= pn == LambdaParameterName.UNDERSCORE &&
|
||||
lk.arity() > 0;
|
||||
|
||||
for (int i = 0; i < lk.arity(); i++) {
|
||||
if (!lk.isShort() &&
|
||||
pks[i].explicitKind(sk) == LambdaParameterKind.ExplicitKind.IMPLICIT_VAR &&
|
||||
sk == SourceKind.SOURCE_10) {
|
||||
errorExpected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (errorExpected != res.hasErrors()) {
|
||||
fail("invalid diagnostics for source:\n" +
|
||||
res.compilationInfo() +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue