java 17: anonymous classes with diamonds
Anna Kozlova
anna.kozlova at jetbrains.com
Mon Jan 18 09:38:39 UTC 2021
Hi all,
The following code doesn't compile with java 17 eap (java: foo.Boo.Nested
is abstract; cannot be instantiated)
```
public class Boo {
static abstract class Nested<T> {
protected Nested(Class<T> aAcceptedClass) { }
}
static class Outer<T> {
protected Outer(final Nested<T> condition) { }
}
static final Outer<Boo> PATTERN = new Outer<>(new
Nested<>(Boo.class) {}) {};
}
```
though the anonymous class is used.
At the same time, if I remove the anonymous class from outer call, like
`static final Outer<Boo> PATTERN = new Outer<>(new Nested<>(Boo.class) {});`
the code would compile.
If explicit types instead of diamonds are used, everything compiles fine as
well.
To me this looks like a bug in the compiler, could someone check this
please?
Thanks,
Anna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20210118/bcdcf2fa/attachment.htm>
More information about the compiler-dev
mailing list