[enhanced-enums]: Enhanced enums failure with raw types?
bsrbnd at gmail.com
Mon Sep 18 18:59:08 UTC 2017
On 18 September 2017 at 16:28, Maurizio Cimadamore
<maurizio.cimadamore at oracle.com> wrote:
> In any case, changing the compiler behavior in this area is a big change,
> and should be considered carefully, and as part of a more holistic effort to
> bring the compiler in sync with the spec.
I agree with you.
And while our example might be related to JDK-8026527, I think it
looks more like JDK-7177306.
Which also means that javac's current behavior with
"EnumSet<G<Object>> g3 = EnumSet.allOf(G.class)" would be compliant
with the JLS 9:
* according to §22.214.171.124, "G" being raw, the constraint < EnumSet ->
EnumSet<G<Object>> > is incorporated.
* then "EnumSet" have to be compatible in a loose invocation context
with "EnumSet<G<Object>>" (§18.1.2).
* and in such a case (§5.3), an unchecked conversion may then be applied.
The compiler should then emit an unchecked warning and succeed.
So, I think that the current behavior looks correct in our example
even if some non-conformance issues still remain, as you mentioned.
Do we agree with this temporary conclusion?
More information about the amber-dev