Update typing rules for class literal expressions.
C::class : KClass<C> expr: T => expr::class : KClass<out T> NB: this means Obj::class : KClass<out Obj> for object Obj.
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
abstract class Base<T : Any>(val klass: KClass<out T>)
|
||||
|
||||
class DerivedClass : Base<DerivedClass>(DerivedClass::class)
|
||||
|
||||
object DerivedObject : Base<DerivedObject>(DerivedObject::class)
|
||||
|
||||
enum class TestEnum {
|
||||
TEST_ENTRY
|
||||
}
|
||||
|
||||
val test1: KClass<DerivedClass> = DerivedClass::class
|
||||
val test2: KClass<DerivedObject> = DerivedObject::class
|
||||
val test3: KClass<TestEnum> = TestEnum::class
|
||||
val test4: KClass<out TestEnum> = TestEnum.TEST_ENTRY::class
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package
|
||||
|
||||
public val test1: kotlin.reflect.KClass<DerivedClass>
|
||||
public val test2: kotlin.reflect.KClass<DerivedObject>
|
||||
public val test3: kotlin.reflect.KClass<TestEnum>
|
||||
public val test4: kotlin.reflect.KClass<out TestEnum>
|
||||
|
||||
public abstract class Base</*0*/ T : kotlin.Any> {
|
||||
public constructor Base</*0*/ T : kotlin.Any>(/*0*/ klass: kotlin.reflect.KClass<out T>)
|
||||
public final val klass: kotlin.reflect.KClass<out 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 final class DerivedClass : Base<DerivedClass> {
|
||||
public constructor DerivedClass()
|
||||
public final override /*1*/ /*fake_override*/ val klass: kotlin.reflect.KClass<out DerivedClass>
|
||||
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 object DerivedObject : Base<DerivedObject> {
|
||||
private constructor DerivedObject()
|
||||
public final override /*1*/ /*fake_override*/ val klass: kotlin.reflect.KClass<out DerivedObject>
|
||||
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 final enum class TestEnum : kotlin.Enum<TestEnum> {
|
||||
enum entry TEST_ENTRY
|
||||
|
||||
private constructor TestEnum()
|
||||
public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: TestEnum): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<TestEnum!>!
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): TestEnum
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<TestEnum>
|
||||
}
|
||||
@@ -3,7 +3,13 @@ import kotlin.reflect.KClass
|
||||
class A
|
||||
class B
|
||||
|
||||
val listOfString: List<String> = null!!
|
||||
val arrayOfString: Array<String> = null!!
|
||||
|
||||
val a1 : KClass<*> = A::class
|
||||
val a2 : KClass<A> = A::class
|
||||
val a3 : KClass<B> = <!TYPE_MISMATCH!>A::class<!>
|
||||
val a4 : B = <!TYPE_MISMATCH!>A::class<!>
|
||||
|
||||
val a5 : KClass<out List<String>> = listOfString::class
|
||||
val a6 : KClass<out Array<String>> = arrayOfString::class
|
||||
|
||||
@@ -4,6 +4,10 @@ public val a1: kotlin.reflect.KClass<*>
|
||||
public val a2: kotlin.reflect.KClass<A>
|
||||
public val a3: kotlin.reflect.KClass<B>
|
||||
public val a4: B
|
||||
public val a5: kotlin.reflect.KClass<out kotlin.collections.List<kotlin.String>>
|
||||
public val a6: kotlin.reflect.KClass<out kotlin.Array<kotlin.String>>
|
||||
public val arrayOfString: kotlin.Array<kotlin.String>
|
||||
public val listOfString: kotlin.collections.List<kotlin.String>
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
fun f(<!UNUSED_PARAMETER!>x<!>: KClass<Int>) {}
|
||||
fun f(<!UNUSED_PARAMETER!>x<!>: KClass<out Int>) {}
|
||||
|
||||
fun test() {
|
||||
f(42::class)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package
|
||||
|
||||
public fun f(/*0*/ x: kotlin.reflect.KClass<kotlin.Int>): kotlin.Unit
|
||||
public fun f(/*0*/ x: kotlin.reflect.KClass<out kotlin.Int>): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
Reference in New Issue
Block a user