FIR2IR: extract implicitCast function
This commit is contained in:
committed by
Space Team
parent
1ef0f9e944
commit
ba06af9d7f
@@ -840,3 +840,14 @@ context(Fir2IrComponents)
|
|||||||
internal fun FirClass.declaredScope(): FirContainingNamesAwareScope {
|
internal fun FirClass.declaredScope(): FirContainingNamesAwareScope {
|
||||||
return symbol.declaredScope()
|
return symbol.declaredScope()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun implicitCast(original: IrExpression, castType: IrType, typeOperator: IrTypeOperator): IrTypeOperatorCall {
|
||||||
|
return IrTypeOperatorCallImpl(
|
||||||
|
original.startOffset,
|
||||||
|
original.endOffset,
|
||||||
|
castType,
|
||||||
|
typeOperator,
|
||||||
|
castType,
|
||||||
|
original
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
+1
-8
@@ -329,14 +329,7 @@ class Fir2IrImplicitCastInserter(
|
|||||||
IrTypeOperator.IMPLICIT_CAST
|
IrTypeOperator.IMPLICIT_CAST
|
||||||
}
|
}
|
||||||
|
|
||||||
return IrTypeOperatorCallImpl(
|
return implicitCast(original, castType, typeOperator)
|
||||||
original.startOffset,
|
|
||||||
original.endOffset,
|
|
||||||
castType,
|
|
||||||
typeOperator,
|
|
||||||
castType,
|
|
||||||
original
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun coerceToUnitIfNeeded(original: IrExpression, irBuiltIns: IrBuiltIns): IrExpression {
|
internal fun coerceToUnitIfNeeded(original: IrExpression, irBuiltIns: IrBuiltIns): IrExpression {
|
||||||
|
|||||||
+3
-6
@@ -1276,13 +1276,10 @@ class CallAndReferenceGenerator(
|
|||||||
// NB: for FE 1.0, this type cast is added by InterfaceObjectCallsLowering
|
// NB: for FE 1.0, this type cast is added by InterfaceObjectCallsLowering
|
||||||
// However, it doesn't work for FIR due to different f/o structure
|
// However, it doesn't work for FIR due to different f/o structure
|
||||||
// (FIR calls Any method directly, but FE 1.0 calls its interface f/o instead)
|
// (FIR calls Any method directly, but FE 1.0 calls its interface f/o instead)
|
||||||
IrTypeOperatorCallImpl(
|
implicitCast(
|
||||||
baseDispatchReceiver.startOffset,
|
baseDispatchReceiver,
|
||||||
baseDispatchReceiver.endOffset,
|
|
||||||
irBuiltIns.anyType,
|
irBuiltIns.anyType,
|
||||||
IrTypeOperator.IMPLICIT_CAST,
|
IrTypeOperator.IMPLICIT_CAST
|
||||||
irBuiltIns.anyType,
|
|
||||||
baseDispatchReceiver
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user