[FIR2IR] Use overridden symbol when handling delegating constructor call
This commit is contained in:
+5
-3
@@ -246,23 +246,25 @@ internal class ClassMemberGenerator(
|
|||||||
|
|
||||||
private fun FirDelegatedConstructorCall.toIrDelegatingConstructorCall(): IrExpression {
|
private fun FirDelegatedConstructorCall.toIrDelegatingConstructorCall(): IrExpression {
|
||||||
val constructedIrType = constructedTypeRef.toIrType()
|
val constructedIrType = constructedTypeRef.toIrType()
|
||||||
val constructorSymbol = (this.calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirConstructorSymbol
|
val referencedSymbol = (this.calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirConstructorSymbol
|
||||||
?: return convertWithOffsets { startOffset, endOffset ->
|
?: return convertWithOffsets { startOffset, endOffset ->
|
||||||
IrErrorCallExpressionImpl(
|
IrErrorCallExpressionImpl(
|
||||||
startOffset, endOffset, constructedIrType, "Cannot find delegated constructor call"
|
startOffset, endOffset, constructedIrType, "Cannot find delegated constructor call"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
val constructorSymbol = referencedSymbol.deepestMatchingOverriddenSymbol() as FirConstructorSymbol
|
||||||
val firDispatchReceiver = dispatchReceiver
|
val firDispatchReceiver = dispatchReceiver
|
||||||
return convertWithOffsets { startOffset, endOffset ->
|
return convertWithOffsets { startOffset, endOffset ->
|
||||||
val irConstructorSymbol = declarationStorage.getIrFunctionSymbol(constructorSymbol) as IrConstructorSymbol
|
val irConstructorSymbol = declarationStorage.getIrFunctionSymbol(constructorSymbol) as IrConstructorSymbol
|
||||||
val typeArguments = (constructedTypeRef as? FirResolvedTypeRef)?.type?.typeArguments
|
val typeArguments = (constructedTypeRef as? FirResolvedTypeRef)?.type?.typeArguments
|
||||||
if (constructorSymbol.fir.isFromEnumClass || constructorSymbol.fir.returnTypeRef.isEnum) {
|
val constructor = constructorSymbol.fir
|
||||||
|
if (constructor.isFromEnumClass || constructor.returnTypeRef.isEnum) {
|
||||||
IrEnumConstructorCallImpl(
|
IrEnumConstructorCallImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
constructedIrType,
|
constructedIrType,
|
||||||
irConstructorSymbol,
|
irConstructorSymbol,
|
||||||
typeArgumentsCount = typeArguments?.size ?: 0,
|
typeArgumentsCount = typeArguments?.size ?: 0,
|
||||||
valueArgumentsCount = constructorSymbol.fir.valueParameters.size
|
valueArgumentsCount = constructor.valueParameters.size
|
||||||
).apply {
|
).apply {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ FILE fqName:<root> fileName:/thisOfGenericOuterClass.kt
|
|||||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.test.<no name provided>
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.test.<no name provided>
|
||||||
CONSTRUCTOR visibility:private <> () returnType:<root>.test.<no name provided> [primary]
|
CONSTRUCTOR visibility:private <> () returnType:<root>.test.<no name provided> [primary]
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (y: kotlin.Int) declared in <root>.Outer.Inner'
|
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (y: kotlin.Int) [primary] declared in <root>.Outer.Inner'
|
||||||
<1>: kotlin.Int
|
<1>: kotlin.Int
|
||||||
$this: GET_VAR '<this>: <root>.Outer<kotlin.Int> declared in <root>.test' type=<root>.Outer<kotlin.Int> origin=null
|
$this: GET_VAR '<this>: <root>.Outer<kotlin.Int> declared in <root>.test' type=<root>.Outer<kotlin.Int> origin=null
|
||||||
y: CONST Int type=kotlin.Int value=42
|
y: CONST Int type=kotlin.Int value=42
|
||||||
|
|||||||
Reference in New Issue
Block a user