Simplify property hierarchy in reflection

Leave only 3*2 = 6 classes: KProperty0, KProperty1, KProperty2 and their
mutable analogs, depending on the number of receivers a property takes
This commit is contained in:
Alexander Udalov
2015-06-26 16:40:39 +03:00
parent c3b97e0668
commit 30794060a9
58 changed files with 374 additions and 653 deletions
@@ -2796,14 +2796,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
if (receiverParameter != null) {
Type[] parameterTypes = new Type[] {JAVA_STRING_TYPE, K_PACKAGE_TYPE, getType(Class.class)};
factoryMethod = descriptor.isVar()
? method("mutableTopLevelExtensionProperty", K_MUTABLE_TOP_LEVEL_EXTENSION_PROPERTY_TYPE, parameterTypes)
: method("topLevelExtensionProperty", K_TOP_LEVEL_EXTENSION_PROPERTY_TYPE, parameterTypes);
? method("mutableTopLevelExtensionProperty", K_MUTABLE_PROPERTY1_TYPE, parameterTypes)
: method("topLevelExtensionProperty", K_PROPERTY1_TYPE, parameterTypes);
}
else {
Type[] parameterTypes = new Type[] {JAVA_STRING_TYPE, K_PACKAGE_TYPE};
factoryMethod = descriptor.isVar()
? method("mutableTopLevelVariable", K_MUTABLE_TOP_LEVEL_VARIABLE_TYPE, parameterTypes)
: method("topLevelVariable", K_TOP_LEVEL_VARIABLE_TYPE, parameterTypes);
? method("mutableTopLevelVariable", K_MUTABLE_PROPERTY0_TYPE, parameterTypes)
: method("topLevelVariable", K_PROPERTY0_TYPE, parameterTypes);
}
return StackValue.operation(factoryMethod.getReturnType(), new Function1<InstructionAdapter, Unit>() {
@@ -2828,8 +2828,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@NotNull final ClassDescriptor containingClass
) {
final Method factoryMethod = descriptor.isVar()
? method("mutableMemberProperty", K_MUTABLE_MEMBER_PROPERTY_TYPE, JAVA_STRING_TYPE, K_CLASS_TYPE)
: method("memberProperty", K_MEMBER_PROPERTY_TYPE, JAVA_STRING_TYPE, K_CLASS_TYPE);
? method("mutableMemberProperty", K_MUTABLE_PROPERTY1_TYPE, JAVA_STRING_TYPE, K_CLASS_TYPE)
: method("memberProperty", K_PROPERTY1_TYPE, JAVA_STRING_TYPE, K_CLASS_TYPE);
return StackValue.operation(factoryMethod.getReturnType(), new Function1<InstructionAdapter, Unit>() {
@Override
@@ -44,12 +44,10 @@ public class AsmTypes {
public static final Type K_FUNCTION = reflect("KFunction");
public static final Type K_MEMBER_PROPERTY_TYPE = reflect("KMemberProperty");
public static final Type K_MUTABLE_MEMBER_PROPERTY_TYPE = reflect("KMutableMemberProperty");
public static final Type K_TOP_LEVEL_VARIABLE_TYPE = reflect("KTopLevelVariable");
public static final Type K_MUTABLE_TOP_LEVEL_VARIABLE_TYPE = reflect("KMutableTopLevelVariable");
public static final Type K_TOP_LEVEL_EXTENSION_PROPERTY_TYPE = reflect("KTopLevelExtensionProperty");
public static final Type K_MUTABLE_TOP_LEVEL_EXTENSION_PROPERTY_TYPE = reflect("KMutableTopLevelExtensionProperty");
public static final Type K_PROPERTY0_TYPE = reflect("KProperty0");
public static final Type K_PROPERTY1_TYPE = reflect("KProperty1");
public static final Type K_MUTABLE_PROPERTY0_TYPE = reflect("KMutableProperty0");
public static final Type K_MUTABLE_PROPERTY1_TYPE = reflect("KMutableProperty1");
public static final String REFLECTION = "kotlin/jvm/internal/Reflection";
@@ -694,20 +694,15 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
return null;
}
JetType receiverType = null;
if (extensionReceiver != null) {
receiverType = extensionReceiver.getType();
}
else if (dispatchReceiver != null) {
receiverType = dispatchReceiver.getType();
}
boolean isExtension = extensionReceiver != null;
JetType receiverType = extensionReceiver != null ? extensionReceiver.getType() :
dispatchReceiver != null ? dispatchReceiver.getType() :
null;
if (descriptor instanceof FunctionDescriptor) {
return createFunctionReferenceType(expression, context, (FunctionDescriptor) descriptor, receiverType);
}
else if (descriptor instanceof PropertyDescriptor) {
return createPropertyReferenceType(expression, context, (PropertyDescriptor) descriptor, receiverType, isExtension);
return createPropertyReferenceType(expression, context, (PropertyDescriptor) descriptor, receiverType);
}
else if (descriptor instanceof VariableDescriptor) {
context.trace.report(UNSUPPORTED.on(reference, "References to variables aren't supported yet"));
@@ -751,11 +746,11 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
@NotNull JetCallableReferenceExpression expression,
@NotNull ExpressionTypingContext context,
@NotNull PropertyDescriptor descriptor,
@Nullable JetType receiverType,
boolean isExtension
@Nullable JetType receiverType
) {
JetType type = components.reflectionTypes.getKPropertyType(Annotations.EMPTY, receiverType, descriptor.getType(), isExtension,
descriptor.isVar());
JetType type = components.reflectionTypes.getKPropertyType(
Annotations.EMPTY, receiverType, descriptor.getType(), descriptor.isVar()
);
LocalVariableDescriptor localVariable =
new LocalVariableDescriptor(context.scope.getContainingDeclaration(), Annotations.EMPTY, Name.special("<anonymous>"),
@@ -10,8 +10,8 @@ fun box(): String {
val s = J::s
// Check that correct reflection objects are created
assert(i.javaClass.getSimpleName() == "KMemberPropertyImpl", "Fail i class")
assert(s.javaClass.getSimpleName() == "KMutableMemberPropertyImpl", "Fail s class")
assert(i.javaClass.getSimpleName() == "KProperty1Impl", "Fail i class")
assert(s.javaClass.getSimpleName() == "KMutableProperty1Impl", "Fail s class")
// Check that no Method objects are created for such properties
assert(i.javaGetter == null, "Fail i getter")
@@ -33,8 +33,8 @@ fun box(): String {
assert(a.s == "def", "Fail js access")
// Check that valid Kotlin reflection objects are created by those Field objects
val ki = ji.kotlin as KMemberProperty<J, Int>
val ks = js.kotlin as KMutableMemberProperty<J, String>
val ki = ji.kotlin as KProperty1<J, Int>
val ks = js.kotlin as KMutableProperty1<J, String>
assert(ki.get(a) == 42, "Fail ki get")
assert(ks.get(a) == "def", "Fail ks get")
ks.set(a, "ghi")
@@ -11,7 +11,7 @@ fun box(): String {
val j = J()
val prop = J::prop
if (prop !is KMutableMemberProperty<*, *>) return "Fail instanceof"
if (prop !is KMutableProperty1<*, *>) return "Fail instanceof"
if (prop.name != "prop") return "Fail name: ${prop.name}"
if (prop.get(j) != ":(") return "Fail get before: ${prop[j]}"
prop[j] = ":)"
@@ -27,13 +27,13 @@ fun box(): String {
val prop2 = klass.properties.firstOrNull { it.name == "prop" } ?: "Fail: no 'prop' property in properties"
if (prop != prop2) return "Fail: property references from :: and from properties differ: $prop != $prop2"
if (prop2 !is KMutableMemberProperty<*, *>) return "Fail instanceof 2"
(prop2 as KMutableMemberProperty<J, String>).set(j, "::)")
if (prop2 !is KMutableProperty1<*, *>) return "Fail instanceof 2"
(prop2 as KMutableProperty1<J, String>).set(j, "::)")
if (prop.get(j) != "::)") return "Fail get after 2: ${prop[j]}"
val ext = klass.extensionProperties.firstOrNull { it.name == "ext" } ?: "Fail: no 'ext' property in extensionProperties"
ext as KMemberExtensionProperty<J, Int, Int>
ext as KProperty2<J, Int, Int>
val fortyTwo = ext.get(j, 42)
if (fortyTwo != 42) return "Fail ext get: $fortyTwo"
@@ -1,6 +1,6 @@
//For KT-6020
import kotlin.reflect.KMemberProperty
import kotlin.reflect.KMutableMemberProperty
import kotlin.reflect.KProperty1
import kotlin.reflect.KMutableProperty1
class Value<T>(var value: T = null as T, var text: String? = null)
@@ -8,7 +8,7 @@ val <T> Value<T>.additionalText by DVal(Value<T>::text) //works
val <T> Value<T>.additionalValue by DVal(Value<T>::value) //not work
class DVal<T, R, P: KMemberProperty<T, R>>(val kmember: P) {
class DVal<T, R, P: KProperty1<T, R>>(val kmember: P) {
fun get(t: T, p: PropertyMetadata): R {
return kmember.get(t)
}
@@ -17,4 +17,4 @@ class DVal<T, R, P: KMemberProperty<T, R>>(val kmember: P) {
fun box(): String {
val p = Value("O", "K")
return p.additionalValue + p.additionalText
}
}
@@ -1,8 +1,8 @@
import kotlin.reflect.KMemberProperty
import kotlin.reflect.KProperty1
class A {
companion object {
val ref: KMemberProperty<A, String> = A::foo
val ref: KProperty1<A, String> = A::foo
}
val foo: String = "OK"
@@ -1,11 +1,11 @@
import kotlin.reflect.IllegalPropertyAccessException
import kotlin.reflect.KMemberProperty
import kotlin.reflect.KProperty1
import kotlin.reflect.jvm.accessible
class Result {
private val value = "OK"
fun ref(): KMemberProperty<Result, String> = ::value
fun ref(): KProperty1<Result, String> = ::value
}
fun box(): String {
@@ -1,11 +1,11 @@
import kotlin.reflect.IllegalPropertyAccessException
import kotlin.reflect.KMutableMemberProperty
import kotlin.reflect.KMutableProperty1
import kotlin.reflect.jvm.accessible
class A {
private var value = 0
fun ref(): KMutableMemberProperty<A, Int> = ::value
fun ref(): KMutableProperty1<A, Int> = ::value
}
fun box(): String {
@@ -4,7 +4,7 @@ object A {
val b: String = "OK"
platformStatic val c: String = "OK"
platformStatic var c: String = "Fail"
platformStatic fun test1() : String {
return b
@@ -36,6 +36,8 @@ fun box(): String {
if ((A::test4)(A) != "1OK") return "fail 4"
(A::c).set(A, "OK")
if (((A::c).get(A)) != "OK") return "fail 5"
return "OK"
@@ -1,7 +1,7 @@
import kotlin.reflect.KExtensionProperty
import kotlin.reflect.KProperty1
import kotlin.test.assertEquals
fun check(expected: String, p: KExtensionProperty<*, *>) {
fun check(expected: String, p: KProperty1<*, *>) {
var s = p.toString()
// Strip "val" or "var"
@@ -4,7 +4,7 @@ import kotlin.reflect.jvm.*
class K(private val value: String)
fun box(): String {
val p = javaClass<K>().kotlin.properties.single() as KMemberProperty<K, String>
val p = javaClass<K>().kotlin.properties.single() as KProperty1<K, String>
try {
return p.get(K("Fail: private property should not be accessible by default"))
@@ -1,11 +1,10 @@
import kotlin.reflect.KMemberProperty
import kotlin.reflect.KProperty1
class A<T> {
val result = "OK"
}
fun box(): String {
val k = A::class.properties.single()
k : KMemberProperty<A<*>, *>
val k : KProperty1<A<*>, *> = A::class.properties.single()
return k.get(A<String>()) as String
}
@@ -1,5 +1,5 @@
import kotlin.reflect.jvm.kotlin
import kotlin.reflect.KMutableMemberExtensionProperty
import kotlin.reflect.KMutableProperty2
var storage = "before"
@@ -15,12 +15,12 @@ class A {
fun box(): String {
val props = javaClass<A>().kotlin.extensionProperties
val readonly = props.single { it.name == "readonly" }
assert(readonly !is KMutableMemberExtensionProperty<A, *, *>) { "Fail 1: $readonly" }
assert(readonly !is KMutableProperty2<A, *, *>) { "Fail 1: $readonly" }
val mutable = props.single { it.name == "mutable" }
assert(mutable is KMutableMemberExtensionProperty<A, *, *>) { "Fail 2: $mutable" }
assert(mutable is KMutableProperty2<A, *, *>) { "Fail 2: $mutable" }
val a = A()
mutable as KMutableMemberExtensionProperty<A, String, String>
mutable as KMutableProperty2<A, String, String>
assert(mutable[a, ""] == "before") { "Fail 3: ${mutable.get(a, "")}" }
mutable[a, ""] = "OK"
return mutable.get(a, "")
@@ -1,5 +1,5 @@
import kotlin.reflect.jvm.kotlin
import kotlin.reflect.KMutableMemberProperty
import kotlin.reflect.KMutableProperty1
class A(val readonly: String) {
var mutable: String = "before"
@@ -8,12 +8,12 @@ class A(val readonly: String) {
fun box(): String {
val props = javaClass<A>().kotlin.properties
val readonly = props.single { it.name == "readonly" }
assert(readonly !is KMutableMemberProperty<A, *>) { "Fail 1: $readonly" }
assert(readonly !is KMutableProperty1<A, *>) { "Fail 1: $readonly" }
val mutable = props.single { it.name == "mutable" }
assert(mutable is KMutableMemberProperty<A, *>) { "Fail 2: $mutable" }
assert(mutable is KMutableProperty1<A, *>) { "Fail 2: $mutable" }
val a = A("")
mutable as KMutableMemberProperty<A, String>
mutable as KMutableProperty1<A, String>
assert(mutable[a] == "before") { "Fail 3: ${mutable.get(a)}" }
mutable[a] = "OK"
return mutable.get(a)
@@ -1,6 +1,6 @@
import kotlin.reflect.jvm.kotlin
import kotlin.reflect.KMemberProperty
import kotlin.reflect.KMemberExtensionProperty
import kotlin.reflect.KProperty1
import kotlin.reflect.KProperty2
class A {
val foo: String = "member"
@@ -9,15 +9,15 @@ class A {
fun box(): String {
run {
val foo: KMemberProperty<A, *> = javaClass<A>().kotlin.properties.single()
val foo: KProperty1<A, *> = javaClass<A>().kotlin.properties.single()
assert(foo.name == "foo") { "Fail name: $foo (${foo.name})" }
assert(foo.get(A()) == "member") { "Fail value: ${foo[A()]}" }
}
run {
val foo: KMemberExtensionProperty<A, *, *> = javaClass<A>().kotlin.extensionProperties.single()
val foo: KProperty2<A, *, *> = javaClass<A>().kotlin.extensionProperties.single()
assert(foo.name == "foo") { "Fail name: $foo (${foo.name})" }
foo as KMemberExtensionProperty<A, Unit, *>
foo as KProperty2<A, Unit, *>
assert(foo.get(A(), Unit) == "extension") { "Fail value: ${foo[A(), Unit]}" }
}
@@ -1,6 +1,6 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberProperty
import kotlin.reflect.KProperty1
interface Base {
val x: Any
@@ -20,17 +20,17 @@ class C : B() {
fun test() {
val base = Base::x
checkSubtype<KMemberProperty<Base, Any>>(base)
checkSubtype<KProperty1<Base, Any>>(base)
checkSubtype<Any>(base.get(A()))
checkSubtype<Number>(<!TYPE_MISMATCH!>base.get(B())<!>)
checkSubtype<Int>(<!TYPE_MISMATCH!>base.get(C())<!>)
val a = A::x
checkSubtype<KMemberProperty<A, String>>(a)
checkSubtype<KProperty1<A, String>>(a)
checkSubtype<String>(a.get(A()))
checkSubtype<Number>(<!TYPE_MISMATCH!>a.get(<!TYPE_MISMATCH!>B()<!>)<!>)
val b = B::x
checkSubtype<KMemberProperty<B, Number>>(b)
checkSubtype<KProperty1<B, Number>>(b)
checkSubtype<Int>(<!TYPE_MISMATCH!>b.get(C())<!>)
}
@@ -1,6 +1,6 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberProperty
import kotlin.reflect.KProperty1
open class Base {
val foo: Int = 42
@@ -10,6 +10,6 @@ open class Derived : Base()
fun test() {
val o = Base::foo
checkSubtype<KMemberProperty<Base, Int>>(o)
checkSubtype<KProperty1<Base, Int>>(o)
checkSubtype<Int>(o.get(Derived()))
}
@@ -6,7 +6,7 @@ class A(var g: A) {
val f: Int = 0
fun test() {
val fRef: KMemberProperty<A, Int> = ::f
val gRef: KMutableMemberProperty<A, A> = ::g
val fRef: KProperty1<A, Int> = ::f
val gRef: KMutableProperty1<A, A> = ::g
}
}
@@ -4,8 +4,8 @@ import kotlin.reflect.*
class A {
fun test() {
val fooRef: KExtensionProperty<A, String> = ::foo
val barRef: KMutableExtensionProperty<A, Int> = ::bar
val fooRef: KProperty1<A, String> = ::foo
val barRef: KMutableProperty1<A, Int> = ::bar
}
}
@@ -12,18 +12,14 @@ var Int.meaning: Long
fun test() {
val f = String::countCharacters
checkSubtype<KTopLevelExtensionProperty<String, Int>>(f)
checkSubtype<KExtensionProperty<String, Int>>(f)
checkSubtype<KMutableExtensionProperty<String, Int>>(<!TYPE_MISMATCH!>f<!>)
checkSubtype<KProperty1<String, Int>>(f)
checkSubtype<KMutableProperty1<String, Int>>(<!TYPE_MISMATCH!>f<!>)
checkSubtype<Int>(f.get("abc"))
f.<!UNRESOLVED_REFERENCE!>set<!>("abc", 0)
val g = Int::meaning
checkSubtype<KTopLevelExtensionProperty<Int, Long>>(g)
checkSubtype<KExtensionProperty<Int, Long>>(g)
checkSubtype<KMutableTopLevelExtensionProperty<Int, Long>>(g)
checkSubtype<KMutableExtensionProperty<Int, Long>>(g)
checkSubtype<KMutableProperty1<Int, Long>>(g)
checkSubtype<Long>(g.get(0))
g.set(1, 0L)
}
@@ -1,6 +1,6 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberProperty
import kotlin.reflect.KProperty1
class A<T>(val t: T) {
val foo: T = t
@@ -8,9 +8,9 @@ class A<T>(val t: T) {
fun bar() {
val x = A<String>::foo
checkSubtype<KMemberProperty<A<String>, String>>(x)
checkSubtype<KMemberProperty<A<String>, Any?>>(x)
checkSubtype<KProperty1<A<String>, String>>(x)
checkSubtype<KProperty1<A<String>, Any?>>(x)
val y = A<*>::foo
checkSubtype<KMemberProperty<A<*>, Any?>>(y)
checkSubtype<KProperty1<A<*>, Any?>>(y)
}
@@ -17,10 +17,10 @@ public class JavaClass {
import kotlin.reflect.*
fun test() {
val pubFinRef: KMemberProperty<JavaClass, Int> = JavaClass::publicFinal
val pubMutRef: KMutableMemberProperty<JavaClass, Long> = JavaClass::publicMutable
val protFinRef: KMemberProperty<JavaClass, Double> = JavaClass::protectedFinal
val protMutRef: KMutableMemberProperty<JavaClass, Char> = JavaClass::protectedMutable
val privFinRef: KMemberProperty<JavaClass, String?> = JavaClass::<!INVISIBLE_MEMBER!>privateFinal<!>
val privMutRef: KMutableMemberProperty<JavaClass, Any?> = JavaClass::<!INVISIBLE_MEMBER!>privateMutable<!>
val pubFinRef: KProperty1<JavaClass, Int> = JavaClass::publicFinal
val pubMutRef: KMutableProperty1<JavaClass, Long> = JavaClass::publicMutable
val protFinRef: KProperty1<JavaClass, Double> = JavaClass::protectedFinal
val protMutRef: KMutableProperty1<JavaClass, Char> = JavaClass::protectedMutable
val privFinRef: KProperty1<JavaClass, String?> = JavaClass::<!INVISIBLE_MEMBER!>privateFinal<!>
val privMutRef: KMutableProperty1<JavaClass, Any?> = JavaClass::<!INVISIBLE_MEMBER!>privateMutable<!>
}
@@ -1,4 +1,3 @@
// !CHECK_TYPE
// !DIAGNOSTICS:-UNUSED_VARIABLE
// FILE: JavaClass.java
@@ -20,8 +19,8 @@ import JavaClass.*
import kotlin.reflect.*
fun test() {
val pubFinRef: KTopLevelProperty<String> = ::publicFinal
val pubMutRef: KMutableTopLevelProperty<Any?> = ::publicMutable
val pubFinRef: KProperty0<String> = ::publicFinal
val pubMutRef: KMutableProperty0<Any?> = ::publicMutable
val protFinRef: KProperty<Double> = ::protectedFinal
val protMutRef: KMutableProperty<Char> = ::protectedMutable
val privFinRef: KProperty<JavaClass?> = ::<!INVISIBLE_MEMBER!>privateFinal<!>
@@ -6,7 +6,7 @@ class A(var g: A) {
val f: Int = 0
fun test() {
checkSubtype<KMemberProperty<A, Int>>(::f)
checkSubtype<KMutableMemberProperty<A, A>>(::g)
checkSubtype<KProperty1<A, Int>>(::f)
checkSubtype<KMutableProperty1<A, A>>(::g)
}
}
}
@@ -1,10 +1,10 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KMemberProperty
import kotlin.reflect.KProperty1
class TestClass(var prop: Int)
open class OtherClass
fun OtherClass.test(prop: KMemberProperty<TestClass, Int>): Unit = throw Exception()
fun OtherClass.test(prop: KProperty1<TestClass, Int>): Unit = throw Exception()
class OtherClass2: OtherClass() {
val result = test(TestClass::<!UNRESOLVED_REFERENCE!>result<!>)
}
@@ -1,6 +1,6 @@
package
internal fun OtherClass.test(/*0*/ prop: kotlin.reflect.KMemberProperty<TestClass, kotlin.Int>): kotlin.Unit
internal fun OtherClass.test(/*0*/ prop: kotlin.reflect.KProperty1<TestClass, kotlin.Int>): kotlin.Unit
internal open class OtherClass {
public constructor OtherClass()
@@ -15,9 +15,9 @@ fun A.test() {
val y = ::bar
val z = ::self
checkSubtype<KMemberProperty<A, Unit>>(x)
checkSubtype<KMutableMemberProperty<A, String>>(y)
checkSubtype<KMutableMemberProperty<A, A>>(z)
checkSubtype<KProperty1<A, Unit>>(x)
checkSubtype<KMutableProperty1<A, String>>(y)
checkSubtype<KMutableProperty1<A, A>>(z)
y.set(z.get(A()), x.get(A()).toString())
}
@@ -10,16 +10,16 @@ class A {
fun test() {
val p = A::foo
checkSubtype<KMemberProperty<A, Int>>(p)
checkSubtype<KMutableMemberProperty<A, Int>>(<!TYPE_MISMATCH!>p<!>)
checkSubtype<KProperty1<A, Int>>(p)
checkSubtype<KMutableProperty1<A, Int>>(<!TYPE_MISMATCH!>p<!>)
checkSubtype<Int>(p.get(A()))
p.get(<!NO_VALUE_FOR_PARAMETER!>)<!>
p.<!UNRESOLVED_REFERENCE!>set<!>(A(), 239)
val q = A::bar
checkSubtype<KMemberProperty<A, String>>(q)
checkSubtype<KMutableMemberProperty<A, String>>(q)
checkSubtype<KProperty1<A, String>>(q)
checkSubtype<KMutableProperty1<A, String>>(q)
checkSubtype<String>(q.get(A()))
q.set(A(), "q")
}
@@ -1,6 +1,6 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberProperty
import kotlin.reflect.KProperty1
class C {
val baz: Int = 12
@@ -9,5 +9,5 @@ class C {
fun Int.baz() {}
fun test() {
C::baz checkType { _<KMemberProperty<C, Int>>() }
}
C::baz checkType { _<KProperty1<C, Int>>() }
}
@@ -7,12 +7,9 @@ val y: String get() = "y"
fun testX() {
val xx = ::x
checkSubtype<KMutableTopLevelProperty<Int>>(xx)
checkSubtype<KMutableTopLevelVariable<Int>>(xx)
checkSubtype<KTopLevelProperty<Int>>(xx)
checkSubtype<KTopLevelVariable<Int>>(xx)
checkSubtype<KMutableProperty0<Int>>(xx)
checkSubtype<KProperty0<Int>>(xx)
checkSubtype<KMutableProperty<Int>>(xx)
checkSubtype<KMutableVariable<Int>>(xx)
checkSubtype<KProperty<Int>>(xx)
checkSubtype<KCallable<Int>>(xx)
@@ -23,8 +20,8 @@ fun testX() {
fun testY() {
val yy = ::y
checkSubtype<KMutableTopLevelProperty<String>>(<!TYPE_MISMATCH!>yy<!>)
checkSubtype<KTopLevelVariable<String>>(yy)
checkSubtype<KMutableProperty0<String>>(<!TYPE_MISMATCH!>yy<!>)
checkSubtype<KProperty0<String>>(yy)
checkSubtype<KMutableProperty<String>>(<!TYPE_MISMATCH!>yy<!>)
checkSubtype<KProperty<String>>(yy)
checkSubtype<KCallable<String>>(yy)