Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 421469 - [1.8][code assist] NPE in LocalDeclaration.resolve with anonymous class in lambda body
Summary: [1.8][code assist] NPE in LocalDeclaration.resolve with anonymous class in la...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: BETA J8   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 402079
  Show dependency tree
 
Reported: 2013-11-11 11:58 EST by Markus Keller CLA
Modified: 2013-11-30 19:57 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2013-11-11 11:58:28 EST
BETA_JAVA8

NPE in LocalDeclaration.resolve when performing content assist with an anonymous class in a lambda body. Same problem with a local class.

package jsr335;
import java.util.function.IntFunction;
public class Snippet {
    void foo() {
        IntFunction<String> toString = i -> {
            //<-- Ctrl+Space here
            new Runnable() {
                @Override
                public void run() {
                    //<-- Ctrl+Space here
                }
            }.run();
            return Integer.toString(i);
        };
    }
}

java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:191)
	at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:114)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:620)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:303)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:531)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1209)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1319)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:568)
	at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1896)
	at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:130)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:357)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:345)
	at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer.internalComputeCompletionProposals(JavaCompletionProposalComputer.java:244)

Stacktrace in bug 383096 looks similar, but that bug is about code with a syntax error.
Comment 1 Srikanth Sankaran CLA 2013-11-14 06:24:14 EST
This is basically due to there being no RecoveredLambdaExpression construct
yet. Anirban has proposed various fixes on behalf of different CRs/ERs, but
these have stalled in the review queue. Will get to this in early December.
Comment 2 Srikanth Sankaran CLA 2013-11-25 07:42:53 EST
This is subsumed by the recent fixes for code selection. I released a test
from comment#0 here: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=9201dfdd65456845c29d6dc3323aadc8322279d6