Drop KPropertyNFromReferenceImpl classes
The only place where their get/set methods were used was in KPropertyNImpl.Getter.invoke, and it's fine if that results in a reflective call instead (KPropertyN#getter is not available without kotlin-reflect.jar anyway). The test data has been changed because a package local Java field is not accessible via reflection
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
static String x;
|
||||
public static String x;
|
||||
|
||||
static String packageLocalField;
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
@@ -19,5 +21,13 @@ fun box(): String {
|
||||
assertEquals("OK", J.x)
|
||||
assertEquals("OK", f.getter())
|
||||
|
||||
val pl = J::packageLocalField.getter
|
||||
try {
|
||||
pl()
|
||||
return "Fail: package local field must be inaccessible"
|
||||
} catch (e: Exception) {
|
||||
// OK
|
||||
}
|
||||
|
||||
return f.get()
|
||||
}
|
||||
|
||||
@@ -24,59 +24,32 @@ internal open class KProperty0Augmented(
|
||||
override val name: String get() = reference.name
|
||||
}
|
||||
|
||||
internal class KProperty0FromReferenceImpl(reference: PropertyReference0) : KProperty0Augmented(reference) {
|
||||
override fun get(): Any? = reference.get()
|
||||
}
|
||||
|
||||
internal open class KMutableProperty0Augmented(
|
||||
val reference: MutablePropertyReference0
|
||||
) : KMutableProperty0Impl<Any?>(reference.owner as KDeclarationContainerImpl, reference.name, reference.signature) {
|
||||
override val name: String get() = reference.name
|
||||
}
|
||||
|
||||
internal class KMutableProperty0FromReferenceImpl(reference: MutablePropertyReference0) : KMutableProperty0Augmented(reference) {
|
||||
override fun get(): Any? = reference.get()
|
||||
override fun set(value: Any?) = reference.set(value)
|
||||
}
|
||||
|
||||
internal open class KProperty1Augmented(
|
||||
val reference: PropertyReference1
|
||||
) : KProperty1Impl<Any?, Any?>(reference.owner as KDeclarationContainerImpl, reference.name, reference.signature) {
|
||||
override val name: String get() = reference.name
|
||||
}
|
||||
|
||||
internal class KProperty1FromReferenceImpl(reference: PropertyReference1) : KProperty1Augmented(reference) {
|
||||
override fun get(receiver: Any?): Any? = reference.get(receiver)
|
||||
}
|
||||
|
||||
internal open class KMutableProperty1Augmented(
|
||||
val reference: MutablePropertyReference1
|
||||
) : KMutableProperty1Impl<Any?, Any?>(reference.owner as KDeclarationContainerImpl, reference.name, reference.signature) {
|
||||
override val name: String get() = reference.name
|
||||
}
|
||||
|
||||
internal class KMutableProperty1FromReferenceImpl(reference: MutablePropertyReference1) : KMutableProperty1Augmented(reference) {
|
||||
override fun get(receiver: Any?): Any? = reference.get(receiver)
|
||||
override fun set(receiver: Any?, value: Any?) = reference.set(receiver, value)
|
||||
}
|
||||
|
||||
internal open class KProperty2Augmented(
|
||||
val reference: PropertyReference2
|
||||
) : KProperty2Impl<Any?, Any?, Any?>(reference.owner as KDeclarationContainerImpl, reference.name, reference.signature) {
|
||||
override val name: String get() = reference.name
|
||||
}
|
||||
|
||||
internal class KProperty2FromReferenceImpl(reference: PropertyReference2) : KProperty2Augmented(reference) {
|
||||
override fun get(receiver1: Any?, receiver2: Any?): Any? = reference.get(receiver1, receiver2)
|
||||
}
|
||||
|
||||
internal open class KMutableProperty2Augmented(
|
||||
val reference: MutablePropertyReference2
|
||||
) : KMutableProperty2Impl<Any?, Any?, Any?>(reference.owner as KDeclarationContainerImpl, reference.name, reference.signature) {
|
||||
override val name: String get() = reference.name
|
||||
}
|
||||
|
||||
internal class KMutableProperty2FromReferenceImpl(reference: MutablePropertyReference2) : KMutableProperty2Augmented(reference) {
|
||||
override fun get(receiver1: Any?, receiver2: Any?): Any? = reference.get(receiver1, receiver2)
|
||||
override fun set(receiver1: Any?, receiver2: Any?, value: Any?) = reference.set(receiver1, receiver2, value)
|
||||
}
|
||||
|
||||
@@ -74,31 +74,31 @@ public class ReflectionFactoryImpl extends ReflectionFactory {
|
||||
|
||||
@Override
|
||||
public KProperty0 property0(PropertyReference0 p) {
|
||||
return p instanceof PropertyReference0Impl ? new KProperty0Augmented(p) : new KProperty0FromReferenceImpl(p);
|
||||
return new KProperty0Augmented(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KMutableProperty0 mutableProperty0(MutablePropertyReference0 p) {
|
||||
return p instanceof MutablePropertyReference0Impl ? new KMutableProperty0Augmented(p) : new KMutableProperty0FromReferenceImpl(p);
|
||||
return new KMutableProperty0Augmented(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KProperty1 property1(PropertyReference1 p) {
|
||||
return p instanceof PropertyReference1Impl ? new KProperty1Augmented(p) : new KProperty1FromReferenceImpl(p);
|
||||
return new KProperty1Augmented(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KMutableProperty1 mutableProperty1(MutablePropertyReference1 p) {
|
||||
return p instanceof MutablePropertyReference1Impl ? new KMutableProperty1Augmented(p) : new KMutableProperty1FromReferenceImpl(p);
|
||||
return new KMutableProperty1Augmented(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KProperty2 property2(PropertyReference2 p) {
|
||||
return p instanceof PropertyReference2Impl ? new KProperty2Augmented(p) : new KProperty2FromReferenceImpl(p);
|
||||
return new KProperty2Augmented(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KMutableProperty2 mutableProperty2(MutablePropertyReference2 p) {
|
||||
return p instanceof MutablePropertyReference2Impl ? new KMutableProperty2Augmented(p) : new KMutableProperty2FromReferenceImpl(p);
|
||||
return new KMutableProperty2Augmented(p);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user