Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 408009 - [1.8][extract method] Unable to extract lambda expression to method
Summary: [1.8][extract method] Unable to extract lambda expression to method
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.3   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: BETA J8   Edit
Assignee: Noopur Gupta CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 407985
Blocks: 405305
  Show dependency tree
 
Reported: 2013-05-14 08:48 EDT by Noopur Gupta CLA
Modified: 2014-02-23 18:21 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Noopur Gupta CLA 2013-05-14 08:48:55 EDT
Consider the example below:

@FunctionalInterface
public interface I1 {
	int foo(int a);
}

class X {	
	void foo() {	
		I1 i1= (int a) -> {return 10;}; // Extract lambda expr
		
		I1 i2= (a) -> {return 10;}; // Extract lambda expr
		bar(a -> 10); // Extract lambda expr
	}
	
	void bar(I1 i) {
	}

	// expected method after extraction
	I1 m() {
		return (int a) -> {return 10;};
	}
}

Try to extract only the lambda expr from the lines with comments to a method using Alt+Shift+M. 

We get different error messages in above cases and it is not possible to extract the lambda expr to a method as shown in the expected method above.
Comment 1 Noopur Gupta CLA 2013-05-15 08:00:41 EDT
The same is applicable to Extract Local Variable refactoring.
It is not possible to extract the lambda expr to a local variable using Alt+Shift+L. 
Example - Same as comment #0.
Comment 2 Noopur Gupta CLA 2013-08-30 12:26:04 EDT
(In reply to comment #1)
> The same is applicable to Extract Local Variable refactoring.
> It is not possible to extract the lambda expr to a local variable using
> Alt+Shift+L. 
> Example - Same as comment #0.

Created bug 416264 for Extract Local Variable refactoring.
Comment 3 Noopur Gupta CLA 2013-09-10 10:15:59 EDT
This will be fixed along with the patch for bug 407985.
Comment 4 Noopur Gupta CLA 2014-02-20 12:20:59 EST
(In reply to Noopur Gupta from comment #3)
> This will be fixed along with the patch for bug 407985.

Fixed with bug 407985.
Comment 5 Martin Mathew CLA 2014-02-23 18:21:42 EST
Verified the functionality in bug 407985 using Kepler SR2 + Java 8 RC1 +   Eclipse Java Development Tools Patch for Java 8 Support (BETA) 1.0.0.v20140220-2054