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.
Product Version = NetBeans IDE 8.0 (Build 201403101706) Operating System = Windows 8 version 6.2 running on amd64 Java; VM; Vendor = 1.8.0 Runtime = Java HotSpot(TM) 64-Bit Server VM 25.0-b70 Consider this class (and imply an import for java.util.function.Supplier): class MissingCastHintInLambdaExpression { void bug() { Supplier<String> s = new Supplier<String>() { @Override public String get() { return new Object(); // "incompatible types: Object cannot be converted to String" } }; } } NetBeans correctly shows a compiler error and provides the hint "Cast ...new Object(...) to String" which results in this (syntactically) correct code: class MissingCastHintInLambdaExpression { void bug() { Supplier<String> s = new Supplier<String>() { @Override public String get() { return (String) new Object(); } }; } } When I introduce a lambda expression in the first version, it looks like this: class MissingCastHintInLambdaExpression { void bug() { Supplier<String> s = () -> new Object(); // "incompatible types: bad return type in lambda expression", "Object cannot be converted to String" } } Again, NetBeans correctly shows a compiler error, but it does not provide a hint to insert the cast to String which – once implemented – should change the code like this: class MissingCastHintInLambdaExpression { void bug() { Supplier<String> s = () -> (String) new Object(); } }
Fixed in jet-main#3c5dfaac4af6
Integrated into 'main-silver', will be available in build *201407300001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/3c5dfaac4af6 User: Svata Dedic <sdedic@netbeans.org> Log: #243093: add cast hint provided for lambda expressions