[FIR2IR] Use overridden symbol when handling delegating constructor call

This commit is contained in:
Mikhail Glukhikh
2020-06-24 10:40:05 +03:00
parent 456508a332
commit 2cffbadbd5
2 changed files with 6 additions and 4 deletions
@@ -246,23 +246,25 @@ internal class ClassMemberGenerator(
private fun FirDelegatedConstructorCall.toIrDelegatingConstructorCall(): IrExpression {
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 ->
IrErrorCallExpressionImpl(
startOffset, endOffset, constructedIrType, "Cannot find delegated constructor call"
)
}
val constructorSymbol = referencedSymbol.deepestMatchingOverriddenSymbol() as FirConstructorSymbol
val firDispatchReceiver = dispatchReceiver
return convertWithOffsets { startOffset, endOffset ->
val irConstructorSymbol = declarationStorage.getIrFunctionSymbol(constructorSymbol) as IrConstructorSymbol
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(
startOffset, endOffset,
constructedIrType,
irConstructorSymbol,
typeArgumentsCount = typeArguments?.size ?: 0,
valueArgumentsCount = constructorSymbol.fir.valueParameters.size
valueArgumentsCount = constructor.valueParameters.size
).apply {
}
} else {