Load raw types as platform with specific bounds
Raw(A<T_i>) = (A<UP(T_i)>..A<*>) Raw types have specific scopes that behaves like JVM signature erasure
This commit is contained in:
@@ -6,7 +6,7 @@ package test {
|
|||||||
public open class Usage {
|
public open class Usage {
|
||||||
public constructor Usage()
|
public constructor Usage()
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public/*package*/ open fun foo(/*0*/ c: kotlin.(Mutable)Collection<*>!): kotlin.Unit
|
public/*package*/ open fun foo(/*0*/ c: (kotlin.MutableCollection<kotlin.Any?>..kotlin.Collection<*>?)): kotlin.Unit
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package
|
package
|
||||||
|
|
||||||
public /*synthesized*/ fun Bar(/*0*/ function: (Foo<*>!) -> kotlin.Unit): Bar
|
public /*synthesized*/ fun Bar(/*0*/ function: ((Foo<kotlin.CharSequence!>..Foo<*>?)) -> kotlin.Unit): Bar
|
||||||
|
|
||||||
public interface Bar {
|
public interface Bar {
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public abstract fun f(/*0*/ f: Foo<*>!): kotlin.Unit
|
public abstract fun f(/*0*/ f: (Foo<kotlin.CharSequence!>..Foo<*>?)): kotlin.Unit
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package
|
package
|
||||||
|
|
||||||
internal fun foo(/*0*/ p: X): Bad<*>!
|
internal fun foo(/*0*/ p: X): (Bad<(Bad<Bad<*>!>..Bad<out Bad<*>!>?)>..Bad<out (Bad<Bad<*>!>..Bad<out Bad<*>!>?)>?)
|
||||||
|
|
||||||
public/*package*/ open class Bad</*0*/ T : Bad<out kotlin.Any?>!> {
|
public/*package*/ open class Bad</*0*/ T : (Bad<Bad<*>>..Bad<out Bad<*>>?)> {
|
||||||
public/*package*/ constructor Bad</*0*/ T : Bad<out kotlin.Any?>!>()
|
public/*package*/ constructor Bad</*0*/ T : (Bad<Bad<*>>..Bad<out Bad<*>>?)>()
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
@@ -12,7 +12,7 @@ public/*package*/ open class Bad</*0*/ T : Bad<out kotlin.Any?>!> {
|
|||||||
public/*package*/ open class X {
|
public/*package*/ open class X {
|
||||||
public/*package*/ constructor X()
|
public/*package*/ constructor X()
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public/*package*/ open fun foo(): Bad<*>!
|
public/*package*/ open fun foo(): (Bad<(Bad<Bad<*>!>..Bad<out Bad<*>!>?)>..Bad<out (Bad<Bad<*>!>..Bad<out Bad<*>!>?)>?)
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class A<T extends CharSequence, E> {
|
||||||
|
T[] charSequences;
|
||||||
|
Map<String, T>[] maps;
|
||||||
|
List<Double>[][] arraysOfLists;
|
||||||
|
E[][] arraysOfAny;
|
||||||
|
|
||||||
|
List<Double[]>[] erasedLists;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Test.java
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
static class RawADerived extends A {}
|
||||||
|
static A rawAField = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
fun arrayOf<T>(): Array<T> = null!!
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val raw = Test.rawAField
|
||||||
|
|
||||||
|
raw.charSequences = arrayOf<String>()
|
||||||
|
raw.charSequences = <!TYPE_MISMATCH!>arrayOf<Double>()<!>
|
||||||
|
|
||||||
|
raw.maps = arrayOf<Map<Int, Int>>()
|
||||||
|
raw.maps = arrayOf<MutableMap<Int, Int>>()
|
||||||
|
raw.maps = <!TYPE_MISMATCH!>arrayOf<List<String>>()<!>
|
||||||
|
|
||||||
|
raw.arraysOfLists = arrayOf<Array<List<*>>>()
|
||||||
|
raw.arraysOfLists = <!TYPE_MISMATCH!>arrayOf<List<String>>()<!>
|
||||||
|
raw.arraysOfLists = <!TYPE_MISMATCH!>arrayOf<Array<Array<String>>>()<!>
|
||||||
|
|
||||||
|
raw.arraysOfAny = arrayOf<Array<Array<String>>>()
|
||||||
|
|
||||||
|
raw.erasedLists = arrayOf<List<String>>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal fun </*0*/ T> arrayOf(): kotlin.Array<T>
|
||||||
|
internal fun main(): kotlin.Unit
|
||||||
|
|
||||||
|
public open class A</*0*/ T : kotlin.CharSequence!, /*1*/ E : kotlin.Any!> {
|
||||||
|
public constructor A</*0*/ T : kotlin.CharSequence!, /*1*/ E : kotlin.Any!>()
|
||||||
|
public/*package*/ final var arraysOfAny: kotlin.Array<(out) kotlin.Array<(out) E!>!>!
|
||||||
|
public/*package*/ final var arraysOfLists: kotlin.Array<(out) kotlin.Array<(out) kotlin.(Mutable)List<kotlin.Double!>!>!>!
|
||||||
|
public/*package*/ final var charSequences: kotlin.Array<(out) T!>!
|
||||||
|
public/*package*/ final var erasedLists: kotlin.Array<(out) kotlin.(Mutable)List<kotlin.Array<(out) kotlin.Double!>!>!>!
|
||||||
|
public/*package*/ final var maps: kotlin.Array<(out) kotlin.(Mutable)Map<kotlin.String!, T!>!>!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public/*package*/ open class Test {
|
||||||
|
public/*package*/ constructor Test()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public/*package*/ open class RawADerived : A<kotlin.CharSequence!, kotlin.Any!> {
|
||||||
|
public/*package*/ constructor RawADerived()
|
||||||
|
public/*package*/ final override /*1*/ /*fake_override*/ var arraysOfAny: kotlin.Array<(out) kotlin.Array<(out) kotlin.Any!>!>!
|
||||||
|
public/*package*/ final override /*1*/ /*fake_override*/ var arraysOfLists: kotlin.Array<(out) kotlin.Array<(out) (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)>!>!
|
||||||
|
public/*package*/ final override /*1*/ /*fake_override*/ var charSequences: kotlin.Array<(out) kotlin.CharSequence!>!
|
||||||
|
public/*package*/ final override /*1*/ /*fake_override*/ var erasedLists: kotlin.Array<(out) (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)>!
|
||||||
|
public/*package*/ final override /*1*/ /*fake_override*/ var maps: kotlin.Array<(out) (kotlin.MutableMap<kotlin.Any?, kotlin.Any?>..kotlin.Map<*, *>?)>!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public/*package*/ final var rawAField: (A<kotlin.CharSequence!, kotlin.Any!>..A<*, *>?)
|
||||||
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
class A<T> {
|
||||||
|
|
||||||
|
void foo(T x)
|
||||||
|
|
||||||
|
public class Inner<E> {
|
||||||
|
Inner(E x0, T x, List<T> y) {}
|
||||||
|
|
||||||
|
void foo(E x0, T x, List<T> y) {}
|
||||||
|
A<Map<E, T>> bar() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Test.java
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
static A rawAField = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
val strList: List<String> = null!!
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val rawA = Test.rawAField
|
||||||
|
var rawInner = rawA.Inner<Double>("", "", strList)
|
||||||
|
rawInner.foo("", "", strList)
|
||||||
|
rawInner.bar().foo("")
|
||||||
|
}
|
||||||
|
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal val strList: kotlin.List<kotlin.String>
|
||||||
|
internal fun main(): kotlin.Unit
|
||||||
|
|
||||||
|
public/*package*/ open class A</*0*/ T : kotlin.Any!> {
|
||||||
|
public/*package*/ constructor A</*0*/ T : kotlin.Any!>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public/*package*/ open fun foo(/*0*/ x: T!): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public open inner class Inner</*0*/ E : kotlin.Any!> {
|
||||||
|
public/*package*/ constructor Inner</*0*/ E : kotlin.Any!>(/*0*/ x0: E!, /*1*/ x: T!, /*2*/ y: kotlin.(Mutable)List<T!>!)
|
||||||
|
public/*package*/ open fun bar(): A<kotlin.(Mutable)Map<E!, T!>!>!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public/*package*/ open fun foo(/*0*/ x0: E!, /*1*/ x: T!, /*2*/ y: kotlin.(Mutable)List<T!>!): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public/*package*/ open class Test {
|
||||||
|
public/*package*/ constructor Test()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public/*package*/ final var rawAField: (A<kotlin.Any!>..A<*>?)
|
||||||
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
class A<T> {
|
||||||
|
B b;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: B.java
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
class B {
|
||||||
|
void bar(List<Double> x);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Test.java
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
static A rawAField = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
val strList: List<String> = null!!
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val rawB = Test.rawAField.b;
|
||||||
|
// Raw(A).b is erased too although it have no type parameters
|
||||||
|
// so it's `bar` allows lists of any types
|
||||||
|
var rawInner = rawB.bar(strList)
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal val strList: kotlin.List<kotlin.String>
|
||||||
|
internal fun main(): kotlin.Unit
|
||||||
|
|
||||||
|
public/*package*/ open class A</*0*/ T : kotlin.Any!> {
|
||||||
|
public/*package*/ constructor A</*0*/ T : kotlin.Any!>()
|
||||||
|
public/*package*/ final var b: B!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public/*package*/ open class B {
|
||||||
|
public/*package*/ constructor B()
|
||||||
|
public/*package*/ open fun bar(/*0*/ x: kotlin.(Mutable)List<kotlin.Double!>!): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public/*package*/ open class Test {
|
||||||
|
public/*package*/ constructor Test()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public/*package*/ final var rawAField: (A<kotlin.Any!>..A<*>?)
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
class A<T extends A<T, E>, E extends T, F extends List<? extends Double>> {
|
||||||
|
T first;
|
||||||
|
E second;
|
||||||
|
F listOfDoubles;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Test.java
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
static class DerivedRawA extends A {}
|
||||||
|
static A rawAField = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
val strList: List<String> = null!!
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val rawA = Test.rawAField
|
||||||
|
rawA.first = Test.rawAField.second
|
||||||
|
Test.rawAField.second = rawA.first.second
|
||||||
|
|
||||||
|
rawA.listOfDoubles = strList
|
||||||
|
rawA.listOfDoubles = <!TYPE_MISMATCH!>""<!> // first should be List
|
||||||
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal val strList: kotlin.List<kotlin.String>
|
||||||
|
internal fun main(): kotlin.Unit
|
||||||
|
|
||||||
|
public/*package*/ open class A</*0*/ T : (A<A<*, *, *>, A<*, *, *>, kotlin.(Mutable)List<*>!>..A<out A<*, *, *>, out A<*, *, *>, out kotlin.(Mutable)List<*>!>?), /*1*/ E : T!, /*2*/ F : (kotlin.MutableList<out kotlin.Double!>..kotlin.List<kotlin.Double!>?)> {
|
||||||
|
public/*package*/ constructor A</*0*/ T : (A<A<*, *, *>, A<*, *, *>, kotlin.(Mutable)List<*>!>..A<out A<*, *, *>, out A<*, *, *>, out kotlin.(Mutable)List<*>!>?), /*1*/ E : T!, /*2*/ F : (kotlin.MutableList<out kotlin.Double!>..kotlin.List<kotlin.Double!>?)>()
|
||||||
|
public/*package*/ final var first: T!
|
||||||
|
public/*package*/ final var listOfDoubles: F!
|
||||||
|
public/*package*/ final var second: E!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public/*package*/ open class Test {
|
||||||
|
public/*package*/ constructor Test()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public/*package*/ open class DerivedRawA : A<out A<*, *, *>!, out A<*, *, *>!, out kotlin.(Mutable)List<*>!> {
|
||||||
|
public/*package*/ constructor DerivedRawA()
|
||||||
|
public/*package*/ final override /*1*/ /*fake_override*/ var first: (A<A<*, *, *>!, A<*, *, *>!, kotlin.(Mutable)List<*>!>..A<out A<*, *, *>!, out A<*, *, *>!, out kotlin.(Mutable)List<*>!>?)
|
||||||
|
public/*package*/ final override /*1*/ /*fake_override*/ var listOfDoubles: (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)
|
||||||
|
public/*package*/ final override /*1*/ /*fake_override*/ var second: (A<A<*, *, *>!, A<*, *, *>!, kotlin.(Mutable)List<*>!>..A<out A<*, *, *>!, out A<*, *, *>!, out kotlin.(Mutable)List<*>!>?)
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public/*package*/ final var rawAField: (A<(A<A<*, *, *>!, A<*, *, *>!, kotlin.(Mutable)List<*>!>..A<out A<*, *, *>!, out A<*, *, *>!, out kotlin.(Mutable)List<*>!>?), (A<A<*, *, *>!, A<*, *, *>!, kotlin.(Mutable)List<*>!>..A<out A<*, *, *>!, out A<*, *, *>!, out kotlin.(Mutable)List<*>!>?), (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)>..A<out (A<A<*, *, *>!, A<*, *, *>!, kotlin.(Mutable)List<*>!>..A<out A<*, *, *>!, out A<*, *, *>!, out kotlin.(Mutable)List<*>!>?), out (A<A<*, *, *>!, A<*, *, *>!, kotlin.(Mutable)List<*>!>..A<out A<*, *, *>!, out A<*, *, *>!, out kotlin.(Mutable)List<*>!>?), out (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)>?)
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
class A<T> {
|
||||||
|
List<T> x;
|
||||||
|
|
||||||
|
void foo(T x, List<T> y) {}
|
||||||
|
|
||||||
|
A<List<T>> bar() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Test.java
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
static class RawADerived extends A {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
val strList: List<String> = null!!
|
||||||
|
val strMap: Map<String, String> = null!!
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val rawADerived = Test.RawADerived()
|
||||||
|
rawADerived.x = strList
|
||||||
|
rawADerived.foo("", strList)
|
||||||
|
|
||||||
|
|
||||||
|
val rawA = rawADerived.bar()
|
||||||
|
rawA.x = strList
|
||||||
|
rawA.foo("", strList)
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal val strList: kotlin.List<kotlin.String>
|
||||||
|
internal val strMap: kotlin.Map<kotlin.String, kotlin.String>
|
||||||
|
internal fun main(): kotlin.Unit
|
||||||
|
|
||||||
|
public/*package*/ open class A</*0*/ T : kotlin.Any!> {
|
||||||
|
public/*package*/ constructor A</*0*/ T : kotlin.Any!>()
|
||||||
|
public/*package*/ final var x: kotlin.(Mutable)List<T!>!
|
||||||
|
public/*package*/ open fun bar(): A<kotlin.(Mutable)List<T!>!>!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public/*package*/ open fun foo(/*0*/ x: T!, /*1*/ y: kotlin.(Mutable)List<T!>!): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public/*package*/ open class Test {
|
||||||
|
public/*package*/ constructor Test()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public/*package*/ open class RawADerived : A<kotlin.Any!> {
|
||||||
|
public/*package*/ constructor RawADerived()
|
||||||
|
public/*package*/ final override /*1*/ /*fake_override*/ var x: (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)
|
||||||
|
public/*package*/ open override /*1*/ /*fake_override*/ fun bar(): (A<kotlin.Any!>..A<*>?)
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public/*package*/ open override /*1*/ /*fake_override*/ fun foo(/*0*/ x: kotlin.Any!, /*1*/ y: (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
class A<T extends CharSequence> {
|
||||||
|
A<List<T>> foo(T x, Map<String, List<T>> y, HashMap<T, T> z) {}
|
||||||
|
|
||||||
|
void bar(List<Double[]>[][] d) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: RawADerived.java
|
||||||
|
|
||||||
|
class RawADerived extends A {
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
class B1 : RawADerived() {
|
||||||
|
override fun foo(x: CharSequence, y: Map<Any?, Any?>, z: HashMap<Any, Any>): A<*> = null!!
|
||||||
|
|
||||||
|
override fun bar(d: Array<Array<List<*>>>) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class B2 : RawADerived() {
|
||||||
|
override fun foo(x: CharSequence?, y: MutableMap<Any?, Any?>, z: HashMap<Any?, Any?>): A<String> = null!!
|
||||||
|
|
||||||
|
override fun bar(d: Array<Array<MutableList<*>>>) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class B3 : RawADerived() {
|
||||||
|
// Type of second parameter (y) is not equal to overridden
|
||||||
|
// RawADerived.foo.y --- (MutableMap<Any?, Any?>..Map<out Any?, out Any?>) is not a subtype of Map<Any?, Any>
|
||||||
|
<!NOTHING_TO_OVERRIDE!>override<!> fun foo(x: CharSequence, y: Map<Any?, Any>, z: HashMap<Any, Any>): A<*> = null!!
|
||||||
|
}
|
||||||
|
|
||||||
|
class B4 : RawADerived() {
|
||||||
|
// Type of first parameter is not equal to overridden
|
||||||
|
<!NOTHING_TO_OVERRIDE!>override<!> fun bar(d: Array<Array<MutableList<Array<Double>>>>) {}
|
||||||
|
}
|
||||||
+57
@@ -0,0 +1,57 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public/*package*/ open class A</*0*/ T : kotlin.CharSequence!> {
|
||||||
|
public/*package*/ constructor A</*0*/ T : kotlin.CharSequence!>()
|
||||||
|
public/*package*/ open fun bar(/*0*/ d: kotlin.Array<(out) kotlin.Array<(out) kotlin.(Mutable)List<kotlin.Array<(out) kotlin.Double!>!>!>!>!): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public/*package*/ open fun foo(/*0*/ x: T!, /*1*/ y: kotlin.(Mutable)Map<kotlin.String!, kotlin.(Mutable)List<T!>!>!, /*2*/ z: java.util.HashMap<T!, T!>!): A<kotlin.(Mutable)List<T!>!>!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
internal final class B1 : RawADerived {
|
||||||
|
public constructor B1()
|
||||||
|
internal open override /*1*/ fun bar(/*0*/ d: kotlin.Array<kotlin.Array<kotlin.List<*>>>): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
internal open override /*1*/ fun foo(/*0*/ x: kotlin.CharSequence, /*1*/ y: kotlin.Map<kotlin.Any?, kotlin.Any?>, /*2*/ z: java.util.HashMap<kotlin.Any, kotlin.Any>): A<*>
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
internal final class B2 : RawADerived {
|
||||||
|
public constructor B2()
|
||||||
|
internal open override /*1*/ fun bar(/*0*/ d: kotlin.Array<kotlin.Array<kotlin.MutableList<*>>>): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
internal open override /*1*/ fun foo(/*0*/ x: kotlin.CharSequence?, /*1*/ y: kotlin.MutableMap<kotlin.Any?, kotlin.Any?>, /*2*/ z: java.util.HashMap<kotlin.Any?, kotlin.Any?>): A<kotlin.String>
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
internal final class B3 : RawADerived {
|
||||||
|
public constructor B3()
|
||||||
|
public/*package*/ open override /*1*/ /*fake_override*/ fun bar(/*0*/ d: kotlin.Array<(out) kotlin.Array<(out) (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)>!>!): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
internal open fun foo(/*0*/ x: kotlin.CharSequence, /*1*/ y: kotlin.Map<kotlin.Any?, kotlin.Any>, /*2*/ z: java.util.HashMap<kotlin.Any, kotlin.Any>): A<*>
|
||||||
|
public/*package*/ open override /*1*/ /*fake_override*/ fun foo(/*0*/ x: kotlin.CharSequence!, /*1*/ y: (kotlin.MutableMap<kotlin.Any?, kotlin.Any?>..kotlin.Map<*, *>?), /*2*/ z: (java.util.HashMap<kotlin.Any!, kotlin.Any!>..java.util.HashMap<*, *>?)): (A<kotlin.CharSequence!>..A<*>?)
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
internal final class B4 : RawADerived {
|
||||||
|
public constructor B4()
|
||||||
|
public/*package*/ open override /*1*/ /*fake_override*/ fun bar(/*0*/ d: kotlin.Array<(out) kotlin.Array<(out) (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)>!>!): kotlin.Unit
|
||||||
|
internal open fun bar(/*0*/ d: kotlin.Array<kotlin.Array<kotlin.MutableList<kotlin.Array<kotlin.Double>>>>): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public/*package*/ open override /*1*/ /*fake_override*/ fun foo(/*0*/ x: kotlin.CharSequence!, /*1*/ y: (kotlin.MutableMap<kotlin.Any?, kotlin.Any?>..kotlin.Map<*, *>?), /*2*/ z: (java.util.HashMap<kotlin.Any!, kotlin.Any!>..java.util.HashMap<*, *>?)): (A<kotlin.CharSequence!>..A<*>?)
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public/*package*/ open class RawADerived : A<kotlin.CharSequence!> {
|
||||||
|
public/*package*/ constructor RawADerived()
|
||||||
|
public/*package*/ open override /*1*/ /*fake_override*/ fun bar(/*0*/ d: kotlin.Array<(out) kotlin.Array<(out) (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)>!>!): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public/*package*/ open override /*1*/ /*fake_override*/ fun foo(/*0*/ x: kotlin.CharSequence!, /*1*/ y: (kotlin.MutableMap<kotlin.Any?, kotlin.Any?>..kotlin.Map<*, *>?), /*2*/ z: (java.util.HashMap<kotlin.Any!, kotlin.Any!>..java.util.HashMap<*, *>?)): (A<kotlin.CharSequence!>..A<*>?)
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class A<T> {
|
||||||
|
List<String> getChildrenStubs() { return null; }
|
||||||
|
void consume(T x) {}
|
||||||
|
|
||||||
|
T produce() { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: B.java
|
||||||
|
|
||||||
|
public class B<E extends A> {
|
||||||
|
public E foo() { return null;}
|
||||||
|
E field;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Test.java
|
||||||
|
|
||||||
|
public class Test {
|
||||||
|
static B rawB = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
fun foo(x: B<*>) {
|
||||||
|
val q: MutableList<String> = <!TYPE_MISMATCH!>x.foo().getChildrenStubs()<!>
|
||||||
|
|
||||||
|
// Raw(B).field erased to A<Any!>..A<out Any!>?
|
||||||
|
Test.rawB.field = A<String>()
|
||||||
|
val anyA: A<Any> = Test.rawB.field
|
||||||
|
|
||||||
|
Test.rawB.field.consume("")
|
||||||
|
val y: Any = Test.rawB.field.produce()
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal fun foo(/*0*/ x: B<*>): kotlin.Unit
|
||||||
|
|
||||||
|
public open class A</*0*/ T : kotlin.Any!> {
|
||||||
|
public constructor A</*0*/ T : kotlin.Any!>()
|
||||||
|
public/*package*/ open fun consume(/*0*/ x: T!): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public/*package*/ open fun getChildrenStubs(): kotlin.(Mutable)List<kotlin.String!>!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public/*package*/ open fun produce(): T!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public open class B</*0*/ E : (A<kotlin.Any!>..A<*>?)> {
|
||||||
|
public constructor B</*0*/ E : (A<kotlin.Any!>..A<*>?)>()
|
||||||
|
public/*package*/ final var field: E!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open fun foo(): E!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public open class Test {
|
||||||
|
public constructor Test()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public/*package*/ final var rawB: (B<(A<kotlin.Any!>..A<*>?)>..B<out (A<kotlin.Any!>..A<*>?)>?)
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
// FILE: Test.java
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
static void foo(Comparable x) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
Test.foo(1)
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal fun main(): kotlin.Unit
|
||||||
|
|
||||||
|
public/*package*/ open class Test {
|
||||||
|
public/*package*/ constructor Test()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public/*package*/ open fun foo(/*0*/ x: (kotlin.Comparable<in kotlin.Any?>..kotlin.Comparable<in kotlin.Nothing>?)): kotlin.Unit
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface A<T extends A> {}
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
class D : A<D>
|
||||||
|
|
||||||
|
fun main(x: A<*>) {
|
||||||
|
if (x is D) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal fun main(/*0*/ x: A<*>): kotlin.Unit
|
||||||
|
|
||||||
|
public interface A</*0*/ T : (A<A<*>>..A<out A<*>>?)> {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
internal final class D : A<D> {
|
||||||
|
public constructor D()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface A<T> {
|
||||||
|
boolean value(T t);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: B.java
|
||||||
|
|
||||||
|
class B {
|
||||||
|
void foo(Runnable runnable, A x);
|
||||||
|
|
||||||
|
static A bar() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
fun println() {}
|
||||||
|
// All parameters in SAM adapter of `foo` have functional types
|
||||||
|
B().foo(<!TYPE_MISMATCH!>{ println() }<!>, B.bar())
|
||||||
|
// So you should use SAM constructors when you want to use mix lambdas and Java objects
|
||||||
|
B().foo(Runnable { println() }, B.bar())
|
||||||
|
B().foo({ println() }, { it: Any? -> true } )
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public /*synthesized*/ fun </*0*/ T : kotlin.Any!> A(/*0*/ function: (T!) -> kotlin.Boolean): A<T>
|
||||||
|
internal fun main(): kotlin.Unit
|
||||||
|
|
||||||
|
public interface A</*0*/ T : kotlin.Any!> {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
public abstract fun value(/*0*/ t: T!): kotlin.Boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
public/*package*/ open class B {
|
||||||
|
public/*package*/ constructor B()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public/*package*/ final /*synthesized*/ fun foo(/*0*/ runnable: (() -> kotlin.Unit)!, /*1*/ x: ((kotlin.Any!) -> kotlin.Boolean)!): kotlin.Unit
|
||||||
|
public/*package*/ open fun foo(/*0*/ runnable: java.lang.Runnable!, /*1*/ x: (A<kotlin.Any!>..A<*>?)): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public/*package*/ open fun bar(): (A<kotlin.Any!>..A<*>?)
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
class A<T> {
|
||||||
|
List<T> x;
|
||||||
|
Map<T, T> y;
|
||||||
|
|
||||||
|
A<Map<String, T>> z;
|
||||||
|
|
||||||
|
void foo(T x, List<T> y, List<Map<Integer, T>> z) {}
|
||||||
|
|
||||||
|
A<List<T>> bar() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Test.java
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
static A rawAField = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
val strList: List<String> = null!!
|
||||||
|
val strMap: Map<String, String> = null!!
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val rawA = Test.rawAField
|
||||||
|
rawA.x = strList
|
||||||
|
rawA.y = strMap
|
||||||
|
rawA.foo("", strList, strList)
|
||||||
|
|
||||||
|
val barResult = rawA.bar()
|
||||||
|
|
||||||
|
barResult.x = strList
|
||||||
|
barResult.y = strMap
|
||||||
|
barResult.foo("", strList, null)
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal val strList: kotlin.List<kotlin.String>
|
||||||
|
internal val strMap: kotlin.Map<kotlin.String, kotlin.String>
|
||||||
|
internal fun main(): kotlin.Unit
|
||||||
|
|
||||||
|
public/*package*/ open class A</*0*/ T : kotlin.Any!> {
|
||||||
|
public/*package*/ constructor A</*0*/ T : kotlin.Any!>()
|
||||||
|
public/*package*/ final var x: kotlin.(Mutable)List<T!>!
|
||||||
|
public/*package*/ final var y: kotlin.(Mutable)Map<T!, T!>!
|
||||||
|
public/*package*/ final var z: A<kotlin.(Mutable)Map<kotlin.String!, T!>!>!
|
||||||
|
public/*package*/ open fun bar(): A<kotlin.(Mutable)List<T!>!>!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public/*package*/ open fun foo(/*0*/ x: T!, /*1*/ y: kotlin.(Mutable)List<T!>!, /*2*/ z: kotlin.(Mutable)List<kotlin.(Mutable)Map<kotlin.Int!, T!>!>!): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public/*package*/ open class Test {
|
||||||
|
public/*package*/ constructor Test()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public/*package*/ final var rawAField: (A<kotlin.Any!>..A<*>?)
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
class A<T extends CharSequence> {}
|
||||||
|
|
||||||
|
// FILE: B.java
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
class B<E extends A> {}
|
||||||
|
|
||||||
|
// FILE: Test.java
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
static void foo(B x) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
|
||||||
|
fun main(x: B<*>) {
|
||||||
|
Test.foo(x)
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal fun main(/*0*/ x: B<*>): kotlin.Unit
|
||||||
|
|
||||||
|
public/*package*/ open class A</*0*/ T : kotlin.CharSequence!> {
|
||||||
|
public/*package*/ constructor A</*0*/ T : kotlin.CharSequence!>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public/*package*/ open class B</*0*/ E : (A<kotlin.CharSequence!>..A<*>?)> {
|
||||||
|
public/*package*/ constructor B</*0*/ E : (A<kotlin.CharSequence!>..A<*>?)>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public/*package*/ open class Test {
|
||||||
|
public/*package*/ constructor Test()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public/*package*/ open fun foo(/*0*/ x: (B<(A<kotlin.CharSequence!>..A<*>?)>..B<out (A<kotlin.CharSequence!>..A<*>?)>?)): kotlin.Unit
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
class A<T> {
|
||||||
|
@NotNull
|
||||||
|
List<@Nullable String> foo(@NotNull T x, @Nullable List<@NotNull String> y) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Test.java
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
static class DerivedRawA extends A {}
|
||||||
|
|
||||||
|
static A rawField = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
val doubleList: List<Double?> = null!!
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
Test.rawField.foo("", doubleList)
|
||||||
|
Test.rawField.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, doubleList)
|
||||||
|
Test.DerivedRawA().foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, doubleList)
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal val doubleList: kotlin.List<kotlin.Double?>
|
||||||
|
internal fun main(): kotlin.Unit
|
||||||
|
|
||||||
|
public/*package*/ open class A</*0*/ T : kotlin.Any!> {
|
||||||
|
public/*package*/ constructor A</*0*/ T : kotlin.Any!>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
org.jetbrains.annotations.NotNull() public/*package*/ open fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: T, /*1*/ org.jetbrains.annotations.Nullable() y: kotlin.(Mutable)List<kotlin.String>?): kotlin.(Mutable)List<kotlin.String?>
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public/*package*/ open class Test {
|
||||||
|
public/*package*/ constructor Test()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public/*package*/ open class DerivedRawA : A<kotlin.Any!> {
|
||||||
|
public/*package*/ constructor DerivedRawA()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
org.jetbrains.annotations.NotNull() public/*package*/ open override /*1*/ /*fake_override*/ fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: kotlin.Any, /*1*/ org.jetbrains.annotations.Nullable() y: (kotlin.MutableList<kotlin.Any?>?..kotlin.List<*>?)): (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>)
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public/*package*/ final var rawField: (A<kotlin.Any!>..A<*>?)
|
||||||
|
}
|
||||||
+1
-1
@@ -61,7 +61,7 @@ internal final class HashMapEx</*0*/ K, /*1*/ V> : java.util.HashMap<K, V>, ExtM
|
|||||||
invisible_fake open override /*1*/ /*fake_override*/ fun resize(/*0*/ p0: kotlin.Int): kotlin.Unit
|
invisible_fake open override /*1*/ /*fake_override*/ fun resize(/*0*/ p0: kotlin.Int): kotlin.Unit
|
||||||
public open override /*2*/ /*fake_override*/ fun size(): kotlin.Int
|
public open override /*2*/ /*fake_override*/ fun size(): kotlin.Int
|
||||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
invisible_fake open override /*1*/ /*fake_override*/ fun transfer(/*0*/ p0: kotlin.Array<(out) java.util.HashMap.Entry<*, *>!>!, /*1*/ p1: kotlin.Boolean): kotlin.Unit
|
invisible_fake open override /*1*/ /*fake_override*/ fun transfer(/*0*/ p0: kotlin.Array<(out) (java.util.HashMap.Entry<kotlin.Any!, kotlin.Any!>..java.util.HashMap.Entry<*, *>?)>!, /*1*/ p1: kotlin.Boolean): kotlin.Unit
|
||||||
public open override /*2*/ /*fake_override*/ fun values(): kotlin.MutableCollection<V>
|
public open override /*2*/ /*fake_override*/ fun values(): kotlin.MutableCollection<V>
|
||||||
invisible_fake open override /*1*/ /*fake_override*/ fun writeObject(/*0*/ p0: java.io.ObjectOutputStream!): kotlin.Unit
|
invisible_fake open override /*1*/ /*fake_override*/ fun writeObject(/*0*/ p0: java.io.ObjectOutputStream!): kotlin.Unit
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ package test {
|
|||||||
invisible_fake final override /*1*/ /*fake_override*/ var focusCycleRoot: kotlin.Boolean
|
invisible_fake final override /*1*/ /*fake_override*/ var focusCycleRoot: kotlin.Boolean
|
||||||
invisible_fake final override /*1*/ /*fake_override*/ var focusListener: [ERROR : Unresolved java classifier: FocusListener]!
|
invisible_fake final override /*1*/ /*fake_override*/ var focusListener: [ERROR : Unresolved java classifier: FocusListener]!
|
||||||
invisible_fake final override /*1*/ /*fake_override*/ var focusMgr: [ERROR : Unresolved java classifier: FocusManager]!
|
invisible_fake final override /*1*/ /*fake_override*/ var focusMgr: [ERROR : Unresolved java classifier: FocusManager]!
|
||||||
invisible_fake final override /*1*/ /*fake_override*/ var focusTraversalKeys: kotlin.Array<(out) kotlin.(Mutable)Set<*>!>!
|
invisible_fake final override /*1*/ /*fake_override*/ var focusTraversalKeys: kotlin.Array<(out) (kotlin.MutableSet<kotlin.Any?>..kotlin.Set<*>?)>!
|
||||||
invisible_fake final override /*1*/ /*fake_override*/ var focusTraversalKeysEnabled: kotlin.Boolean
|
invisible_fake final override /*1*/ /*fake_override*/ var focusTraversalKeysEnabled: kotlin.Boolean
|
||||||
invisible_fake final override /*1*/ /*fake_override*/ var focusTraversalPolicy: [ERROR : Unresolved java classifier: FocusTraversalPolicy]!
|
invisible_fake final override /*1*/ /*fake_override*/ var focusTraversalPolicy: [ERROR : Unresolved java classifier: FocusTraversalPolicy]!
|
||||||
invisible_fake final override /*1*/ /*fake_override*/ var focusTraversalPolicyProvider: kotlin.Boolean
|
invisible_fake final override /*1*/ /*fake_override*/ var focusTraversalPolicyProvider: kotlin.Boolean
|
||||||
@@ -98,7 +98,7 @@ package test {
|
|||||||
invisible_fake final override /*1*/ /*fake_override*/ var prefSizeSet: kotlin.Boolean
|
invisible_fake final override /*1*/ /*fake_override*/ var prefSizeSet: kotlin.Boolean
|
||||||
invisible_fake final override /*1*/ /*fake_override*/ var preserveBackgroundColor: [ERROR : Unresolved java classifier: Color]!
|
invisible_fake final override /*1*/ /*fake_override*/ var preserveBackgroundColor: [ERROR : Unresolved java classifier: Color]!
|
||||||
invisible_fake final override /*1*/ /*fake_override*/ var printing: kotlin.Boolean
|
invisible_fake final override /*1*/ /*fake_override*/ var printing: kotlin.Boolean
|
||||||
invisible_fake final override /*1*/ /*fake_override*/ var printingThreads: kotlin.(Mutable)Set<*>!
|
invisible_fake final override /*1*/ /*fake_override*/ var printingThreads: (kotlin.MutableSet<kotlin.Any?>..kotlin.Set<*>?)
|
||||||
invisible_fake final override /*1*/ /*fake_override*/ var resizable: kotlin.Boolean
|
invisible_fake final override /*1*/ /*fake_override*/ var resizable: kotlin.Boolean
|
||||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var rootPane: [ERROR : Unresolved java classifier: JRootPane]!
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var rootPane: [ERROR : Unresolved java classifier: JRootPane]!
|
||||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var rootPaneCheckingEnabled: kotlin.Boolean
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var rootPaneCheckingEnabled: kotlin.Boolean
|
||||||
@@ -290,7 +290,7 @@ package test {
|
|||||||
public open override /*1*/ /*fake_override*/ fun getFocusOwner(): java.awt.Component!
|
public open override /*1*/ /*fake_override*/ fun getFocusOwner(): java.awt.Component!
|
||||||
public open override /*1*/ /*fake_override*/ fun getFocusTraversalKeys(/*0*/ p0: kotlin.Int): kotlin.(Mutable)Set<java.awt.AWTKeyStroke!>!
|
public open override /*1*/ /*fake_override*/ fun getFocusTraversalKeys(/*0*/ p0: kotlin.Int): kotlin.(Mutable)Set<java.awt.AWTKeyStroke!>!
|
||||||
public open override /*1*/ /*fake_override*/ fun getFocusTraversalKeysEnabled(): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun getFocusTraversalKeysEnabled(): kotlin.Boolean
|
||||||
invisible_fake final override /*1*/ /*fake_override*/ fun getFocusTraversalKeys_NoIDCheck(/*0*/ p0: kotlin.Int): kotlin.(Mutable)Set<*>!
|
invisible_fake final override /*1*/ /*fake_override*/ fun getFocusTraversalKeys_NoIDCheck(/*0*/ p0: kotlin.Int): (kotlin.MutableSet<kotlin.Any?>..kotlin.Set<*>?)
|
||||||
public open override /*1*/ /*fake_override*/ fun getFocusTraversalPolicy(): [ERROR : Unresolved java classifier: FocusTraversalPolicy]!
|
public open override /*1*/ /*fake_override*/ fun getFocusTraversalPolicy(): [ERROR : Unresolved java classifier: FocusTraversalPolicy]!
|
||||||
public open override /*1*/ /*fake_override*/ fun getFocusableWindowState(): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun getFocusableWindowState(): kotlin.Boolean
|
||||||
[ERROR : java.beans.Transient]() public open override /*1*/ /*fake_override*/ fun getFont(): [ERROR : Unresolved java classifier: Font]!
|
[ERROR : java.beans.Transient]() public open override /*1*/ /*fake_override*/ fun getFont(): [ERROR : Unresolved java classifier: Font]!
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package test
|
|||||||
public interface RawTypeWithUpperBound {
|
public interface RawTypeWithUpperBound {
|
||||||
|
|
||||||
public interface Bar {
|
public interface Bar {
|
||||||
public abstract fun f(/*0*/ p0: test.RawTypeWithUpperBound.Foo<*>!): kotlin.Unit
|
public abstract fun f(/*0*/ p0: (test.RawTypeWithUpperBound.Foo<kotlin.CharSequence!>..test.RawTypeWithUpperBound.Foo<*>?)): kotlin.Unit
|
||||||
public abstract fun g(/*0*/ p0: kotlin.(Mutable)List<test.RawTypeWithUpperBound.Foo<*>!>!): kotlin.Unit
|
public abstract fun g(/*0*/ p0: kotlin.(Mutable)List<(test.RawTypeWithUpperBound.Foo<kotlin.CharSequence!>..test.RawTypeWithUpperBound.Foo<*>?)>!): kotlin.Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Foo</*0*/ T : kotlin.CharSequence!> {
|
public interface Foo</*0*/ T : kotlin.CharSequence!> {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
public interface RawUpperBound</*0*/ T : test.RawUpperBound<out kotlin.Any?>!> {
|
public interface RawUpperBound</*0*/ T : (test.RawUpperBound<test.RawUpperBound<*>>..test.RawUpperBound<out test.RawUpperBound<*>>?)> {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
public interface RecursiveRawUpperBound</*0*/ T : test.RecursiveRawUpperBound<out kotlin.Any?>!> {
|
public interface RecursiveRawUpperBound</*0*/ T : (test.RecursiveRawUpperBound<test.RecursiveRawUpperBound<*>>..test.RecursiveRawUpperBound<out test.RecursiveRawUpperBound<*>>?)> {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
public interface RecursiveWildcardUpperBound</*0*/ T : test.RecursiveWildcardUpperBound<out kotlin.Any?>!> {
|
public interface RecursiveWildcardUpperBound</*0*/ T : (test.RecursiveWildcardUpperBound<test.RecursiveWildcardUpperBound<*>>..test.RecursiveWildcardUpperBound<out test.RecursiveWildcardUpperBound<*>>?)> {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ public open class Rendering {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public/*package*/ interface H_Raw {
|
public/*package*/ interface H_Raw {
|
||||||
public abstract fun foo1(/*0*/ p0: kotlin.(Mutable)List<*>!): kotlin.Unit
|
public abstract fun foo1(/*0*/ p0: (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)): kotlin.Unit
|
||||||
public abstract fun foo2(/*0*/ p0: test.Rendering.D_SuperG<*>!): kotlin.Unit
|
public abstract fun foo2(/*0*/ p0: (test.Rendering.D_SuperG<kotlin.Any!>..test.Rendering.D_SuperG<*>?)): kotlin.Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
public/*package*/ interface I_Wildcard {
|
public/*package*/ interface I_Wildcard {
|
||||||
|
|||||||
Vendored
+2
-2
@@ -3,11 +3,11 @@ package test
|
|||||||
public open class RawSuperTypeWithRecursiveBound {
|
public open class RawSuperTypeWithRecursiveBound {
|
||||||
public constructor RawSuperTypeWithRecursiveBound()
|
public constructor RawSuperTypeWithRecursiveBound()
|
||||||
|
|
||||||
public open inner class Derived : test.RawSuperTypeWithRecursiveBound.Super<test.RawSuperTypeWithRecursiveBound.Super<*>!> {
|
public open inner class Derived : test.RawSuperTypeWithRecursiveBound.Super<out test.RawSuperTypeWithRecursiveBound.Super<*>!> {
|
||||||
public constructor Derived()
|
public constructor Derived()
|
||||||
public open override /*1*/ fun dummy(): kotlin.Unit
|
public open override /*1*/ fun dummy(): kotlin.Unit
|
||||||
|
public open override /*1*/ fun foo(/*0*/ p0: (test.RawSuperTypeWithRecursiveBound.Super<(test.RawSuperTypeWithRecursiveBound.Super<test.RawSuperTypeWithRecursiveBound.Super<*>!>..test.RawSuperTypeWithRecursiveBound.Super<out test.RawSuperTypeWithRecursiveBound.Super<*>!>?)>..test.RawSuperTypeWithRecursiveBound.Super<out (test.RawSuperTypeWithRecursiveBound.Super<test.RawSuperTypeWithRecursiveBound.Super<*>!>..test.RawSuperTypeWithRecursiveBound.Super<out test.RawSuperTypeWithRecursiveBound.Super<*>!>?)>?)): kotlin.Unit
|
||||||
public open fun foo(/*0*/ p0: kotlin.Any!): kotlin.Unit
|
public open fun foo(/*0*/ p0: kotlin.Any!): kotlin.Unit
|
||||||
public open override /*1*/ fun foo(/*0*/ p0: test.RawSuperTypeWithRecursiveBound.Super<*>!): kotlin.Unit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Super</*0*/ T : test.RawSuperTypeWithRecursiveBound.Super<T!>!> {
|
public interface Super</*0*/ T : test.RawSuperTypeWithRecursiveBound.Super<T!>!> {
|
||||||
|
|||||||
+2
-2
@@ -3,11 +3,11 @@ package test
|
|||||||
public open class RawSuperTypeWithRecursiveBoundMultipleParameters {
|
public open class RawSuperTypeWithRecursiveBoundMultipleParameters {
|
||||||
public constructor RawSuperTypeWithRecursiveBoundMultipleParameters()
|
public constructor RawSuperTypeWithRecursiveBoundMultipleParameters()
|
||||||
|
|
||||||
public open inner class Derived : test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<kotlin.Any!, test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, *>!> {
|
public open inner class Derived : test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<kotlin.Any!, out test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, *>!> {
|
||||||
public constructor Derived()
|
public constructor Derived()
|
||||||
public open override /*1*/ fun dummy(): kotlin.Unit
|
public open override /*1*/ fun dummy(): kotlin.Unit
|
||||||
|
public open override /*1*/ fun foo(/*0*/ p0: kotlin.Any!, /*1*/ p1: (test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<kotlin.Any!, (test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<kotlin.Any!, test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, *>!>..test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, out test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, *>!>?)>..test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, out (test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<kotlin.Any!, test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, *>!>..test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, out test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, *>!>?)>?)): kotlin.Unit
|
||||||
public open fun foo(/*0*/ p0: kotlin.Any!, /*1*/ p1: kotlin.Any!): kotlin.Unit
|
public open fun foo(/*0*/ p0: kotlin.Any!, /*1*/ p1: kotlin.Any!): kotlin.Unit
|
||||||
public open override /*1*/ fun foo(/*0*/ p0: kotlin.Any!, /*1*/ p1: test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, *>!): kotlin.Unit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Super</*0*/ R : kotlin.Any!, /*1*/ T : test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<R!, T!>!> {
|
public interface Super</*0*/ R : kotlin.Any!, /*1*/ T : test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<R!, T!>!> {
|
||||||
|
|||||||
+8
-8
@@ -4,22 +4,22 @@ public interface SubclassWithRawType {
|
|||||||
|
|
||||||
public interface Sub : test.SubclassWithRawType.Super {
|
public interface Sub : test.SubclassWithRawType.Super {
|
||||||
public abstract override /*1*/ fun array1(): kotlin.Array<(out) kotlin.(Mutable)List<kotlin.String!>!>!
|
public abstract override /*1*/ fun array1(): kotlin.Array<(out) kotlin.(Mutable)List<kotlin.String!>!>!
|
||||||
public abstract override /*1*/ fun array2(): kotlin.Array<(out) kotlin.(Mutable)List<*>!>!
|
public abstract override /*1*/ fun array2(): kotlin.Array<(out) (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)>!
|
||||||
public abstract override /*1*/ fun boundWildcard1(): (kotlin.MutableList<out kotlin.(Mutable)List<kotlin.String!>!>..kotlin.List<kotlin.(Mutable)List<kotlin.String!>!>?)
|
public abstract override /*1*/ fun boundWildcard1(): (kotlin.MutableList<out kotlin.(Mutable)List<kotlin.String!>!>..kotlin.List<kotlin.(Mutable)List<kotlin.String!>!>?)
|
||||||
public abstract override /*1*/ fun boundWildcard2(): kotlin.(Mutable)List<in (kotlin.MutableList<out kotlin.Any?>..kotlin.List<kotlin.Any?>?)>!
|
public abstract override /*1*/ fun boundWildcard2(): kotlin.(Mutable)List<in (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)>!
|
||||||
public abstract override /*1*/ fun simple1(): kotlin.(Mutable)List<kotlin.String!>!
|
public abstract override /*1*/ fun simple1(): kotlin.(Mutable)List<kotlin.String!>!
|
||||||
public abstract override /*1*/ fun simple2(): kotlin.(Mutable)List<kotlin.(Mutable)List<kotlin.String!>!>!
|
public abstract override /*1*/ fun simple2(): kotlin.(Mutable)List<kotlin.(Mutable)List<kotlin.String!>!>!
|
||||||
public abstract override /*1*/ fun simple3(): kotlin.(Mutable)List<*>!
|
public abstract override /*1*/ fun simple3(): (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)
|
||||||
public abstract override /*1*/ fun wildcard(): kotlin.(Mutable)List<*>!
|
public abstract override /*1*/ fun wildcard(): (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Super {
|
public interface Super {
|
||||||
public abstract fun array1(): kotlin.Array<(out) kotlin.(Mutable)List<*>!>!
|
public abstract fun array1(): kotlin.Array<(out) (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)>!
|
||||||
public abstract fun array2(): kotlin.Array<(out) kotlin.(Mutable)List<kotlin.String!>!>!
|
public abstract fun array2(): kotlin.Array<(out) kotlin.(Mutable)List<kotlin.String!>!>!
|
||||||
public abstract fun boundWildcard1(): (kotlin.MutableList<out (kotlin.MutableList<out kotlin.Any?>..kotlin.List<kotlin.Any?>?)>..kotlin.List<(kotlin.MutableList<out kotlin.Any?>..kotlin.List<kotlin.Any?>?)>?)
|
public abstract fun boundWildcard1(): (kotlin.MutableList<out (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)>..kotlin.List<(kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)>?)
|
||||||
public abstract fun boundWildcard2(): kotlin.(Mutable)List<in kotlin.(Mutable)List<kotlin.String!>!>!
|
public abstract fun boundWildcard2(): kotlin.(Mutable)List<in kotlin.(Mutable)List<kotlin.String!>!>!
|
||||||
public abstract fun simple1(): kotlin.(Mutable)List<*>!
|
public abstract fun simple1(): (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)
|
||||||
public abstract fun simple2(): kotlin.(Mutable)List<*>!
|
public abstract fun simple2(): (kotlin.MutableList<kotlin.Any?>..kotlin.List<*>?)
|
||||||
public abstract fun simple3(): kotlin.(Mutable)List<kotlin.String!>!
|
public abstract fun simple3(): kotlin.(Mutable)List<kotlin.String!>!
|
||||||
public abstract fun wildcard(): kotlin.(Mutable)List<*>!
|
public abstract fun wildcard(): kotlin.(Mutable)List<*>!
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
public interface WrongNumberOfGenericParameters {
|
public interface WrongNumberOfGenericParameters {
|
||||||
public abstract fun o0(): test.WrongNumberOfGenericParameters.One<*>!
|
public abstract fun o0(): (test.WrongNumberOfGenericParameters.One<kotlin.Any!>..test.WrongNumberOfGenericParameters.One<*>?)
|
||||||
public abstract fun o2(): test.WrongNumberOfGenericParameters.One<[ERROR : T]>!
|
public abstract fun o2(): test.WrongNumberOfGenericParameters.One<[ERROR : T]>!
|
||||||
public abstract fun t1(): test.WrongNumberOfGenericParameters.Two<*, *>!
|
public abstract fun t1(): (test.WrongNumberOfGenericParameters.Two<kotlin.Any!, kotlin.Any!>..test.WrongNumberOfGenericParameters.Two<*, *>?)
|
||||||
public abstract fun z(): test.WrongNumberOfGenericParameters.Zero!
|
public abstract fun z(): test.WrongNumberOfGenericParameters.Zero!
|
||||||
|
|
||||||
public interface One</*0*/ T : kotlin.Any!> {
|
public interface One</*0*/ T : kotlin.Any!> {
|
||||||
|
|||||||
@@ -10566,6 +10566,93 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/diagnostics/tests/platformTypes/rawTypes")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class RawTypes extends AbstractJetDiagnosticsTest {
|
||||||
|
public void testAllFilesPresentInRawTypes() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/platformTypes/rawTypes"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("arrays.kt")
|
||||||
|
public void testArrays() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/rawTypes/arrays.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericInnerClass.kt")
|
||||||
|
public void testGenericInnerClass() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/rawTypes/genericInnerClass.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nonGenericRawMember.kt")
|
||||||
|
public void testNonGenericRawMember() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/rawTypes/nonGenericRawMember.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nonTrivialErasure.kt")
|
||||||
|
public void testNonTrivialErasure() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/rawTypes/nonTrivialErasure.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("rawSupertype.kt")
|
||||||
|
public void testRawSupertype() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/rawTypes/rawSupertype.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("rawSupertypeOverride.kt")
|
||||||
|
public void testRawSupertypeOverride() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/rawTypes/rawSupertypeOverride.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("rawTypeInUpperBound.kt")
|
||||||
|
public void testRawTypeInUpperBound() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/rawTypes/rawTypeInUpperBound.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("rawWithInProjection.kt")
|
||||||
|
public void testRawWithInProjection() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/rawTypes/rawWithInProjection.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("recursiveBound.kt")
|
||||||
|
public void testRecursiveBound() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/rawTypes/recursiveBound.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("samRaw.kt")
|
||||||
|
public void testSamRaw() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/rawTypes/samRaw.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simple.kt")
|
||||||
|
public void testSimple() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/rawTypes/simple.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("starProjectionToRaw.kt")
|
||||||
|
public void testStarProjectionToRaw() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/rawTypes/starProjectionToRaw.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("typeEnhancement.kt")
|
||||||
|
public void testTypeEnhancement() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/rawTypes/typeEnhancement.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement")
|
@TestMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ class LazyJavaTypeParameterDescriptor(
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return bounds.map {
|
return bounds.map {
|
||||||
javaType -> c.typeResolver.transformJavaType(javaType, TypeUsage.UPPER_BOUND.toAttributes())
|
javaType -> c.typeResolver.transformJavaType(javaType, TypeUsage.UPPER_BOUND.toAttributes(upperBoundForTypeParameter = this))
|
||||||
}.toSet()
|
}.toSet()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+174
-25
@@ -98,16 +98,6 @@ class LazyJavaTypeResolver(
|
|||||||
}.replaceAnnotations(attr.typeAnnotations)
|
}.replaceAnnotations(attr.typeAnnotations)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun makeStarProjection(
|
|
||||||
typeParameter: TypeParameterDescriptor,
|
|
||||||
attr: JavaTypeAttributes
|
|
||||||
): TypeProjection {
|
|
||||||
return if (attr.howThisTypeIsUsed == SUPERTYPE)
|
|
||||||
TypeProjectionImpl(typeParameter.starProjectionType())
|
|
||||||
else
|
|
||||||
StarProjectionImpl(typeParameter)
|
|
||||||
}
|
|
||||||
|
|
||||||
private inner class LazyJavaClassifierType(
|
private inner class LazyJavaClassifierType(
|
||||||
private val javaType: JavaClassifierType,
|
private val javaType: JavaClassifierType,
|
||||||
private val attr: JavaTypeAttributes
|
private val attr: JavaTypeAttributes
|
||||||
@@ -207,19 +197,24 @@ class LazyJavaTypeResolver(
|
|||||||
if (isRaw()) {
|
if (isRaw()) {
|
||||||
return typeParameters.map {
|
return typeParameters.map {
|
||||||
parameter ->
|
parameter ->
|
||||||
|
// Some activity for preventing recursion in cases like `class A<T extends A, F extends T>`
|
||||||
|
//
|
||||||
|
// When calculating upper bound of some parameter (attr.upperBoundOfTypeParameter),
|
||||||
|
// do not try to start upper bound calculation of it again.
|
||||||
|
// If we met such recursive dependency it means that upper bound of `attr.upperBoundOfTypeParameter` based effectively
|
||||||
|
// on the current class, so we can manually erase default type of current constructor.
|
||||||
|
//
|
||||||
|
// In example above corner cases are:
|
||||||
|
// - Calculating first argument for raw upper bound of T. It depends on T, so we just get A<*, *>
|
||||||
|
// - Calculating second argument for raw upper bound of T. It depends on F, that again depends on upper bound of T,
|
||||||
|
// so we get A<*, *>.
|
||||||
|
// Summary result for upper bound of T is `A<A<*, *>, A<*, *>>..A<out A<*, *>, out A<*, *>>`
|
||||||
|
val erasedUpperBound =
|
||||||
|
parameter.getErasedUpperBound(attr.upperBoundOfTypeParameter) {
|
||||||
|
constructor.declarationDescriptor!!.defaultType.replaceArgumentsWithStarProjections()
|
||||||
|
}
|
||||||
|
|
||||||
if (attr.howThisTypeIsUsed == UPPER_BOUND) {
|
RawSubstitution.computeProjection(parameter, attr, erasedUpperBound)
|
||||||
// not making a star projection because of this case:
|
|
||||||
// Java:
|
|
||||||
// class C<T extends C> {}
|
|
||||||
// The upper bound is raw here, and we can't compute the projection: it would be infinite:
|
|
||||||
// C<*> = C<out C<out C<...>>>
|
|
||||||
// this way we lose some type information, even when the case is not so bad, but it doesn't seem to matter
|
|
||||||
val projectionKind = if (parameter.getVariance() == OUT_VARIANCE) INVARIANT else OUT_VARIANCE
|
|
||||||
TypeProjectionImpl(projectionKind, c.module.builtIns.getNullableAnyType())
|
|
||||||
}
|
|
||||||
else
|
|
||||||
makeStarProjection(parameter, attr)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isConstructorTypeParameter()) {
|
if (isConstructorTypeParameter()) {
|
||||||
@@ -268,10 +263,86 @@ class LazyJavaTypeResolver(
|
|||||||
|
|
||||||
if (descriptor is TypeParameterDescriptor) return descriptor.getDefaultType().getMemberScope()
|
if (descriptor is TypeParameterDescriptor) return descriptor.getDefaultType().getMemberScope()
|
||||||
|
|
||||||
return (descriptor as ClassDescriptor).getMemberScope(getArguments())
|
return (descriptor as ClassDescriptor).getMemberScope(substitution)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun computeCustomSubstitution(): TypeSubstitution? = null
|
override fun computeCustomSubstitution() = if (isRaw()) RawSubstitution else null
|
||||||
|
|
||||||
|
private object RawSubstitution : TypeSubstitution() {
|
||||||
|
override fun get(key: JetType) = TypeProjectionImpl(eraseType(key))
|
||||||
|
|
||||||
|
private val lowerTypeAttr = MEMBER_SIGNATURE_INVARIANT.toAttributes().toFlexible(FLEXIBLE_LOWER_BOUND)
|
||||||
|
private val upperTypeAttr = MEMBER_SIGNATURE_INVARIANT.toAttributes().toFlexible(FLEXIBLE_UPPER_BOUND)
|
||||||
|
|
||||||
|
private fun eraseType(type: JetType): JetType {
|
||||||
|
val declaration = type.constructor.declarationDescriptor
|
||||||
|
return when (declaration) {
|
||||||
|
is TypeParameterDescriptor -> eraseType(declaration.getErasedUpperBound())
|
||||||
|
is ClassDescriptor -> {
|
||||||
|
val lower = type.lowerIfFlexible()
|
||||||
|
val upper = type.upperIfFlexible()
|
||||||
|
FlexibleJavaClassifierTypeCapabilities.create(
|
||||||
|
eraseInflexibleBasedOnClassDescriptor(lower, declaration, lowerTypeAttr),
|
||||||
|
eraseInflexibleBasedOnClassDescriptor(upper, declaration, upperTypeAttr)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else -> error("Unexpected declaration kind: $declaration")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun eraseInflexibleBasedOnClassDescriptor(type: JetType, declaration: ClassDescriptor, attr: JavaTypeAttributes): JetType {
|
||||||
|
if (KotlinBuiltIns.isArray(type)) {
|
||||||
|
val componentTypeProjection = type.arguments[0]
|
||||||
|
val arguments = listOf(
|
||||||
|
TypeProjectionImpl(componentTypeProjection.projectionKind, eraseType(componentTypeProjection.type))
|
||||||
|
)
|
||||||
|
return JetTypeImpl(
|
||||||
|
type.annotations, type.constructor, type.isMarkedNullable, arguments,
|
||||||
|
(type.constructor.declarationDescriptor as ClassDescriptor).getMemberScope(arguments)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val constructor = type.constructor
|
||||||
|
return JetTypeImpl(
|
||||||
|
type.annotations, constructor, type.isMarkedNullable,
|
||||||
|
type.constructor.parameters.map {
|
||||||
|
parameter -> computeProjection(parameter, attr)
|
||||||
|
},
|
||||||
|
RawSubstitution,
|
||||||
|
declaration.getMemberScope(RawSubstitution)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun computeProjection(
|
||||||
|
parameter: TypeParameterDescriptor,
|
||||||
|
attr: JavaTypeAttributes,
|
||||||
|
erasedUpperBound: JetType = parameter.getErasedUpperBound()
|
||||||
|
) = when (attr.flexibility) {
|
||||||
|
// Raw(List<T>) => (List<Any?>..List<*>)
|
||||||
|
// Raw(Enum<T>) => (Enum<Enum<*>>..Enum<out Enum<*>>)
|
||||||
|
// In the last case upper bound is equal to star projection `Enum<*>`,
|
||||||
|
// but we want to keep matching tree structure of flexible bounds (at least they should have the same size)
|
||||||
|
FLEXIBLE_LOWER_BOUND -> TypeProjectionImpl(
|
||||||
|
// T : String -> String
|
||||||
|
// in T : String -> String
|
||||||
|
// T : Enum<T> -> Enum<*>
|
||||||
|
Variance.INVARIANT, erasedUpperBound
|
||||||
|
)
|
||||||
|
FLEXIBLE_UPPER_BOUND, INFLEXIBLE -> {
|
||||||
|
if (!parameter.variance.allowsOutPosition)
|
||||||
|
// in T -> Comparable<Nothing>
|
||||||
|
TypeProjectionImpl(Variance.INVARIANT, parameter.lowerBounds.first())
|
||||||
|
else if (erasedUpperBound.constructor.parameters.isNotEmpty())
|
||||||
|
// T : Enum<E> -> out Enum<*>
|
||||||
|
TypeProjectionImpl(Variance.OUT_VARIANCE, erasedUpperBound)
|
||||||
|
else
|
||||||
|
// T : String -> *
|
||||||
|
makeStarProjection(parameter, attr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isEmpty() = false
|
||||||
|
}
|
||||||
|
|
||||||
private val nullable = c.storageManager.createLazyValue l@ {
|
private val nullable = c.storageManager.createLazyValue l@ {
|
||||||
when (attr.flexibility) {
|
when (attr.flexibility) {
|
||||||
@@ -349,6 +420,16 @@ class LazyJavaTypeResolver(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun makeStarProjection(
|
||||||
|
typeParameter: TypeParameterDescriptor,
|
||||||
|
attr: JavaTypeAttributes
|
||||||
|
): TypeProjection {
|
||||||
|
return if (attr.howThisTypeIsUsed == SUPERTYPE)
|
||||||
|
TypeProjectionImpl(typeParameter.starProjectionType())
|
||||||
|
else
|
||||||
|
StarProjectionImpl(typeParameter)
|
||||||
|
}
|
||||||
|
|
||||||
interface JavaTypeAttributes {
|
interface JavaTypeAttributes {
|
||||||
val howThisTypeIsUsed: TypeUsage
|
val howThisTypeIsUsed: TypeUsage
|
||||||
val howThisTypeIsUsedAccordingToAnnotations: TypeUsage
|
val howThisTypeIsUsedAccordingToAnnotations: TypeUsage
|
||||||
@@ -360,6 +441,9 @@ interface JavaTypeAttributes {
|
|||||||
val typeAnnotations: Annotations
|
val typeAnnotations: Annotations
|
||||||
val isForAnnotationParameter: Boolean
|
val isForAnnotationParameter: Boolean
|
||||||
get() = false
|
get() = false
|
||||||
|
// Current type is upper bound of this type parameter
|
||||||
|
val upperBoundOfTypeParameter: TypeParameterDescriptor?
|
||||||
|
get() = null
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class JavaTypeFlexibility {
|
enum class JavaTypeFlexibility {
|
||||||
@@ -390,7 +474,11 @@ class LazyJavaTypeAttributes(
|
|||||||
internal fun Annotations.isMarkedNotNull() = findAnnotation(JETBRAINS_NOT_NULL_ANNOTATION) != null
|
internal fun Annotations.isMarkedNotNull() = findAnnotation(JETBRAINS_NOT_NULL_ANNOTATION) != null
|
||||||
internal fun Annotations.isMarkedNullable() = findAnnotation(JETBRAINS_NULLABLE_ANNOTATION) != null
|
internal fun Annotations.isMarkedNullable() = findAnnotation(JETBRAINS_NULLABLE_ANNOTATION) != null
|
||||||
|
|
||||||
fun TypeUsage.toAttributes(allowFlexible: Boolean = true, isForAnnotationParameter: Boolean = false) = object : JavaTypeAttributes {
|
fun TypeUsage.toAttributes(
|
||||||
|
allowFlexible: Boolean = true,
|
||||||
|
isForAnnotationParameter: Boolean = false,
|
||||||
|
upperBoundForTypeParameter: TypeParameterDescriptor? = null
|
||||||
|
) = object : JavaTypeAttributes {
|
||||||
override val howThisTypeIsUsed: TypeUsage = this@toAttributes
|
override val howThisTypeIsUsed: TypeUsage = this@toAttributes
|
||||||
override val howThisTypeIsUsedAccordingToAnnotations: TypeUsage
|
override val howThisTypeIsUsedAccordingToAnnotations: TypeUsage
|
||||||
get() = howThisTypeIsUsed
|
get() = howThisTypeIsUsed
|
||||||
@@ -400,9 +488,70 @@ fun TypeUsage.toAttributes(allowFlexible: Boolean = true, isForAnnotationParamet
|
|||||||
override val typeAnnotations: Annotations = Annotations.EMPTY
|
override val typeAnnotations: Annotations = Annotations.EMPTY
|
||||||
|
|
||||||
override val isForAnnotationParameter: Boolean = isForAnnotationParameter
|
override val isForAnnotationParameter: Boolean = isForAnnotationParameter
|
||||||
|
override val upperBoundOfTypeParameter: TypeParameterDescriptor? = upperBoundForTypeParameter
|
||||||
}
|
}
|
||||||
|
|
||||||
fun JavaTypeAttributes.toFlexible(flexibility: JavaTypeFlexibility) =
|
fun JavaTypeAttributes.toFlexible(flexibility: JavaTypeFlexibility) =
|
||||||
object : JavaTypeAttributes by this {
|
object : JavaTypeAttributes by this {
|
||||||
override val flexibility = flexibility
|
override val flexibility = flexibility
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Definition:
|
||||||
|
// ErasedUpperBound(T : G<t>) = G<*> // UpperBound(T) is a type G<t> with arguments
|
||||||
|
// ErasedUpperBound(T : A) = A // UpperBound(T) is a type A without arguments
|
||||||
|
// ErasedUpperBound(T : F) = UpperBound(F) // UB(T) is another type parameter F
|
||||||
|
private fun TypeParameterDescriptor.getErasedUpperBound(
|
||||||
|
// Calculation of `potentiallyRecursiveTypeParameter.upperBounds` may recursively depend on `this.getErasedUpperBound`
|
||||||
|
// E.g. `class A<T extends A, F extends A>`
|
||||||
|
// To prevent recursive calls return defaultValue() instead
|
||||||
|
potentiallyRecursiveTypeParameter: TypeParameterDescriptor? = null,
|
||||||
|
defaultValue: (() -> JetType) = { ErrorUtils.createErrorType("Can't compute erased upper bound of type parameter `$this`") }
|
||||||
|
): JetType {
|
||||||
|
if (this === potentiallyRecursiveTypeParameter) return defaultValue()
|
||||||
|
|
||||||
|
val firstUpperBound = upperBounds.first()
|
||||||
|
|
||||||
|
if (firstUpperBound.constructor.declarationDescriptor is ClassDescriptor) {
|
||||||
|
return firstUpperBound.replaceArgumentsWithStarProjections()
|
||||||
|
}
|
||||||
|
|
||||||
|
val stopAt = potentiallyRecursiveTypeParameter ?: this
|
||||||
|
var current = firstUpperBound.constructor.declarationDescriptor as TypeParameterDescriptor
|
||||||
|
|
||||||
|
while (current != stopAt) {
|
||||||
|
val nextUpperBound = current.upperBounds.first()
|
||||||
|
if (nextUpperBound.constructor.declarationDescriptor is ClassDescriptor) {
|
||||||
|
return nextUpperBound.replaceArgumentsWithStarProjections()
|
||||||
|
}
|
||||||
|
|
||||||
|
current = nextUpperBound.constructor.declarationDescriptor as TypeParameterDescriptor
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultValue()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun JetType.replaceArgumentsWithStarProjections(): JetType {
|
||||||
|
if (constructor.parameters.isEmpty() || constructor.declarationDescriptor == null) return this
|
||||||
|
|
||||||
|
// We could just create JetTypeImpl with current type constructor and star projections,
|
||||||
|
// but we want to preserve flexibility of type, and that it what TypeSubstitutor does
|
||||||
|
return TypeSubstitutor.create(ConstantStarSubstitution).substitute(this, Variance.INVARIANT)!!
|
||||||
|
}
|
||||||
|
|
||||||
|
private object ConstantStarSubstitution : TypeSubstitution() {
|
||||||
|
override fun get(key: JetType): TypeProjection? {
|
||||||
|
// Let substitutor deal with flexibility
|
||||||
|
if (key.isFlexible()) return null
|
||||||
|
|
||||||
|
val newProjections = key.constructor.parameters.map(::StarProjectionImpl)
|
||||||
|
|
||||||
|
val substitution = IndexedParametersSubstitution(key.constructor, newProjections)
|
||||||
|
|
||||||
|
return TypeProjectionImpl(
|
||||||
|
TypeSubstitutor.create(substitution).substitute(key.constructor.declarationDescriptor!!.defaultType, Variance.INVARIANT)!!
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isEmpty() = false
|
||||||
|
}
|
||||||
|
|||||||
+7
-2
@@ -98,13 +98,18 @@ private fun JetType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, i
|
|||||||
enhancedNullabilityAnnotations
|
enhancedNullabilityAnnotations
|
||||||
).filterNotNull().compositeAnnotationsOrSingle()
|
).filterNotNull().compositeAnnotationsOrSingle()
|
||||||
|
|
||||||
|
val (newSubstitution, substitutedEnhancedArgs) = computeNewSubstitutionAndArguments(
|
||||||
|
enhancedClassifier.typeConstructor.parameters, enhancedArguments
|
||||||
|
)
|
||||||
|
|
||||||
val enhancedType = JetTypeImpl(
|
val enhancedType = JetTypeImpl(
|
||||||
newAnnotations,
|
newAnnotations,
|
||||||
enhancedClassifier.getTypeConstructor(),
|
enhancedClassifier.getTypeConstructor(),
|
||||||
enhancedNullability,
|
enhancedNullability,
|
||||||
enhancedArguments,
|
substitutedEnhancedArgs,
|
||||||
|
newSubstitution,
|
||||||
if (enhancedClassifier is ClassDescriptor)
|
if (enhancedClassifier is ClassDescriptor)
|
||||||
enhancedClassifier.getMemberScope(enhancedArguments)
|
enhancedClassifier.getMemberScope(newSubstitution)
|
||||||
else enhancedClassifier.getDefaultType().getMemberScope()
|
else enhancedClassifier.getDefaultType().getMemberScope()
|
||||||
)
|
)
|
||||||
return Result(enhancedType, globalArgIndex - index)
|
return Result(enhancedType, globalArgIndex - index)
|
||||||
|
|||||||
@@ -90,3 +90,39 @@ public class IndexedParametersSubstitution(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public fun JetType.computeNewSubstitutionAndArguments(
|
||||||
|
newParameters: List<TypeParameterDescriptor>,
|
||||||
|
newArguments: List<TypeProjection>
|
||||||
|
): Pair<TypeSubstitution, List<TypeProjection>> {
|
||||||
|
val previousSubstitution = getSubstitution()
|
||||||
|
if (newArguments.isEmpty()) return Pair(previousSubstitution, emptyList())
|
||||||
|
|
||||||
|
val newIndexedSubstitution = IndexedParametersSubstitution(newParameters, newArguments)
|
||||||
|
|
||||||
|
// If previous substitution was trivial just replace it with indexed one
|
||||||
|
if (previousSubstitution is IndexedParametersSubstitution || previousSubstitution.isEmpty()) {
|
||||||
|
return Pair(newIndexedSubstitution, newArguments)
|
||||||
|
}
|
||||||
|
|
||||||
|
val composedSubstitution = CompositeTypeSubstitution(newIndexedSubstitution, previousSubstitution)
|
||||||
|
val newSubstitutor = composedSubstitution.buildSubstitutor()
|
||||||
|
val resultArguments = newParameters.map { newSubstitutor.substitute(TypeProjectionImpl(it.variance, it.defaultType))!! }
|
||||||
|
|
||||||
|
return Pair(composedSubstitution, resultArguments)
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CompositeTypeSubstitution(
|
||||||
|
private val first: TypeSubstitution,
|
||||||
|
private val second: TypeSubstitution
|
||||||
|
) : TypeSubstitution() {
|
||||||
|
|
||||||
|
override fun get(key: JetType): TypeProjection? {
|
||||||
|
val firstResult = first[key] ?: return second[key]
|
||||||
|
return second.buildSubstitutor().substitute(firstResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isEmpty() = first.isEmpty() && second.isEmpty()
|
||||||
|
//
|
||||||
|
override fun approximateCapturedTypes() = first.approximateCapturedTypes() || second.approximateCapturedTypes()
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.SubstitutingScope
|
||||||
import org.jetbrains.kotlin.types.*
|
import org.jetbrains.kotlin.types.*
|
||||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||||
@@ -134,3 +135,4 @@ fun JetType.containsError() = ErrorUtils.containsErrorType(this)
|
|||||||
public fun List<JetType>.defaultProjections(): List<TypeProjection> = map { TypeProjectionImpl(it) }
|
public fun List<JetType>.defaultProjections(): List<TypeProjection> = map { TypeProjectionImpl(it) }
|
||||||
|
|
||||||
public fun JetType.isDefaultBound(): Boolean = KotlinBuiltIns.isDefaultBound(getSupertypeRepresentative())
|
public fun JetType.isDefaultBound(): Boolean = KotlinBuiltIns.isDefaultBound(getSupertypeRepresentative())
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,4 +2,4 @@ fun testing() {
|
|||||||
<caret>SomeClass<List<String>>()
|
<caret>SomeClass<List<String>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
// INFO: <b>public</b> <b>constructor</b> SomeClass<T : (MutableList<out Any?>..List<Any?>?)>()<br/>Java declaration:<br/>[light_idea_test_case] public class SomeClass<T extends java.util.List> extends Object
|
// INFO: <b>public</b> <b>constructor</b> SomeClass<T : (MutableList<Any?>..List<*>?)>()<br/>Java declaration:<br/>[light_idea_test_case] public class SomeClass<T extends java.util.List> extends Object
|
||||||
@@ -65,6 +65,49 @@ k(Foo<Bar>) = Foo<Bar!>!
|
|||||||
k(int[]) = IntArray
|
k(int[]) = IntArray
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Raw types
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
where `G<T1>..F<T2>` is initially loaded flexible type with yet unsubstituted type parameters.
|
||||||
|
|
||||||
|
`ErasedUpperBound` defined as follows:
|
||||||
|
|
||||||
|
```
|
||||||
|
ErasedUpperBound(T : G<t>) = G<*> // UB(T) is a type G<t> with arguments
|
||||||
|
ErasedUpperBound(T : A) = A // UB(T) is a type A without arguments
|
||||||
|
ErasedUpperBound(T : F) = ErasedUpperBound(F) // UB(T) is another type parameter F
|
||||||
|
```
|
||||||
|
and `UB(T)` means first upper bound with notation `T : UB(T)`.
|
||||||
|
|
||||||
|
NOTE: On Java code with errors later definition may recursively depend on the same type parameter,
|
||||||
|
that should be handled properly, e.g. by loading such ErasedUpperBound as Error type
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
```
|
||||||
|
Raw(java.util.concurrent.Future) = (Future<Any!>..Future<out Any!>?)
|
||||||
|
Raw(java.util.Collection) = (MutableCollection<Any?>..Collection<out Any?>?)
|
||||||
|
|
||||||
|
class A<T extends CharSequence> {}
|
||||||
|
Raw(A) = (A<CharSequence!>..A<out CharSequence>)
|
||||||
|
|
||||||
|
Raw(java.lang.Enum) = (Enum<Enum<*>>..Enum<out 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
|
||||||
|
```
|
||||||
|
|
||||||
## Overriding
|
## Overriding
|
||||||
|
|
||||||
When overriding a method from a Java class, one can not use flexible type, only replace them with denotable Kotlin types:
|
When overriding a method from a Java class, one can not use flexible type, only replace them with denotable Kotlin types:
|
||||||
|
|||||||
Reference in New Issue
Block a user