Bug 577270 - Disambiguation for '->' fails with latest changes from JDT
- fix detection of lambda inside role method
(to fix bogus compiler error in HighlightingAdaptor)
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 69a72ee..e411ac1 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
@@ -29,6 +29,7 @@
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Argument;
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
@@ -2258,6 +2259,8 @@
return !(goal == Goal.LambdaParameterListGoal || goal == Goal.PatternGoal);
} else if (this.activeParser instanceof Parser) {
Parser parser = (Parser) this.activeParser;
+ if (parser.referenceContext instanceof AbstractMethodDeclaration)
+ return false; // no callout inside a method :)
int ptr = parser.astPtr;
while (ptr > -1) {
ASTNode topAstNode = parser.astStack[ptr];
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java8.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java8.java
index 9bc8acc..e2fe65d 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java8.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java8.java
@@ -601,4 +601,19 @@
"}\n"
});
}
+ public void testRoleLambdaArgNoParen() {
+ runConformTest(
+ new String[] {
+ "LambdaArgNoParen.java",
+ "import java.util.function.Function;\n" +
+ "public team class LambdaArgNoParen {\n" +
+ " protected class R {\n" +
+ " void m1(Function<String,Boolean> f) {}\n" +
+ " void m2() {\n" +
+ " m1(s -> s.isEmpty());\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ });
+ }
}