| Summary: | No Java method proposal when inside lambda | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Stefan Vahlgren <stefan.vahlgren> |
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | jarthana, stephan.herrmann |
| Version: | 4.8 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | stalebug | ||
(In reply to Stefan Vahlgren from comment #0) > The last comment is for the case where > the problem happens. In that case, I get this exception in the Error Log: java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.typesAsString(ProblemReporter.java:8239) at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.typesAsString(ProblemReporter.java:8227) at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.invalidMethod(ProblemReporter.java:4237) at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:792) at org.eclipse.jdt.internal.codeassist.complete.CompletionOnMemberAccess.resolveType(CompletionOnMemberAccess.java:58) at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:1031) at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:122) at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.resolveType(LambdaExpression.java:437) at org.eclipse.jdt.internal.compiler.ast.FunctionalExpression.resolveType(FunctionalExpression.java:184) at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:725) at org.eclipse.jdt.internal.codeassist.complete.CompletionOnMemberAccess.resolveType(CompletionOnMemberAccess.java:58) at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:1031) at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:122) at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.resolveType(LambdaExpression.java:437) at org.eclipse.jdt.internal.compiler.ast.ASTNode.resolvePolyExpressionArguments(ASTNode.java:701) at org.eclipse.jdt.internal.compiler.ast.MessageSend.findMethodBinding(MessageSend.java:956) at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:770) at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:1031) at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:122) at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.resolveType(LambdaExpression.java:437) at org.eclipse.jdt.internal.compiler.ast.FunctionalExpression.resolveType(FunctionalExpression.java:184) at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:261) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:639) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:313) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:549) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1219) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1333) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:631) at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:2246) at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:133) at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:365) at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:355) at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer.internalComputeCompletionProposals(JavaCompletionProposalComputer.java:250) ... Moving to JDT Core. Thank you Noopur. This is my first bug report in Eclipse and I wasn't sure which value for Product to use. This may be is similar to bug 460921. The problem appears to be we end up in a stackoverflow situation with the completion node getting the receiver as the MessageSend (1) but also also becomes one of the statements in the lambda which is an argument to the MessageSend (1). This makes the resolution of argumentTypes impossible later inside MessageSend#resolveType(). Yet to figure out how best this can be avoided. (In reply to Jay Arthanareeswaran from comment #3) > This may be is similar to bug 460921. > > The problem appears to be we end up in a stackoverflow situation with the > completion node getting the receiver as the MessageSend (1) but also also > becomes one of the statements in the lambda which is an argument to the > MessageSend (1). This makes the resolution of argumentTypes impossible later > inside MessageSend#resolveType(). Yet to figure out how best this can be > avoided. Yes it seems to be similar or the same as 460921. I just noticed that the proposals Are shown if there is a variable to be declared with the response of the statement that you try to use the CTRL + SPACE for. Maybe information good to know about when solving this. So to clarify I continue my example code with the following: A a2 = ()->{ getException(()->{}).getMessage(); //no proposal for getMessage in Eclipse }; A a3 = ()->{ String s = getException(()->{}).getMessage(); //Proposal for getMessage in Eclipse }; This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. Let's at least link it to the other bug, so we can revisit the examples here when/if we have a fix in this area. *** This bug has been marked as a duplicate of bug 460921 *** |
In some case, Eclipse doesn't give proposals for methods. Please look at the following Class and the 3 comments. The last comment is for the case where the problem happens. The lambda for A calls the getException taking another lambda for B as parameter. The return type is Exception. In the 2 first calls, using CTRL + SPACE to show the proposals for methods of Exception is shown, but not the 3rd one. public class LambdasWithinLambdas { interface B{ void b(); } public Exception getException(B b){ return new Exception(); } interface A{ void a(); } public void test(){ getException(()->{}).getMessage(); //Proposal for getMessage in Eclipse A a = new A() { @Override public void a() { getException(()->{}).getMessage(); //Proposal for getMessage in Eclipse } }; A a2 = ()->{ getException(()->{}).getMessage(); //no proposal for getMessage in Eclipse }; } }