diff options
| author | Srikanth | 2012-06-20 15:22:56 +0000 |
|---|---|---|
| committer | Srikanth | 2012-06-20 15:22:56 +0000 |
| commit | 05c0ef920f8f629670a61fe160e2d7350d9d88d5 (patch) | |
| tree | 53fad61f1915eb91f11e023afc46ca00d5680091 | |
| parent | fff49fd0bdbee760e61edee27f88554273119578 (diff) | |
| download | eclipse.jdt.core-05c0ef920f8f629670a61fe160e2d7350d9d88d5.tar.gz eclipse.jdt.core-05c0ef920f8f629670a61fe160e2d7350d9d88d5.tar.xz eclipse.jdt.core-05c0ef920f8f629670a61fe160e2d7350d9d88d5.zip | |
Part 2 of fix for 383046
2 files changed, 27 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsNegativeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsNegativeTest.java index 5296856518..226c6073cd 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsNegativeTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsNegativeTest.java @@ -135,7 +135,7 @@ public void test005() { "}\n" + "public class X {\n" + " IX i = super::toString;\n" + - " Zork z;\n" + + " Zork z;\n" + "}\n", }, "----------\n" + @@ -145,6 +145,26 @@ public void test005() { "Zork cannot be resolved to a type\n" + "----------\n"); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383046, syntax error reported incorrectly on *syntactically* valid reference expression +public void test006() { + this.runNegativeTest( + new String[] { + "X.java", + "interface IX{\n" + + " public void foo();\n" + + "}\n" + + "public class X {\n" + + " IX i = Outer<One, Two>.Inner<Three, Four>.Deeper<Five, Six<String>>.Leaf::<Blah, Blah>method;\n" + + " int\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " int\n" + + " ^^^\n" + + "Syntax error on token \"int\", delete this token\n" + + "----------\n"); +} public static Class testClass() { return LambdaExpressionsNegativeTest.class; diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java index cddee87ae5..e7811f88c9 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java @@ -193,6 +193,7 @@ public class Scanner implements TerminalTokens { private final boolean scanningJava8Plus; public boolean shouldDisambiguate; // feedback from parser about need to disambiguate -- to lookahead only when absolutely necessary. public boolean disambiguatedAlready; + public boolean scanningHeadOfReferenceExpression = false; public static final int RoundBracket = 0; public static final int SquareBracket = 1; @@ -1144,6 +1145,9 @@ public int getNextToken() throws InvalidInputException { } else { token = getNextToken0(); } + if (token == TokenNameCOLON_COLON) { + this.scanningHeadOfReferenceExpression = false; + } if (this.disambiguatedAlready) { this.disambiguatedAlready = false; return token; @@ -1155,10 +1159,11 @@ public int getNextToken() throws InvalidInputException { this.disambiguatedAlready = true; return TokenNameBeginLambda; } - } else if (token == TokenNameLESS) { + } else if (token == TokenNameLESS && !this.scanningHeadOfReferenceExpression) { if (atReferenceExpression()) { this.nextToken = token; this.disambiguatedAlready = true; + this.scanningHeadOfReferenceExpression = true; return TokenNameBeginTypeArguments; } } |
