-
Bug
-
Resolution: Unresolved
-
P4
-
8, 9
JLS 4.5: "A parameterized type C<T1,...,Tn> is well-formed if ... When subjected to capture conversion (§5.1.10) resulting in the type C<X1,...,Xn>, each type argument Xi is a subtype of S[F1:=X1,...,Fn:=Xn] for each bound type S in Bi. It is a compile-time error if a parameterized type is not well-formed."
javac does not enforce the restriction. Instead, it checks the wildcard bound directly against the declaration-site bound (see checkExtends in Check.java). For upper bounds, this involves a castability check. For lower bounds, this involves a novel check called 'notSoftSubtypes'.
Questions:
- There are types that pass the javac check but not the JLS capture check. If we allow these types to be considered valid, what happens when they actually get captured somewhere downstream? Are we violating invariants of the type checker?
- Are there any types that pass the JLS capture check but not the javac check? If so, are there good reasons to prohibit them?
This bug may be resolved by updating JLS, producing a new bug requiring javac to conform to JLS, or some of both.
javac does not enforce the restriction. Instead, it checks the wildcard bound directly against the declaration-site bound (see checkExtends in Check.java). For upper bounds, this involves a castability check. For lower bounds, this involves a novel check called 'notSoftSubtypes'.
Questions:
- There are types that pass the javac check but not the JLS capture check. If we allow these types to be considered valid, what happens when they actually get captured somewhere downstream? Are we violating invariants of the type checker?
- Are there any types that pass the JLS capture check but not the javac check? If so, are there good reasons to prohibit them?
This bug may be resolved by updating JLS, producing a new bug requiring javac to conform to JLS, or some of both.
- relates to
-
JDK-8054937 5.1.10: Fresh capture variables sometimes can't conform to bounds
- Open
-
JDK-8043351 4.5: Capture to check well-formedness of a parameterized type may be undefined
- Open
-
JDK-8274183 StackOverflowError on computing the GLB
- Closed