Implement rendering of raw types
Also add some clarification in spec
This commit is contained in:
@@ -69,11 +69,17 @@ k(int[]) = IntArray
|
||||
Raw Java types (see https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.8 for clarification) are loaded as usual flexible types with special arguments projections.
|
||||
|
||||
```
|
||||
Raw(G<T1>..F<T2>) = (G<ErasedUpperBound(T1)>..F<out ErasedUpperBound(T2)>) // T1 and T2 have invariant or `out` variance
|
||||
Raw(G<T1>..F<T2>) = (G<ErasedUpperBound(T1)>..F<Nothing>) // T1 and T2 have `in` variance
|
||||
```
|
||||
Raw(G) = (G<ErasedUpperBound(T)>..G<out ErasedUpperBound(T)>?) // T is a generic parameter of G and it's invariant or has `out` variance.
|
||||
// notation: G<(raw) ErasedUpperBound(T)>!
|
||||
|
||||
where `G<T1>..F<T2>` is initially loaded flexible type with yet unsubstituted type parameters.
|
||||
Raw(G) = (G<ErasedUpperBound(T1)>..G<Nothing>?) // T is a generic parameter of G and it has `in` variance.
|
||||
|
||||
Raw(java.util.Collection) = (MutableCollection<ErasedUpperBound(T)>..Collection<out ErasedUpperBound(T)?>)
|
||||
// notation: (Mutable)Collection<(raw) ErasedUpperBound(T)>!
|
||||
|
||||
Raw(A) = (A..A?) // A has no generic parameter
|
||||
// notation: A(raw)!
|
||||
```
|
||||
|
||||
`ErasedUpperBound` defined as follows:
|
||||
|
||||
@@ -90,22 +96,24 @@ that should be handled properly, e.g. by loading such ErasedUpperBound as Error
|
||||
Examples:
|
||||
|
||||
```
|
||||
Raw(java.util.concurrent.Future) = (Future<Any!>..Future<out Any!>?)
|
||||
Raw(java.util.Collection) = (MutableCollection<Any?>..Collection<out Any?>?)
|
||||
Raw(java.util.concurrent.Future) = (Future<Any!>..Future<out Any!>?) // notation: Future<(raw) Any!>!
|
||||
|
||||
class A<T extends CharSequence> {}
|
||||
Raw(A) = (A<CharSequence!>..A<out CharSequence>)
|
||||
Raw(A) = (A<CharSequence!>..A<out CharSequence>?) // notation: A<(raw) CharSequence!>!
|
||||
|
||||
Raw(java.lang.Enum) = (Enum<Enum<*>>..Enum<out Enum<*>>?)
|
||||
Raw(java.lang.Enum) = (Enum<Enum<*>!>..Enum<out Enum<*>!>?) // notation: Enum<(raw) Enum<*>!>!
|
||||
```
|
||||
|
||||
Also raw types have special types of contained members, each of them is replaced with it's JVM erasure representation:
|
||||
|
||||
```
|
||||
Erase(T) = Erase(UpperBound(T)) // T is a type variable
|
||||
Erase(Array<t>) = Array<Erase(t)>
|
||||
Erase(G<t>) = Raw(G<T>) // G<t> is a type constructed with argument t mapped onto parameter T
|
||||
Erase(A) = A // A is a type constructor without parameters
|
||||
Erase(Array<T>) = Array<Erase(T)>
|
||||
Erase(G<T>) = Raw(G)
|
||||
Erase(A) = Raw(A) // `A` is a type constructor without parameters
|
||||
// NOTE: The latter rule needed for proper erasure inside member scope of A
|
||||
// E.g. if A has property with type `Foo<String>``
|
||||
// then it becomes `Foo<(raw) Any!>` inside Erase(A)
|
||||
```
|
||||
|
||||
## Overriding
|
||||
|
||||
Reference in New Issue
Block a user