KT-8575 Add tests and disable reflection for Java synthetic property references

This commit is contained in:
Pavel Mikhailovskii
2022-09-22 10:48:14 +02:00
committed by teamcity
parent 5116bbc440
commit f8fd23e373
12 changed files with 210 additions and 46 deletions
@@ -11,26 +11,42 @@ import kotlin.reflect.KProperty;
@SuppressWarnings("rawtypes")
public abstract class PropertyReference extends CallableReference implements KProperty {
private final boolean syntheticJavaProperty;
public PropertyReference() {
super();
syntheticJavaProperty = false;
}
@SinceKotlin(version = "1.1")
public PropertyReference(Object receiver) {
super(receiver);
syntheticJavaProperty = false;
}
@SinceKotlin(version = "1.4")
public PropertyReference(Object receiver, Class owner, String name, String signature, int flags) {
super(receiver, owner, name, signature, (flags & 1) == 1);
syntheticJavaProperty = (flags & 2) == 2;
}
@Override
@SinceKotlin(version = "1.1")
protected KProperty getReflected() {
if (syntheticJavaProperty) {
throw new UnsupportedOperationException("Kotlin reflection is not yet supported for synthetic Java properties");
}
return (KProperty) super.getReflected();
}
@Override
public KCallable compute() {
return syntheticJavaProperty ? this : super.compute();
}
@Override
@SinceKotlin(version = "1.1")
public boolean isLateinit() {
@@ -4007,6 +4007,7 @@ public abstract class kotlin/jvm/internal/PropertyReference : kotlin/jvm/interna
public fun <init> ()V
public fun <init> (Ljava/lang/Object;)V
public fun <init> (Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
public fun compute ()Lkotlin/reflect/KCallable;
public fun equals (Ljava/lang/Object;)Z
protected synthetic fun getReflected ()Lkotlin/reflect/KCallable;
protected fun getReflected ()Lkotlin/reflect/KProperty;