Possible compiler bug causing LambdaConversionException
Kiva
imkiva at islovely.icu
Fri Aug 26 09:04:19 UTC 2022
Hi all,
I am not sure whether this should be reported to amber-dev or compiler-dev so I am reporting it here (sorry!)
A minimal repro was attached below or you can visit here: https://gist.github.com/imkiva/8db13b6e578e473c1c9b977086bfe898
import java.util.function.BiFunction;
public class Bug {
sealed interface Term {
record Lit() implements Term {}
record Lam(String x, Term a) implements Term {}
}
public static <X, T> void call(BiFunction<X, T, T> op, X x, T t) {
op.apply(x, t);
}
public static void main(String[] args) {
// this code works
call(Term.Lam::new, "x", (Term) new Term.Lit());
// this does not
call(Term.Lam::new, "x", new Term.Lit());
// java.lang.invoke.LambdaConversionException: Type mismatch for lambda argument 1:
// class java.lang.Record is not convertible to interface Term
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20220826/c5456df9/attachment.htm>
More information about the compiler-dev
mailing list