This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 233100 - "Convert lambda" hints add a return statement for methods with return type void
Summary: "Convert lambda" hints add a return statement for methods with return type void
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.4
Hardware: PC Windows 8
: P3 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-20 02:54 UTC by xehpuk
Modified: 2013-07-22 04:16 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description xehpuk 2013-07-20 02:54:48 UTC
Product Version = NetBeans IDE 7.4 Beta (Build 201307092200)
Operating System = Windows 8 version 6.2 running on x86
Java; VM; Vendor = 1.8.0-ea
Runtime = Java HotSpot(TM) Client VM 25.0-b41

Consider this interface:
interface ConvertLambda {
	void foo();
	
	static void bar() {
		ConvertLambda cl = () -> System.out.println("foo()");
	}
}

NetBeans shows two hints for converting the lambda.

First hint is: "Use block as the lambda's body" ("Convert lambda body to use a block rather than an expression")
Resulting in this code:
static void bar() {
	ConvertLambda cl = () -> {
		return System.out.println("foo()");
	};
}

Apparently, the "return" is wrong here.

Second hint is: "Convert lambda expression to anonymous innerclass"
Resulting in this code:
static void bar() {
	ConvertLambda cl = new ConvertLambda() {

		public void foo() {
			return System.out.println("foo()");
		}
	};
}

Again, the "return" is wrong.
Comment 1 Quality Engineering 2013-07-22 02:13:09 UTC
Integrated into 'main-silver', will be available in build *201307212300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/7375a4c11257
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #233100: expression based lambda's expression can have type void, make sure not to generate the return type for it.
Comment 2 Jan Lahoda 2013-07-22 04:16:46 UTC
Good catch, thanks. Fixed by the above commit.