From 8fd29a9fec9bdaaca3a209488ee2c5507f69230f Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Mon, 2 May 2022 13:30:06 +0300 Subject: [PATCH] Fir2Ir: properly compute setter type parameter bounds --- .../fir/backend/Fir2IrClassifierStorage.kt | 2 +- .../typeParameterBeforeBound.fir.ir.txt | 40 ------------------- .../typeParameterBeforeBound.fir.kt.txt | 17 -------- .../parameters/typeParameterBeforeBound.kt | 1 + 4 files changed, 2 insertions(+), 58 deletions(-) delete mode 100644 compiler/testData/ir/irText/declarations/parameters/typeParameterBeforeBound.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/declarations/parameters/typeParameterBeforeBound.fir.kt.txt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrClassifierStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrClassifierStorage.kt index ff4f9621d69..60753567795 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrClassifierStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrClassifierStorage.kt @@ -115,7 +115,7 @@ class Fir2IrClassifierStorage( getIrTypeParameter(typeParameter, index, symbol, typeContext).apply { parent = this@setTypeParameters if (superTypes.isEmpty()) { - superTypes = typeParameter.bounds.map { it.toIrType() } + superTypes = typeParameter.bounds.map { it.toIrType(typeContext) } } } } diff --git a/compiler/testData/ir/irText/declarations/parameters/typeParameterBeforeBound.fir.ir.txt b/compiler/testData/ir/irText/declarations/parameters/typeParameterBeforeBound.fir.ir.txt deleted file mode 100644 index de330442279..00000000000 --- a/compiler/testData/ir/irText/declarations/parameters/typeParameterBeforeBound.fir.ir.txt +++ /dev/null @@ -1,40 +0,0 @@ -FILE fqName: fileName:/typeParameterBeforeBound.kt - CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test1.Test1, U of .Test1> - TYPE_PARAMETER name:T index:0 variance: superTypes:[U of .Test1] reified:false - TYPE_PARAMETER name:U index:1 variance: superTypes:[kotlin.Any?] reified:false - CONSTRUCTOR visibility:public <> () returnType:.Test1.Test1, U of .Test1> [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test2 visibility:public modality:FINAL () returnType:kotlin.Unit - TYPE_PARAMETER name:T index:0 variance: superTypes:[U of .test2] reified:false - TYPE_PARAMETER name:U index:1 variance: superTypes:[kotlin.Any?] reified:false - BLOCK_BODY - PROPERTY name:test3 visibility:public modality:FINAL [var] - FUN name: visibility:public modality:FINAL ($receiver:.Test1., U of .>) returnType:kotlin.Unit - correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [var] - TYPE_PARAMETER name:T index:0 variance: superTypes:[U of .] reified:false - TYPE_PARAMETER name:U index:1 variance: superTypes:[kotlin.Any?] reified:false - $receiver: VALUE_PARAMETER name: type:.Test1., U of .> - BLOCK_BODY - FUN name: visibility:public modality:FINAL ($receiver:.Test1., U of .>, value:kotlin.Unit) returnType:kotlin.Unit - correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [var] - TYPE_PARAMETER name:T index:0 variance: superTypes:[U of .] reified:false - TYPE_PARAMETER name:U index:1 variance: superTypes:[kotlin.Any?] reified:false - $receiver: VALUE_PARAMETER name: type:.Test1., U of .> - VALUE_PARAMETER name:value index:0 type:kotlin.Unit - BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/parameters/typeParameterBeforeBound.fir.kt.txt b/compiler/testData/ir/irText/declarations/parameters/typeParameterBeforeBound.fir.kt.txt deleted file mode 100644 index 7fb49758dad..00000000000 --- a/compiler/testData/ir/irText/declarations/parameters/typeParameterBeforeBound.fir.kt.txt +++ /dev/null @@ -1,17 +0,0 @@ -class Test1 { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - -} - -fun test2() { -} - -var Test1.test3: Unit - get() { - } - set(value: Unit) { - } diff --git a/compiler/testData/ir/irText/declarations/parameters/typeParameterBeforeBound.kt b/compiler/testData/ir/irText/declarations/parameters/typeParameterBeforeBound.kt index 7c199dbbee9..e0f5e0bb1e1 100644 --- a/compiler/testData/ir/irText/declarations/parameters/typeParameterBeforeBound.kt +++ b/compiler/testData/ir/irText/declarations/parameters/typeParameterBeforeBound.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL class Test1 fun test2() {}