diff options
author | Manoj Palat | 2014-10-16 02:40:34 +0000 |
---|---|---|
committer | Jayaprakash Arthanareeswaran | 2014-11-20 16:38:23 +0000 |
commit | e27be48ee11d57346cc42f5ceea57f2f158d38a8 (patch) | |
tree | 3f1fd92ad46203bffecf088068d6156b0bd9f651 | |
parent | 9bbd1c75c3645a901e87d8dd5657f584792bbe64 (diff) | |
download | eclipse.jdt.core-e27be48ee11d57346cc42f5ceea57f2f158d38a8.tar.gz eclipse.jdt.core-e27be48ee11d57346cc42f5ceea57f2f158d38a8.tar.xz eclipse.jdt.core-e27be48ee11d57346cc42f5ceea57f2f158d38a8.zip |
Fix for [Bug 447062] [1.8][dom/ast] lambda as a class member -
IllegalArgumentException
-rw-r--r-- | org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java | 32 | ||||
-rw-r--r-- | org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java | 3 |
2 files changed, 35 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java index 7cc7d6f053..6586982525 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java @@ -4720,4 +4720,36 @@ public void testBug435348() throws JavaModelException { "}\n"; buildAST(contents, this.workingCopy, false); } +/** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=447062 + * + * @throws JavaModelException + */ +public void testBug447062() throws JavaModelException { + String contents = + "public class X {\n" + + " Runnable foo = () -> {\n" + + " \n" + + " }\n" + + "}\n"; + this.workingCopy = getWorkingCopy("/Converter18/src/test447062/X.java", contents, true/*computeProblems*/); + IJavaProject javaProject = this.workingCopy.getJavaProject(); + class BindingRequestor extends ASTRequestor { + ITypeBinding _result = null; + public void acceptBinding(String bindingKey, IBinding binding) { + if (this._result == null && binding != null && binding.getKind() == IBinding.TYPE) + this._result = (ITypeBinding) binding; + } + } + final BindingRequestor requestor = new BindingRequestor(); + final ASTParser parser = ASTParser.newParser(AST.JLS8); + parser.setResolveBindings(false); + parser.setProject(javaProject); + parser.setIgnoreMethodBodies(true); + try { + parser.createASTs(new ICompilationUnit[] {this.workingCopy}, new String[0], requestor, null); + } catch (IllegalArgumentException e) { + assertTrue("Test Failed", false); + } +} } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java index f9f4de763b..146a819f94 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java @@ -7969,7 +7969,10 @@ protected void consumeLambdaExpression() { Statement body = (Statement) this.astStack[this.astPtr--]; if (body instanceof Block) { if (this.options.ignoreMethodBodies) { + Statement oldBody = body; body = new Block(0); + body.sourceStart = oldBody.sourceStart; + body.sourceEnd = oldBody.sourceEnd; } ((Block) body).lambdaBody = true; // for consistency's sakes. } |