Community
Participate
Working Groups
Start with the valid and working program below, computing a factorial: ------------------------------------------------ package java8.test; public class Main { interface Duo { int apply(int n, Duo g); } public static void main(String[] args) { Duo f = (n, g) -> n > 0 ? n * g.apply(n - 1, g) : 1; System.out.println(f.apply(5, f)); } } ------------------------------------------------ then change the line declaring the "Duo f" variable as such: ------------------------------------------------ Duo f = (n, g) -> n > 0 ? n * g.apply(n - 1, g) : 1, f. ------------------------------------------------ After the "." is entered after "f", Eclipse hangs and must be killed.
Fix and tests here: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=696ed15a1e8614ddbc6d608510de2603ca6573e4. We were missing a call to the routine that handles lambda closure, instead waiting for the entire LocalVariableDeclaration to be reduced. However the fact that we think we are inside the lambda expression even past its closure interferes with subsequent parsing. As a follow up, I'll shortly also hook up the new infrastructure for completion support in lambda expressions into IProgressMonitor so timeouts would automatically trigger and preclude such freezes.
(In reply to Srikanth Sankaran from comment #1) > As a follow up, I'll shortly also hook up the new infrastructure for > completion > support in lambda expressions into IProgressMonitor so timeouts would > automatically trigger and preclude such freezes. I hooked up the CompletionParser infrastructure into the canonical of scheme of things i.e IProgressMonitor that the CompletionEngine already tracks: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=7dbc472feab6f8985cd72052d6eaace52c7ea562
Verified as working for Eclipse + Java 8 RC1 using Kepler SR1 + Eclipse Java Development Tools Patch for Java 8 Support (BETA) 1.0.0.v20140220-2054
Great, thanks for the fix!
On further look after bug 539685 I noticed that meanwhile we are giving real completion proposals, but those didn't look great. I was about to file a new bug to ensure that good proposals are made, but only then I noticed the syntax error at "1, f." - either the ',' or the '.' is wrong. When removing "1, ", the completion AST looks nice as of now.