Intersection type and method ref bug ?

Vicente Romero vicente.romero at oracle.com
Fri Oct 26 13:21:02 UTC 2018


Hi Remi, Francois,

Thanks for reporting this. I have created [1] to track this issue,

Vicente

[1] https://bugs.openjdk.java.net/browse/JDK-8213032

On 10/24/18 6:05 AM, Remi Forax wrote:
> This bug was discovered by Francois Green when testing records, but the bug is independent of the record,
> method reference and intersection type doesn't mix well.
>
> public class RecordBadType {
>    interface  I {}
>    static abstract class C { }
>    static class A extends C implements I { }
>    static class B extends C implements I { }
>    
>    static String f(I i) { return null; }
>
>    public static void main(String[] args) {
>      Stream.of(new A(), new B())
>        .map(RecordBadType::f)   // here the compiler should generate a bridge method no ?
>        .forEach(System.out::println);
>    }
> }
>
> this code compiles but you get a LambdaConversionException at runtime.
>
> Rémi



More information about the compiler-dev mailing list