Intersection type and method ref bug ?
Remi Forax
forax at univ-mlv.fr
Wed Oct 24 10:05:38 UTC 2018
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