[PSI2IR] Use candidate descriptor to get original type parameters while generating assignment receiver for property
^KT-46829 Fixed
This commit is contained in:
+6
@@ -21412,6 +21412,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/innerNested/kt4036.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt4036.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt46829.kt")
|
||||||
|
public void testKt46829() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/innerNested/kt46829.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt5363.kt")
|
@TestMetadata("kt5363.kt")
|
||||||
public void testKt5363() throws Exception {
|
public void testKt5363() throws Exception {
|
||||||
|
|||||||
+11
-5
@@ -294,9 +294,12 @@ class AssignmentGenerator(statementGenerator: StatementGenerator) : StatementGen
|
|||||||
)
|
)
|
||||||
|
|
||||||
val superQualifier = getSuperQualifier(resolvedCall)
|
val superQualifier = getSuperQualifier(resolvedCall)
|
||||||
|
val candidateDescriptor = resolvedCall.candidateDescriptor as PropertyDescriptor
|
||||||
|
|
||||||
// TODO property imported from an object
|
// TODO property imported from an object
|
||||||
createPropertyLValue(ktLeft, descriptor, propertyReceiver, getTypeArguments(resolvedCall), origin, superQualifier)
|
createPropertyLValue(
|
||||||
|
ktLeft, descriptor, candidateDescriptor, propertyReceiver, getTypeArguments(resolvedCall), origin, superQualifier
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,26 +311,29 @@ class AssignmentGenerator(statementGenerator: StatementGenerator) : StatementGen
|
|||||||
|
|
||||||
private fun createPropertyLValue(
|
private fun createPropertyLValue(
|
||||||
ktExpression: KtExpression,
|
ktExpression: KtExpression,
|
||||||
descriptor: PropertyDescriptor,
|
resultingDescriptor: PropertyDescriptor,
|
||||||
|
candidateDescriptor: PropertyDescriptor,
|
||||||
propertyReceiver: CallReceiver,
|
propertyReceiver: CallReceiver,
|
||||||
typeArgumentsMap: Map<TypeParameterDescriptor, KotlinType>?,
|
typeArgumentsMap: Map<TypeParameterDescriptor, KotlinType>?,
|
||||||
origin: IrStatementOrigin?,
|
origin: IrStatementOrigin?,
|
||||||
superQualifier: ClassDescriptor?
|
superQualifier: ClassDescriptor?
|
||||||
): PropertyLValueBase {
|
): PropertyLValueBase {
|
||||||
|
|
||||||
val unwrappedPropertyDescriptor = descriptor.unwrapPropertyDescriptor()
|
val unwrappedPropertyDescriptor = resultingDescriptor.unwrapPropertyDescriptor()
|
||||||
val getterDescriptor = unwrappedPropertyDescriptor.unwrappedGetMethod
|
val getterDescriptor = unwrappedPropertyDescriptor.unwrappedGetMethod
|
||||||
val setterDescriptor = unwrappedPropertyDescriptor.unwrappedSetMethod
|
val setterDescriptor = unwrappedPropertyDescriptor.unwrappedSetMethod
|
||||||
|
|
||||||
val getterSymbol = getterDescriptor?.let { context.symbolTable.referenceSimpleFunction(it.original) }
|
val getterSymbol = getterDescriptor?.let { context.symbolTable.referenceSimpleFunction(it.original) }
|
||||||
val setterSymbol = setterDescriptor?.let { context.symbolTable.referenceSimpleFunction(it.original) }
|
val setterSymbol = setterDescriptor?.let { context.symbolTable.referenceSimpleFunction(it.original) }
|
||||||
|
|
||||||
val propertyIrType = descriptor.type.toIrType()
|
val propertyIrType = resultingDescriptor.type.toIrType()
|
||||||
return if (getterSymbol != null || setterSymbol != null) {
|
return if (getterSymbol != null || setterSymbol != null) {
|
||||||
val superQualifierSymbol = superQualifier?.let { context.symbolTable.referenceClass(it) }
|
val superQualifierSymbol = superQualifier?.let { context.symbolTable.referenceClass(it) }
|
||||||
val typeArgumentsList =
|
val typeArgumentsList =
|
||||||
typeArgumentsMap?.let { typeArguments ->
|
typeArgumentsMap?.let { typeArguments ->
|
||||||
descriptor.original.typeParameters.map { typeArguments[it]!!.toIrType() }
|
candidateDescriptor.typeParameters.map {
|
||||||
|
typeArguments[it]!!.toIrType()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
AccessorPropertyLValue(
|
AccessorPropertyLValue(
|
||||||
context,
|
context,
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
class Outer<T> {
|
||||||
|
var <V> Inner<T, V>.prop: V
|
||||||
|
get() = this.value
|
||||||
|
set(value) {
|
||||||
|
this.value = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Inner<T, V>(
|
||||||
|
val key: T,
|
||||||
|
var value: V
|
||||||
|
)
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
Outer<Boolean>().run {
|
||||||
|
val i = Inner(true, false)
|
||||||
|
i.prop = true
|
||||||
|
}
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+6
@@ -21280,6 +21280,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/innerNested/kt4036.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt4036.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt46829.kt")
|
||||||
|
public void testKt46829() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/innerNested/kt46829.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt5363.kt")
|
@TestMetadata("kt5363.kt")
|
||||||
public void testKt5363() throws Exception {
|
public void testKt5363() throws Exception {
|
||||||
|
|||||||
+6
@@ -21412,6 +21412,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/innerNested/kt4036.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt4036.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt46829.kt")
|
||||||
|
public void testKt46829() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/innerNested/kt46829.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt5363.kt")
|
@TestMetadata("kt5363.kt")
|
||||||
public void testKt5363() throws Exception {
|
public void testKt5363() throws Exception {
|
||||||
|
|||||||
+5
@@ -17769,6 +17769,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/innerNested/kt4036.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt4036.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt46829.kt")
|
||||||
|
public void testKt46829() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/innerNested/kt46829.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt5363.kt")
|
@TestMetadata("kt5363.kt")
|
||||||
public void testKt5363() throws Exception {
|
public void testKt5363() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -15603,6 +15603,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
|||||||
runTest("compiler/testData/codegen/box/innerNested/kt3927.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt3927.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt46829.kt")
|
||||||
|
public void testKt46829() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/innerNested/kt46829.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt5363.kt")
|
@TestMetadata("kt5363.kt")
|
||||||
public void testKt5363() throws Exception {
|
public void testKt5363() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
|
||||||
|
|||||||
Generated
+5
@@ -15009,6 +15009,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/innerNested/kt3927.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt3927.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt46829.kt")
|
||||||
|
public void testKt46829() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/innerNested/kt46829.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt5363.kt")
|
@TestMetadata("kt5363.kt")
|
||||||
public void testKt5363() throws Exception {
|
public void testKt5363() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
|
||||||
|
|||||||
Generated
+5
@@ -15039,6 +15039,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/innerNested/kt3927.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt3927.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt46829.kt")
|
||||||
|
public void testKt46829() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/innerNested/kt46829.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt5363.kt")
|
@TestMetadata("kt5363.kt")
|
||||||
public void testKt5363() throws Exception {
|
public void testKt5363() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+5
@@ -9753,6 +9753,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/innerNested/kt3927.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt3927.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt46829.kt")
|
||||||
|
public void testKt46829() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/innerNested/kt46829.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt5363.kt")
|
@TestMetadata("kt5363.kt")
|
||||||
public void testKt5363() throws Exception {
|
public void testKt5363() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
|
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user