[External] : javac can not infer a var inside a record pattern correctly
Jan Lahoda
jan.lahoda at oracle.com
Mon Oct 14 05:37:20 UTC 2024
Hi Remi,
Thanks for the report. I believe this is already reported as:
https://bugs.openjdk.org/browse/JDK-8341901
which is under progress.
Thanks,
Jan
On 12. 10. 24 23:11, Remi Forax wrote:
> Hello,
> this code does not compile correctly:
>
> public class StaticSelect<T> {
> record A<T>(T value) {}
> record Pair<T>(A<T> a, int size) {}
>
> static <T> Pair<T> bar(A<T> a) {
> return new Pair<>(a, 0);
> }
>
> void foo(A<T> a) {
> switch (bar(a)) {
> case Pair<T>(/*A<T>*/ var a2, int s) -> {}
> }
> }
> }
>
>
> Fails with javac either JDK 23 or JDK 24 build 19
>
> javac StaticSelect.java
> error: cannot select a static class from a parameterized type
> 1 error
>
> No idea why, but changing "var a2" by "A<T> a2" fixes the issue.
>
> regards,
> Rémi
More information about the amber-dev
mailing list