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 Dev (Build 201506240001) Java: 1.8.0_45; Java HotSpot(TM) 64-Bit Server VM 25.45-b02 Runtime: Java(TM) SE Runtime Environment 1.8.0_45-b14 System: Windows 7 version 6.1 running on amd64; Cp1252; en_CA (nb) User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev Given: --- import com.codahale.metrics.MetricRegistry; [...] MetricRegistry registry = getMetrics(); registry.register("name", (Gauge<Double>) () -> 5.0); --- Netbeans annotates the cast to "Gauge<Double>" with a "remove redundant cast" hint but removing the cast results in a compiler error "Metric is not a functional interface". To recap: 1. The code is invoking a method that takes a Metric argument. 2. Gauge extends Metric, but Gauge *is* a functional interface whereas Metric is not. Expected behavior: The hint should not be offered for lambdas if removing the cast results in a type which is not a functional interface.
God knows what boxing / unboxing / whatever will break. I changed the final check so it attempts to actually parse+attribute the exact proposed code for the method call and report unnecessary cast if and only if the code does not produce an error and resolves to the same method. Fixed in jet-main#df1a8506223a
Integrated into 'main-silver', will be available in build *201508050002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/df1a8506223a User: Svata Dedic <sdedic@netbeans.org> Log: #253195: suggested code better checked for errors and ambiguity