Fix error with interpreting name of java property
This commit is contained in:
@@ -604,7 +604,11 @@ class IrInterpreter(internal val environment: IrInterpreterEnvironment, internal
|
|||||||
|
|
||||||
fun List<IrTypeParameter>.addToFields() {
|
fun List<IrTypeParameter>.addToFields() {
|
||||||
(0 until propertyReference.typeArgumentsCount).forEach { index ->
|
(0 until propertyReference.typeArgumentsCount).forEach { index ->
|
||||||
val kTypeState = KTypeState(propertyReference.getTypeArgument(index)!!, environment.kTypeClass.owner)
|
// We need nullable check for java case in FIR
|
||||||
|
// For some reason it is possible that typeArgumentsCount > 0, but all args are null
|
||||||
|
// TODO report as error after fix KT-52480
|
||||||
|
val typeArgument = propertyReference.getTypeArgument(index) ?: return@forEach
|
||||||
|
val kTypeState = KTypeState(typeArgument, environment.kTypeClass.owner)
|
||||||
propertyState.setField(this[index].symbol, kTypeState)
|
propertyState.setField(this[index].symbol, kTypeState)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -20,7 +20,7 @@ internal open class KProperty0Proxy(
|
|||||||
state: KPropertyState, callInterceptor: CallInterceptor
|
state: KPropertyState, callInterceptor: CallInterceptor
|
||||||
) : AbstractKPropertyProxy(state, callInterceptor), KProperty0<Any?> {
|
) : AbstractKPropertyProxy(state, callInterceptor), KProperty0<Any?> {
|
||||||
override val getter: KProperty0.Getter<Any?>
|
override val getter: KProperty0.Getter<Any?>
|
||||||
get() = object : Getter(state.property.getter!!), KProperty0.Getter<Any?> {
|
get() = object : Getter(state.property.getter!!), KProperty0.Getter<Any?> { // TODO avoid !!; getter will be null in case of java property
|
||||||
override fun invoke(): Any? = call()
|
override fun invoke(): Any? = call()
|
||||||
|
|
||||||
override fun call(vararg args: Any?): Any? {
|
override fun call(vararg args: Any?): Any? {
|
||||||
@@ -54,8 +54,8 @@ internal open class KProperty0Proxy(
|
|||||||
internal class KMutableProperty0Proxy(
|
internal class KMutableProperty0Proxy(
|
||||||
state: KPropertyState, callInterceptor: CallInterceptor
|
state: KPropertyState, callInterceptor: CallInterceptor
|
||||||
) : KProperty0Proxy(state, callInterceptor), KMutableProperty0<Any?> {
|
) : KProperty0Proxy(state, callInterceptor), KMutableProperty0<Any?> {
|
||||||
override val setter: KMutableProperty0.Setter<Any?> =
|
override val setter: KMutableProperty0.Setter<Any?>
|
||||||
object : Setter(state.property.setter!!), KMutableProperty0.Setter<Any?> {
|
get() = object : Setter(state.property.setter!!), KMutableProperty0.Setter<Any?> {
|
||||||
override fun invoke(p1: Any?) = call(p1)
|
override fun invoke(p1: Any?) = call(p1)
|
||||||
|
|
||||||
override fun call(vararg args: Any?) {
|
override fun call(vararg args: Any?) {
|
||||||
|
|||||||
+2
-2
@@ -54,8 +54,8 @@ internal open class KProperty1Proxy(
|
|||||||
internal class KMutableProperty1Proxy(
|
internal class KMutableProperty1Proxy(
|
||||||
state: KPropertyState, callInterceptor: CallInterceptor
|
state: KPropertyState, callInterceptor: CallInterceptor
|
||||||
) : KProperty1Proxy(state, callInterceptor), KMutableProperty1<Any?, Any?> {
|
) : KProperty1Proxy(state, callInterceptor), KMutableProperty1<Any?, Any?> {
|
||||||
override val setter: KMutableProperty1.Setter<Any?, Any?> =
|
override val setter: KMutableProperty1.Setter<Any?, Any?>
|
||||||
object : Setter(state.property.setter!!), KMutableProperty1.Setter<Any?, Any?> {
|
get() = object : Setter(state.property.setter!!), KMutableProperty1.Setter<Any?, Any?> {
|
||||||
override fun invoke(p1: Any?, p2: Any?) = call(p1, p2)
|
override fun invoke(p1: Any?, p2: Any?) = call(p1, p2)
|
||||||
|
|
||||||
override fun call(vararg args: Any?) {
|
override fun call(vararg args: Any?) {
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// FILE: Main.kt
|
||||||
|
const val name = <!EVALUATED: `SOME_PROPERTY`!>ClassWithProperty::SOME_PROPERTY.name<!>
|
||||||
|
|
||||||
|
// FILE: ClassWithProperty.java
|
||||||
|
public class ClassWithProperty {
|
||||||
|
public boolean SOME_PROPERTY = false;
|
||||||
|
}
|
||||||
+6
@@ -706,6 +706,12 @@ public class IrInterpreterAfterFir2IrTestGenerated extends AbstractIrInterpreter
|
|||||||
runTest("compiler/testData/ir/interpreter/reference/getClass.kt");
|
runTest("compiler/testData/ir/interpreter/reference/getClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaPropertyReference.kt")
|
||||||
|
public void testJavaPropertyReference() throws Exception {
|
||||||
|
runTest("compiler/testData/ir/interpreter/reference/javaPropertyReference.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("propertyReference.kt")
|
@TestMetadata("propertyReference.kt")
|
||||||
public void testPropertyReference() throws Exception {
|
public void testPropertyReference() throws Exception {
|
||||||
|
|||||||
+6
@@ -706,6 +706,12 @@ public class IrInterpreterAfterPsi2IrTestGenerated extends AbstractIrInterpreter
|
|||||||
runTest("compiler/testData/ir/interpreter/reference/getClass.kt");
|
runTest("compiler/testData/ir/interpreter/reference/getClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaPropertyReference.kt")
|
||||||
|
public void testJavaPropertyReference() throws Exception {
|
||||||
|
runTest("compiler/testData/ir/interpreter/reference/javaPropertyReference.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("propertyReference.kt")
|
@TestMetadata("propertyReference.kt")
|
||||||
public void testPropertyReference() throws Exception {
|
public void testPropertyReference() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user