FIR2IR: fix type parameter indexes & fix some black-box & FIR2IR tests
This commit is contained in:
+6
-9
@@ -130,15 +130,11 @@ class Fir2IrDeclarationStorage(
|
||||
}
|
||||
}
|
||||
|
||||
private fun IrClass.setThisReceiver(typeParameters: List<FirTypeParameter>? = null) {
|
||||
private fun IrClass.setThisReceiver() {
|
||||
enterScope(descriptor)
|
||||
val typeArguments = typeParameters?.map {
|
||||
IrSimpleTypeImpl(
|
||||
it.symbol.toTypeParameterSymbol(this@Fir2IrDeclarationStorage),
|
||||
false,
|
||||
emptyList(),
|
||||
emptyList())
|
||||
} ?: emptyList()
|
||||
val typeArguments = this.typeParameters.map {
|
||||
IrSimpleTypeImpl(it.symbol, false, emptyList(), emptyList())
|
||||
}
|
||||
thisReceiver = declareThisReceiverParameter(
|
||||
parent = this,
|
||||
thisType = IrSimpleTypeImpl(symbol, false, typeArguments, emptyList()),
|
||||
@@ -204,7 +200,6 @@ class Fir2IrDeclarationStorage(
|
||||
parent = getIrExternalPackageFragment(packageFqName)
|
||||
}
|
||||
}
|
||||
setThisReceiver((klass as? FirRegularClass)?.typeParameters)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -216,11 +211,13 @@ class Fir2IrDeclarationStorage(
|
||||
val created = create()
|
||||
localStorage.putLocalClass(klass, created)
|
||||
created.declareSupertypesAndTypeParameters(klass)
|
||||
created.setThisReceiver()
|
||||
return created
|
||||
}
|
||||
// NB: klass can be either FirRegularClass or FirAnonymousObject
|
||||
return classCache.getOrPut(klass as FirRegularClass, { create() }) {
|
||||
it.declareSupertypesAndTypeParameters(klass)
|
||||
it.setThisReceiver()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,10 @@ FILE fqName:<root> fileName:/localDelegatedProperties.kt
|
||||
GET_VAR 'var x: IrErrorType [var] declared in <root>.test2' type=IrErrorType origin=null
|
||||
SET_VAR 'var x: IrErrorType [var] declared in <root>.test2' type=IrErrorType origin=null
|
||||
CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
$this: GET_VAR 'val tmp_0: kotlin.Int [val] declared in <root>.test2' type=kotlin.Int origin=null
|
||||
GET_VAR 'val tmp_0: kotlin.Int [val] declared in <root>.test2' type=kotlin.Int origin=null
|
||||
$this: TYPE_OP type=IrErrorType origin=IMPLICIT_CAST typeOperand=IrErrorType
|
||||
GET_VAR 'val tmp_0: kotlin.Int [val] declared in <root>.test2' type=kotlin.Int origin=null
|
||||
TYPE_OP type=IrErrorType origin=IMPLICIT_CAST typeOperand=IrErrorType
|
||||
GET_VAR 'val tmp_0: kotlin.Int [val] declared in <root>.test2' type=kotlin.Int origin=null
|
||||
SET_VAR 'var x: IrErrorType [var] declared in <root>.test2' type=IrErrorType origin=null
|
||||
CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
$this: GET_VAR 'var x: IrErrorType [var] declared in <root>.test2' type=kotlin.Int origin=null
|
||||
|
||||
@@ -2,7 +2,7 @@ FILE fqName:<root> fileName:/constructor.kt
|
||||
CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Test1<T1 of <root>.Test1, T2 of <root>.Test1>
|
||||
TYPE_PARAMETER name:T1 index:0 variance: superTypes:[kotlin.Any?]
|
||||
TYPE_PARAMETER name:T2 index:0 variance: superTypes:[kotlin.Any?]
|
||||
TYPE_PARAMETER name:T2 index:1 variance: superTypes:[kotlin.Any?]
|
||||
CONSTRUCTOR visibility:public <> (x:T1 of <root>.Test1, y:T2 of <root>.Test1) returnType:<root>.Test1<T1 of <root>.Test1, T2 of <root>.Test1> [primary]
|
||||
VALUE_PARAMETER name:x index:0 type:T1 of <root>.Test1
|
||||
VALUE_PARAMETER name:y index:1 type:T2 of <root>.Test1
|
||||
|
||||
@@ -2,7 +2,7 @@ FILE fqName:<root> fileName:/partialSam.kt
|
||||
CLASS INTERFACE name:Fn modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Fn<T of <root>.Fn, R of <root>.Fn>
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||
TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Any?]
|
||||
TYPE_PARAMETER name:R index:1 variance: superTypes:[kotlin.Any?]
|
||||
FUN name:run visibility:public modality:ABSTRACT <> ($this:<root>.Fn<T of <root>.Fn, R of <root>.Fn>, s:kotlin.String, i:kotlin.Int, t:T of <root>.Fn) returnType:R of <root>.Fn
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Fn<T of <root>.Fn, R of <root>.Fn>
|
||||
VALUE_PARAMETER name:s index:0 type:kotlin.String
|
||||
|
||||
+2
-3
@@ -37,7 +37,7 @@ FILE fqName:<root> fileName:/kt30020.kt
|
||||
CALL 'public final fun plusAssign <T> (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null
|
||||
<T>: kotlin.Int
|
||||
$receiver: TYPE_OP type=kotlin.collections.MutableList<kotlin.Int> origin=CAST typeOperand=kotlin.collections.MutableList<kotlin.Int>
|
||||
CALL 'public abstract fun <get-xs> (): kotlin.collections.MutableList<kotlin.Any> declared in <root>.X' type=kotlin.collections.MutableList<kotlin.Int> origin=null
|
||||
CALL 'public abstract fun <get-xs> (): kotlin.collections.MutableList<kotlin.Any> declared in <root>.X' type=kotlin.collections.MutableList<kotlin.Any> origin=null
|
||||
$this: GET_VAR 'x: <root>.X declared in <root>.test' type=<root>.X origin=null
|
||||
element: CONST Int type=kotlin.Int value=3
|
||||
CALL 'public final fun plusAssign <T> (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null
|
||||
@@ -58,8 +58,7 @@ FILE fqName:<root> fileName:/kt30020.kt
|
||||
$receiver: CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.collections.MutableList<kotlin.Any> origin=EXCLEXCL
|
||||
<T0>: kotlin.collections.MutableList<kotlin.Any>
|
||||
arg0: CALL 'public abstract fun f (): kotlin.collections.MutableList<kotlin.Any> declared in <root>.X' type=kotlin.collections.MutableList<kotlin.Any>? origin=null
|
||||
$this: TYPE_OP type=<root>.X origin=IMPLICIT_CAST typeOperand=<root>.X
|
||||
GET_VAR 'nx: <root>.X? declared in <root>.test' type=<root>.X? origin=null
|
||||
$this: GET_VAR 'nx: <root>.X? declared in <root>.test' type=<root>.X? origin=null
|
||||
element: CONST Int type=kotlin.Int value=6
|
||||
FUN name:testExtensionReceiver visibility:public modality:FINAL <> ($receiver:kotlin.collections.MutableList<kotlin.Any>) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:<this> type:kotlin.collections.MutableList<kotlin.Any>
|
||||
|
||||
+4
-2
@@ -53,7 +53,9 @@ FILE fqName:<root> fileName:/smartCastsWithDestructuring.kt
|
||||
GET_VAR 'x: <root>.I1 declared in <root>.test' type=<root>.I1 origin=null
|
||||
VAR name:c1 type:kotlin.Int [val]
|
||||
CALL 'public final fun component1 (): kotlin.Int [operator] declared in <root>' type=kotlin.Int origin=null
|
||||
$receiver: GET_VAR 'val tmp_0: <root>.I2 [val] declared in <root>.test' type=<root>.I2 origin=null
|
||||
$receiver: TYPE_OP type=<root>.I1 origin=IMPLICIT_CAST typeOperand=<root>.I1
|
||||
GET_VAR 'val tmp_0: <root>.I2 [val] declared in <root>.test' type=<root>.I2 origin=null
|
||||
VAR name:c2 type:kotlin.String [val]
|
||||
CALL 'public final fun component2 (): kotlin.String [operator] declared in <root>' type=kotlin.String origin=null
|
||||
$receiver: GET_VAR 'val tmp_0: <root>.I2 [val] declared in <root>.test' type=<root>.I2 origin=null
|
||||
$receiver: TYPE_OP type=<root>.I1 origin=IMPLICIT_CAST typeOperand=<root>.I1
|
||||
GET_VAR 'val tmp_0: <root>.I2 [val] declared in <root>.test' type=<root>.I2 origin=null
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ FILE fqName:<root> fileName:/fixationOrder1.kt
|
||||
CLASS INTERFACE name:Inv2 modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Inv2<A of <root>.Inv2, B of <root>.Inv2>
|
||||
TYPE_PARAMETER name:A index:0 variance: superTypes:[kotlin.Any?]
|
||||
TYPE_PARAMETER name:B index:0 variance: superTypes:[kotlin.Any?]
|
||||
TYPE_PARAMETER name:B index:1 variance: 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
|
||||
|
||||
Vendored
+1
-1
@@ -61,7 +61,7 @@ FILE fqName:<root> fileName:/enhancedNullabilityInDestructuringAssignment.kt
|
||||
CLASS CLASS name:Q modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Q<T1 of <root>.Q, T2 of <root>.Q>
|
||||
TYPE_PARAMETER name:T1 index:0 variance: superTypes:[kotlin.Any?]
|
||||
TYPE_PARAMETER name:T2 index:0 variance: superTypes:[kotlin.Any?]
|
||||
TYPE_PARAMETER name:T2 index:1 variance: superTypes:[kotlin.Any?]
|
||||
CONSTRUCTOR visibility:public <> (x:T1 of <root>.Q, y:T2 of <root>.Q) returnType:<root>.Q<T1 of <root>.Q, T2 of <root>.Q> [primary]
|
||||
VALUE_PARAMETER name:x index:0 type:T1 of <root>.Q
|
||||
VALUE_PARAMETER name:y index:1 type:T2 of <root>.Q
|
||||
|
||||
@@ -172,7 +172,7 @@ FILE fqName:<root> fileName:/smartCastOnFakeOverrideReceiver.kt
|
||||
CLASS CLASS name:GB modality:FINAL visibility:public superTypes:[<root>.GA<T of <root>.GB>]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.GB<T of <root>.GB, S of <root>.GB>
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||
TYPE_PARAMETER name:S index:0 variance: superTypes:[kotlin.Any?]
|
||||
TYPE_PARAMETER name:S index:1 variance: superTypes:[kotlin.Any?]
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.GB<T of <root>.GB, S of <root>.GB> [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.GA'
|
||||
|
||||
Reference in New Issue
Block a user