[FIR2IR] Replace FirExpression.typeRef.toIrType with coneType.toIrType
#KT-59855
This commit is contained in:
committed by
Space Team
parent
9ec814b7ad
commit
e50025f21f
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
|||||||
import org.jetbrains.kotlin.fir.symbols.Fir2IrConstructorSymbol
|
import org.jetbrains.kotlin.fir.symbols.Fir2IrConstructorSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.Fir2IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.fir.symbols.Fir2IrSimpleFunctionSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.lazyDeclarationResolver
|
import org.jetbrains.kotlin.fir.symbols.lazyDeclarationResolver
|
||||||
|
import org.jetbrains.kotlin.fir.types.coneTypeOrNull
|
||||||
import org.jetbrains.kotlin.ir.PsiIrFileEntry
|
import org.jetbrains.kotlin.ir.PsiIrFileEntry
|
||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
@@ -274,7 +275,7 @@ class Fir2IrConverter(
|
|||||||
|
|
||||||
val irFragmentFunction = symbolTable.declareSimpleFunction(signature, { Fir2IrSimpleFunctionSymbol(signature) }) { irSymbol ->
|
val irFragmentFunction = symbolTable.declareSimpleFunction(signature, { Fir2IrSimpleFunctionSymbol(signature) }) { irSymbol ->
|
||||||
val lastStatement = codeFragment.block.statements.lastOrNull()
|
val lastStatement = codeFragment.block.statements.lastOrNull()
|
||||||
val returnType = (lastStatement as? FirExpression)?.typeRef?.toIrType(typeConverter) ?: irBuiltIns.unitType
|
val returnType = (lastStatement as? FirExpression)?.coneTypeOrNull?.toIrType(typeConverter) ?: irBuiltIns.unitType
|
||||||
|
|
||||||
irFactory.createSimpleFunction(
|
irFactory.createSimpleFunction(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||||
|
|||||||
+10
-10
@@ -933,7 +933,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
firInitializerExpression: FirExpression?,
|
firInitializerExpression: FirExpression?,
|
||||||
type: IrType? = null
|
type: IrType? = null
|
||||||
): IrField = convertCatching(property) {
|
): IrField = convertCatching(property) {
|
||||||
val inferredType = type ?: firInitializerExpression!!.typeRef.toIrType()
|
val inferredType = type ?: firInitializerExpression!!.coneType.toIrType()
|
||||||
return declareIrField { symbol ->
|
return declareIrField { symbol ->
|
||||||
irFactory.createField(
|
irFactory.createField(
|
||||||
startOffset = startOffset,
|
startOffset = startOffset,
|
||||||
@@ -1101,7 +1101,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
property.name, property.isVal, initializer, typeToUse
|
property.name, property.isVal, initializer, typeToUse
|
||||||
).also { field ->
|
).also { field ->
|
||||||
if (initializer is FirConstExpression<*>) {
|
if (initializer is FirConstExpression<*>) {
|
||||||
val constType = initializer.typeRef.toIrType()
|
val constType = initializer.coneType.toIrType()
|
||||||
field.initializer = factory.createExpressionBody(initializer.toIrConst(constType))
|
field.initializer = factory.createExpressionBody(initializer.toIrConst(constType))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1291,7 +1291,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
return createIrField(
|
return createIrField(
|
||||||
field,
|
field,
|
||||||
irParent = irClass,
|
irParent = irClass,
|
||||||
typeRef = initializer?.typeRef ?: field.returnTypeRef,
|
type = initializer?.coneType ?: field.returnTypeRef.coneType,
|
||||||
origin = IrDeclarationOrigin.DELEGATE
|
origin = IrDeclarationOrigin.DELEGATE
|
||||||
).apply {
|
).apply {
|
||||||
metadata = FirMetadataSource.Field(field)
|
metadata = FirMetadataSource.Field(field)
|
||||||
@@ -1301,10 +1301,10 @@ class Fir2IrDeclarationStorage(
|
|||||||
internal fun createIrField(
|
internal fun createIrField(
|
||||||
field: FirField,
|
field: FirField,
|
||||||
irParent: IrDeclarationParent?,
|
irParent: IrDeclarationParent?,
|
||||||
typeRef: FirTypeRef = field.returnTypeRef,
|
type: ConeKotlinType = field.returnTypeRef.coneType,
|
||||||
origin: IrDeclarationOrigin = IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB
|
origin: IrDeclarationOrigin = IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB
|
||||||
): IrField = convertCatching(field) {
|
): IrField = convertCatching(field) {
|
||||||
val type = typeRef.toIrType()
|
val irType = type.toIrType()
|
||||||
val classId = (irParent as? IrClass)?.classId
|
val classId = (irParent as? IrClass)?.classId
|
||||||
val containingClassLookupTag = classId?.toLookupTag()
|
val containingClassLookupTag = classId?.toLookupTag()
|
||||||
val signature = signatureComposer.composeSignature(field, containingClassLookupTag)
|
val signature = signatureComposer.composeSignature(field, containingClassLookupTag)
|
||||||
@@ -1320,7 +1320,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
name = field.name,
|
name = field.name,
|
||||||
visibility = components.visibilityConverter.convertToDescriptorVisibility(field.visibility),
|
visibility = components.visibilityConverter.convertToDescriptorVisibility(field.visibility),
|
||||||
symbol = symbol,
|
symbol = symbol,
|
||||||
type = type,
|
type = irType,
|
||||||
isFinal = field.modality == Modality.FINAL,
|
isFinal = field.modality == Modality.FINAL,
|
||||||
isStatic = field.isStatic,
|
isStatic = field.isStatic,
|
||||||
isExternal = false
|
isExternal = false
|
||||||
@@ -1334,7 +1334,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
name = field.name,
|
name = field.name,
|
||||||
visibility = components.visibilityConverter.convertToDescriptorVisibility(field.visibility),
|
visibility = components.visibilityConverter.convertToDescriptorVisibility(field.visibility),
|
||||||
symbol = IrFieldSymbolImpl(),
|
symbol = IrFieldSymbolImpl(),
|
||||||
type = type,
|
type = irType,
|
||||||
isFinal = field.modality == Modality.FINAL,
|
isFinal = field.modality == Modality.FINAL,
|
||||||
isStatic = field.isStatic,
|
isStatic = field.isStatic,
|
||||||
isExternal = false
|
isExternal = false
|
||||||
@@ -1349,7 +1349,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
}
|
}
|
||||||
val initializer = field.unwrapFakeOverrides().initializer
|
val initializer = field.unwrapFakeOverrides().initializer
|
||||||
if (initializer is FirConstExpression<*>) {
|
if (initializer is FirConstExpression<*>) {
|
||||||
this.initializer = factory.createExpressionBody(initializer.toIrConst(type))
|
this.initializer = factory.createExpressionBody(initializer.toIrConst(irType))
|
||||||
}
|
}
|
||||||
setAndModifyParent(irParent)
|
setAndModifyParent(irParent)
|
||||||
}
|
}
|
||||||
@@ -1467,7 +1467,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
// Note: for components call, we have to change type here (to original component type) to keep compatibility with PSI2IR
|
// Note: for components call, we have to change type here (to original component type) to keep compatibility with PSI2IR
|
||||||
// Some backend optimizations related to withIndex() probably depend on this type: index should always be Int
|
// Some backend optimizations related to withIndex() probably depend on this type: index should always be Int
|
||||||
// See e.g. forInStringWithIndexWithExplicitlyTypedIndexVariable.kt from codegen box tests
|
// See e.g. forInStringWithIndexWithExplicitlyTypedIndexVariable.kt from codegen box tests
|
||||||
val type = ((variable.initializer as? FirComponentCall)?.typeRef ?: variable.returnTypeRef).toIrType()
|
val type = ((variable.initializer as? FirComponentCall)?.coneType ?: variable.returnTypeRef.coneType).toIrType()
|
||||||
// Some temporary variables are produced in RawFirBuilder, but we consistently use special names for them.
|
// Some temporary variables are produced in RawFirBuilder, but we consistently use special names for them.
|
||||||
val origin = when {
|
val origin = when {
|
||||||
givenOrigin != null -> givenOrigin
|
givenOrigin != null -> givenOrigin
|
||||||
@@ -1509,7 +1509,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
enterScope(this)
|
enterScope(this)
|
||||||
delegate = declareIrVariable(
|
delegate = declareIrVariable(
|
||||||
startOffset, endOffset, IrDeclarationOrigin.PROPERTY_DELEGATE,
|
startOffset, endOffset, IrDeclarationOrigin.PROPERTY_DELEGATE,
|
||||||
NameUtils.propertyDelegateName(property.name), property.delegate!!.typeRef.toIrType(),
|
NameUtils.propertyDelegateName(property.name), property.delegate!!.coneType.toIrType(),
|
||||||
isVar = false, isConst = false, isLateinit = false
|
isVar = false, isConst = false, isLateinit = false
|
||||||
)
|
)
|
||||||
delegate.parent = irParent
|
delegate.parent = irParent
|
||||||
|
|||||||
+10
-10
@@ -185,7 +185,7 @@ class Fir2IrImplicitCastInserter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitThrowExpression(throwExpression: FirThrowExpression, data: IrElement): IrElement =
|
override fun visitThrowExpression(throwExpression: FirThrowExpression, data: IrElement): IrElement =
|
||||||
(data as IrThrow).cast(throwExpression, throwExpression.exception.typeRef, throwExpression.typeRef)
|
(data as IrThrow).cast(throwExpression, throwExpression.exception.coneType, throwExpression.coneType)
|
||||||
|
|
||||||
override fun visitBlock(block: FirBlock, data: IrElement): IrElement =
|
override fun visitBlock(block: FirBlock, data: IrElement): IrElement =
|
||||||
(data as? IrContainerExpression)?.insertImplicitCasts() ?: data
|
(data as? IrContainerExpression)?.insertImplicitCasts() ?: data
|
||||||
@@ -193,13 +193,13 @@ class Fir2IrImplicitCastInserter(
|
|||||||
override fun visitReturnExpression(returnExpression: FirReturnExpression, data: IrElement): IrElement {
|
override fun visitReturnExpression(returnExpression: FirReturnExpression, data: IrElement): IrElement {
|
||||||
val irReturn = data as? IrReturn ?: return data
|
val irReturn = data as? IrReturn ?: return data
|
||||||
val expectedType = returnExpression.target.labeledElement.returnTypeRef
|
val expectedType = returnExpression.target.labeledElement.returnTypeRef
|
||||||
irReturn.value = irReturn.value.cast(returnExpression.result, returnExpression.result.typeRef, expectedType)
|
irReturn.value = irReturn.value.cast(returnExpression.result, returnExpression.result.coneType, expectedType.coneType)
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================================================================================
|
// ==================================================================================
|
||||||
|
|
||||||
internal fun IrExpression.cast(expression: FirExpression, valueTypeRef: FirTypeRef, expectedTypeRef: FirTypeRef): IrExpression {
|
internal fun IrExpression.cast(expression: FirExpression, valueTypeRef: ConeKotlinType, expectedTypeRef: ConeKotlinType): IrExpression {
|
||||||
if (this is IrTypeOperatorCall) {
|
if (this is IrTypeOperatorCall) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
@@ -208,8 +208,8 @@ class Fir2IrImplicitCastInserter(
|
|||||||
insertImplicitCasts()
|
insertImplicitCasts()
|
||||||
}
|
}
|
||||||
|
|
||||||
val valueType = valueTypeRef.coneType.fullyExpandedType(session)
|
val valueType = valueTypeRef.fullyExpandedType(session)
|
||||||
val expectedType = expectedTypeRef.coneType.fullyExpandedType(session)
|
val expectedType = expectedTypeRef.fullyExpandedType(session)
|
||||||
|
|
||||||
return when {
|
return when {
|
||||||
expectedType.isUnit -> {
|
expectedType.isUnit -> {
|
||||||
@@ -273,7 +273,7 @@ class Fir2IrImplicitCastInserter(
|
|||||||
override fun visitSmartCastExpression(smartCastExpression: FirSmartCastExpression, data: IrElement): IrElement {
|
override fun visitSmartCastExpression(smartCastExpression: FirSmartCastExpression, data: IrElement): IrElement {
|
||||||
// We don't want an implicit cast to Nothing?. This expression just encompasses nullability after null check.
|
// We don't want an implicit cast to Nothing?. This expression just encompasses nullability after null check.
|
||||||
return if (smartCastExpression.isStable && smartCastExpression.smartcastTypeWithoutNullableNothing == null) {
|
return if (smartCastExpression.isStable && smartCastExpression.smartcastTypeWithoutNullableNothing == null) {
|
||||||
implicitCastOrExpression(data as IrExpression, smartCastExpression.typeRef)
|
implicitCastOrExpression(data as IrExpression, smartCastExpression.coneType)
|
||||||
} else {
|
} else {
|
||||||
data as IrExpression
|
data as IrExpression
|
||||||
}
|
}
|
||||||
@@ -281,7 +281,7 @@ class Fir2IrImplicitCastInserter(
|
|||||||
|
|
||||||
internal fun implicitCastFromDispatchReceiver(
|
internal fun implicitCastFromDispatchReceiver(
|
||||||
original: IrExpression,
|
original: IrExpression,
|
||||||
originalTypeRef: FirTypeRef,
|
coneKotlinType: ConeKotlinType,
|
||||||
calleeReference: FirReference?,
|
calleeReference: FirReference?,
|
||||||
typeOrigin: ConversionTypeOrigin,
|
typeOrigin: ConversionTypeOrigin,
|
||||||
): IrExpression {
|
): IrExpression {
|
||||||
@@ -289,18 +289,18 @@ class Fir2IrImplicitCastInserter(
|
|||||||
|
|
||||||
val dispatchReceiverType =
|
val dispatchReceiverType =
|
||||||
referencedDeclaration?.dispatchReceiverType as? ConeClassLikeType
|
referencedDeclaration?.dispatchReceiverType as? ConeClassLikeType
|
||||||
?: return implicitCastOrExpression(original, originalTypeRef)
|
?: return implicitCastOrExpression(original, coneKotlinType)
|
||||||
|
|
||||||
val starProjectedDispatchReceiver = dispatchReceiverType.replaceArgumentsWithStarProjections()
|
val starProjectedDispatchReceiver = dispatchReceiverType.replaceArgumentsWithStarProjections()
|
||||||
|
|
||||||
val castType = originalTypeRef.coneTypeSafe<ConeIntersectionType>()
|
val castType = coneKotlinType as? ConeIntersectionType
|
||||||
castType?.intersectedTypes?.forEach { componentType ->
|
castType?.intersectedTypes?.forEach { componentType ->
|
||||||
if (AbstractTypeChecker.isSubtypeOf(session.typeContext, componentType, starProjectedDispatchReceiver)) {
|
if (AbstractTypeChecker.isSubtypeOf(session.typeContext, componentType, starProjectedDispatchReceiver)) {
|
||||||
return implicitCastOrExpression(original, componentType, typeOrigin)
|
return implicitCastOrExpression(original, componentType, typeOrigin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return implicitCastOrExpression(original, originalTypeRef, typeOrigin)
|
return implicitCastOrExpression(original, coneKotlinType, typeOrigin)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun implicitCastOrExpression(
|
private fun implicitCastOrExpression(
|
||||||
|
|||||||
@@ -336,3 +336,11 @@ fun FirTypeRef.toIrType(
|
|||||||
with(typeConverter) {
|
with(typeConverter) {
|
||||||
toIrType(typeOrigin)
|
toIrType(typeOrigin)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun ConeKotlinType.toIrType(
|
||||||
|
typeConverter: Fir2IrTypeConverter,
|
||||||
|
typeOrigin: ConversionTypeOrigin = ConversionTypeOrigin.DEFAULT
|
||||||
|
): IrType =
|
||||||
|
with(typeConverter) {
|
||||||
|
toIrType(typeOrigin)
|
||||||
|
}
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ class Fir2IrVisitor(
|
|||||||
get() = _annotationMode
|
get() = _annotationMode
|
||||||
|
|
||||||
private fun FirTypeRef.toIrType(): IrType = with(typeConverter) { toIrType() }
|
private fun FirTypeRef.toIrType(): IrType = with(typeConverter) { toIrType() }
|
||||||
|
private fun ConeKotlinType.toIrType(): IrType = with(typeConverter) { toIrType() }
|
||||||
|
|
||||||
private fun <T : IrDeclaration> applyParentFromStackTo(declaration: T): T = conversionScope.applyParentFromStackTo(declaration)
|
private fun <T : IrDeclaration> applyParentFromStackTo(declaration: T): T = conversionScope.applyParentFromStackTo(declaration)
|
||||||
|
|
||||||
@@ -468,7 +469,7 @@ class Fir2IrVisitor(
|
|||||||
if (initializer != null) {
|
if (initializer != null) {
|
||||||
irVariable.initializer =
|
irVariable.initializer =
|
||||||
convertToIrExpression(initializer)
|
convertToIrExpression(initializer)
|
||||||
.insertImplicitCast(initializer, initializer.typeRef, variable.returnTypeRef)
|
.insertImplicitCast(initializer, initializer.coneType, variable.returnTypeRef.coneType)
|
||||||
}
|
}
|
||||||
annotationGenerator.generate(irVariable, variable)
|
annotationGenerator.generate(irVariable, variable)
|
||||||
return irVariable
|
return irVariable
|
||||||
@@ -476,8 +477,8 @@ class Fir2IrVisitor(
|
|||||||
|
|
||||||
private fun IrExpression.insertImplicitCast(
|
private fun IrExpression.insertImplicitCast(
|
||||||
baseExpression: FirExpression,
|
baseExpression: FirExpression,
|
||||||
valueType: FirTypeRef,
|
valueType: ConeKotlinType,
|
||||||
expectedType: FirTypeRef
|
expectedType: ConeKotlinType,
|
||||||
) =
|
) =
|
||||||
with(implicitCastInserter) {
|
with(implicitCastInserter) {
|
||||||
this@insertImplicitCast.cast(baseExpression, valueType, expectedType)
|
this@insertImplicitCast.cast(baseExpression, valueType, expectedType)
|
||||||
@@ -532,7 +533,7 @@ class Fir2IrVisitor(
|
|||||||
IrVarargImpl(
|
IrVarargImpl(
|
||||||
startOffset,
|
startOffset,
|
||||||
endOffset,
|
endOffset,
|
||||||
varargArgumentsExpression.typeRef.toIrType(),
|
varargArgumentsExpression.coneType.toIrType(),
|
||||||
varargArgumentsExpression.varargElementType.toIrType(),
|
varargArgumentsExpression.varargElementType.toIrType(),
|
||||||
varargArgumentsExpression.arguments.map { it.convertToIrVarargElement() }
|
varargArgumentsExpression.arguments.map { it.convertToIrVarargElement() }
|
||||||
)
|
)
|
||||||
@@ -565,7 +566,7 @@ class Fir2IrVisitor(
|
|||||||
val explicitReceiverExpression = convertToIrReceiverExpression(functionCall.explicitReceiver, functionCall.calleeReference)
|
val explicitReceiverExpression = convertToIrReceiverExpression(functionCall.explicitReceiver, functionCall.calleeReference)
|
||||||
return callGenerator.convertToIrCall(
|
return callGenerator.convertToIrCall(
|
||||||
functionCall,
|
functionCall,
|
||||||
functionCall.typeRef,
|
functionCall.coneType,
|
||||||
explicitReceiverExpression,
|
explicitReceiverExpression,
|
||||||
dynamicOperator
|
dynamicOperator
|
||||||
)
|
)
|
||||||
@@ -579,7 +580,7 @@ class Fir2IrVisitor(
|
|||||||
explicitReceiverExpression.arguments.removeLast()
|
explicitReceiverExpression.arguments.removeLast()
|
||||||
}
|
}
|
||||||
val result = callGenerator.convertToIrCall(
|
val result = callGenerator.convertToIrCall(
|
||||||
functionCall, functionCall.typeRef, explicitReceiverExpression,
|
functionCall, functionCall.coneType, explicitReceiverExpression,
|
||||||
dynamicOperator = IrDynamicOperator.EQ
|
dynamicOperator = IrDynamicOperator.EQ
|
||||||
)
|
)
|
||||||
if (result is IrDynamicOperatorExpression) {
|
if (result is IrDynamicOperatorExpression) {
|
||||||
@@ -645,7 +646,7 @@ class Fir2IrVisitor(
|
|||||||
qualifiedAccessExpression.explicitReceiver, qualifiedAccessExpression.calleeReference
|
qualifiedAccessExpression.explicitReceiver, qualifiedAccessExpression.calleeReference
|
||||||
)
|
)
|
||||||
return callGenerator.convertToIrCall(
|
return callGenerator.convertToIrCall(
|
||||||
qualifiedAccessExpression, qualifiedAccessExpression.typeRef, explicitReceiverExpression
|
qualifiedAccessExpression, qualifiedAccessExpression.coneType, explicitReceiverExpression
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -713,7 +714,7 @@ class Fir2IrVisitor(
|
|||||||
|
|
||||||
IrGetFieldImpl(
|
IrGetFieldImpl(
|
||||||
startOffset, endOffset, contextReceivers[calleeReference.contextReceiverNumber].symbol,
|
startOffset, endOffset, contextReceivers[calleeReference.contextReceiverNumber].symbol,
|
||||||
thisReceiverExpression.typeRef.toIrType(),
|
thisReceiverExpression.coneType.toIrType(),
|
||||||
thisRef,
|
thisRef,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -770,7 +771,7 @@ class Fir2IrVisitor(
|
|||||||
return inaccessibleReceiverExpression.convertWithOffsets { startOffset, endOffset ->
|
return inaccessibleReceiverExpression.convertWithOffsets { startOffset, endOffset ->
|
||||||
IrErrorExpressionImpl(
|
IrErrorExpressionImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
inaccessibleReceiverExpression.typeRef.toIrType(),
|
inaccessibleReceiverExpression.coneType.toIrType(),
|
||||||
"Receiver is inaccessible"
|
"Receiver is inaccessible"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -817,7 +818,7 @@ class Fir2IrVisitor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun <T> visitConstExpression(constExpression: FirConstExpression<T>, data: Any?): IrElement {
|
override fun <T> visitConstExpression(constExpression: FirConstExpression<T>, data: Any?): IrElement {
|
||||||
return constExpression.toIrConst(constExpression.typeRef.toIrType())
|
return constExpression.toIrConst(constExpression.coneType.toIrType())
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================================================================================
|
// ==================================================================================
|
||||||
@@ -872,7 +873,7 @@ class Fir2IrVisitor(
|
|||||||
calleeReference.name != OperatorNameConventions.INVOKE &&
|
calleeReference.name != OperatorNameConventions.INVOKE &&
|
||||||
(calleeReference.resolvedSymbol as? FirCallableSymbol)?.callableId?.callableName == OperatorNameConventions.INVOKE
|
(calleeReference.resolvedSymbol as? FirCallableSymbol)?.callableId?.callableName == OperatorNameConventions.INVOKE
|
||||||
callGenerator.convertToIrCall(
|
callGenerator.convertToIrCall(
|
||||||
expression, expression.typeRef, explicitReceiverExpression = null,
|
expression, expression.coneType, explicitReceiverExpression = null,
|
||||||
variableAsFunctionMode = variableAsFunctionMode
|
variableAsFunctionMode = variableAsFunctionMode
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@@ -882,7 +883,7 @@ class Fir2IrVisitor(
|
|||||||
if (expression is FirQualifiedAccessExpression && expression.calleeReference is FirSuperReference) return@run this
|
if (expression is FirQualifiedAccessExpression && expression.calleeReference is FirSuperReference) return@run this
|
||||||
|
|
||||||
implicitCastInserter.implicitCastFromDispatchReceiver(
|
implicitCastInserter.implicitCastFromDispatchReceiver(
|
||||||
this, expression.typeRef, calleeReference,
|
this, expression.coneType, calleeReference,
|
||||||
conversionScope.defaultConversionTypeOrigin()
|
conversionScope.defaultConversionTypeOrigin()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -990,7 +991,7 @@ class Fir2IrVisitor(
|
|||||||
val arrayAccess = operationReceiver as? FirFunctionCall ?: return null
|
val arrayAccess = operationReceiver as? FirFunctionCall ?: return null
|
||||||
val originalVararg = arrayAccess.resolvedArgumentMapping?.keys?.filterIsInstance<FirVarargArgumentsExpression>()?.firstOrNull()
|
val originalVararg = arrayAccess.resolvedArgumentMapping?.keys?.filterIsInstance<FirVarargArgumentsExpression>()?.firstOrNull()
|
||||||
(callGenerator.convertToIrCall(
|
(callGenerator.convertToIrCall(
|
||||||
arrayAccess, arrayAccess.typeRef,
|
arrayAccess, arrayAccess.coneType,
|
||||||
convertToIrReceiverExpression(receiverValue, arrayAccess.calleeReference),
|
convertToIrReceiverExpression(receiverValue, arrayAccess.calleeReference),
|
||||||
noArguments = true
|
noArguments = true
|
||||||
) as IrDynamicOperatorExpression).apply {
|
) as IrDynamicOperatorExpression).apply {
|
||||||
@@ -1009,12 +1010,12 @@ class Fir2IrVisitor(
|
|||||||
}
|
}
|
||||||
callGenerator.convertToIrCall(
|
callGenerator.convertToIrCall(
|
||||||
qualifiedAccess,
|
qualifiedAccess,
|
||||||
qualifiedAccess.typeRef,
|
qualifiedAccess.coneType,
|
||||||
convertToIrReceiverExpression(receiverExpression, qualifiedAccess.calleeReference),
|
convertToIrReceiverExpression(receiverExpression, qualifiedAccess.calleeReference),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return callGenerator.convertToIrCall(
|
return callGenerator.convertToIrCall(
|
||||||
operationCall, operationCall.typeRef, explicitReceiverExpression
|
operationCall, operationCall.coneType, explicitReceiverExpression
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1054,7 +1055,7 @@ class Fir2IrVisitor(
|
|||||||
val type = if (forceUnitType)
|
val type = if (forceUnitType)
|
||||||
irBuiltIns.unitType
|
irBuiltIns.unitType
|
||||||
else
|
else
|
||||||
(lastOrNull() as? FirExpression)?.typeRef?.toIrType() ?: irBuiltIns.unitType
|
(lastOrNull() as? FirExpression)?.coneType?.toIrType() ?: irBuiltIns.unitType
|
||||||
return source.convertWithOffsets { startOffset, endOffset ->
|
return source.convertWithOffsets { startOffset, endOffset ->
|
||||||
if (origin == IrStatementOrigin.DO_WHILE_LOOP) {
|
if (origin == IrStatementOrigin.DO_WHILE_LOOP) {
|
||||||
IrCompositeImpl(
|
IrCompositeImpl(
|
||||||
@@ -1079,7 +1080,7 @@ class Fir2IrVisitor(
|
|||||||
return errorExpression.convertWithOffsets { startOffset, endOffset ->
|
return errorExpression.convertWithOffsets { startOffset, endOffset ->
|
||||||
IrErrorExpressionImpl(
|
IrErrorExpressionImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
errorExpression.typeRef.toIrType(),
|
errorExpression.coneType.toIrType(),
|
||||||
errorExpression.diagnostic.reason
|
errorExpression.diagnostic.reason
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1122,7 +1123,7 @@ class Fir2IrVisitor(
|
|||||||
IrConstImpl.constNull(startOffset, endOffset, irBuiltIns.nothingNType)
|
IrConstImpl.constNull(startOffset, endOffset, irBuiltIns.nothingNType)
|
||||||
),
|
),
|
||||||
convertToIrExpression(elvisExpression.rhs)
|
convertToIrExpression(elvisExpression.rhs)
|
||||||
.insertImplicitCast(elvisExpression, elvisExpression.rhs.typeRef, elvisExpression.typeRef)
|
.insertImplicitCast(elvisExpression, elvisExpression.rhs.coneType, elvisExpression.coneType)
|
||||||
),
|
),
|
||||||
IrElseBranchImpl(
|
IrElseBranchImpl(
|
||||||
IrConstImpl.boolean(startOffset, endOffset, irBuiltIns.booleanType, true),
|
IrConstImpl.boolean(startOffset, endOffset, irBuiltIns.booleanType, true),
|
||||||
@@ -1140,7 +1141,7 @@ class Fir2IrVisitor(
|
|||||||
generateWhen(
|
generateWhen(
|
||||||
startOffset, endOffset, IrStatementOrigin.ELVIS,
|
startOffset, endOffset, IrStatementOrigin.ELVIS,
|
||||||
irLhsVariable, irBranches,
|
irLhsVariable, irBranches,
|
||||||
elvisExpression.typeRef.toIrType()
|
elvisExpression.coneType.toIrType()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1166,7 +1167,7 @@ class Fir2IrVisitor(
|
|||||||
val whenExpressionType =
|
val whenExpressionType =
|
||||||
if (whenExpression.isProperlyExhaustive && whenExpression.branches.none {
|
if (whenExpression.isProperlyExhaustive && whenExpression.branches.none {
|
||||||
it.condition is FirElseIfTrueCondition && it.result.statements.isEmpty()
|
it.condition is FirElseIfTrueCondition && it.result.statements.isEmpty()
|
||||||
}) whenExpression.typeRef else session.builtinTypes.unitType
|
}) whenExpression.coneType else session.builtinTypes.unitType.type
|
||||||
val irBranches = whenExpression.branches.mapTo(mutableListOf()) { branch ->
|
val irBranches = whenExpression.branches.mapTo(mutableListOf()) { branch ->
|
||||||
branch.toIrWhenBranch(whenExpressionType)
|
branch.toIrWhenBranch(whenExpressionType)
|
||||||
}
|
}
|
||||||
@@ -1217,10 +1218,10 @@ class Fir2IrVisitor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun FirWhenBranch.toIrWhenBranch(whenExpressionType: FirTypeRef): IrBranch {
|
private fun FirWhenBranch.toIrWhenBranch(whenExpressionType: ConeKotlinType): IrBranch {
|
||||||
return convertWithOffsets { startOffset, endOffset ->
|
return convertWithOffsets { startOffset, endOffset ->
|
||||||
val condition = condition
|
val condition = condition
|
||||||
val irResult = convertToIrExpression(result).insertImplicitCast(result, result.typeRef, whenExpressionType)
|
val irResult = convertToIrExpression(result).insertImplicitCast(result, result.coneType, whenExpressionType)
|
||||||
if (condition is FirElseIfTrueCondition) {
|
if (condition is FirElseIfTrueCondition) {
|
||||||
IrElseBranchImpl(IrConstImpl.boolean(irResult.startOffset, irResult.endOffset, irBuiltIns.booleanType, true), irResult)
|
IrElseBranchImpl(IrConstImpl.boolean(irResult.startOffset, irResult.endOffset, irBuiltIns.booleanType, true), irResult)
|
||||||
} else {
|
} else {
|
||||||
@@ -1358,7 +1359,7 @@ class Fir2IrVisitor(
|
|||||||
// that line number for the finally block.
|
// that line number for the finally block.
|
||||||
return tryExpression.convertWithOffsets { startOffset, endOffset ->
|
return tryExpression.convertWithOffsets { startOffset, endOffset ->
|
||||||
IrTryImpl(
|
IrTryImpl(
|
||||||
startOffset, endOffset, tryExpression.typeRef.toIrType(),
|
startOffset, endOffset, tryExpression.coneType.toIrType(),
|
||||||
tryExpression.tryBlock.convertToIrBlock(forceUnitType = false),
|
tryExpression.tryBlock.convertToIrBlock(forceUnitType = false),
|
||||||
tryExpression.catches.map { it.accept(this, data) as IrCatch },
|
tryExpression.catches.map { it.accept(this, data) as IrCatch },
|
||||||
tryExpression.finallyBlock?.convertToIrBlock(forceUnitType = true)
|
tryExpression.finallyBlock?.convertToIrBlock(forceUnitType = true)
|
||||||
@@ -1442,13 +1443,13 @@ class Fir2IrVisitor(
|
|||||||
return checkNotNullCall.convertWithOffsets { startOffset, endOffset ->
|
return checkNotNullCall.convertWithOffsets { startOffset, endOffset ->
|
||||||
IrCallImpl(
|
IrCallImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
checkNotNullCall.typeRef.toIrType(),
|
checkNotNullCall.coneType.toIrType(),
|
||||||
irBuiltIns.checkNotNullSymbol,
|
irBuiltIns.checkNotNullSymbol,
|
||||||
typeArgumentsCount = 1,
|
typeArgumentsCount = 1,
|
||||||
valueArgumentsCount = 1,
|
valueArgumentsCount = 1,
|
||||||
origin = IrStatementOrigin.EXCLEXCL
|
origin = IrStatementOrigin.EXCLEXCL
|
||||||
).apply {
|
).apply {
|
||||||
putTypeArgument(0, checkNotNullCall.argument.typeRef.toIrType().makeNotNull())
|
putTypeArgument(0, checkNotNullCall.argument.coneType.toIrType().makeNotNull())
|
||||||
putValueArgument(0, convertToIrExpression(checkNotNullCall.argument))
|
putValueArgument(0, convertToIrExpression(checkNotNullCall.argument))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1456,12 +1457,12 @@ class Fir2IrVisitor(
|
|||||||
|
|
||||||
override fun visitGetClassCall(getClassCall: FirGetClassCall, data: Any?): IrElement = whileAnalysing(session, getClassCall) {
|
override fun visitGetClassCall(getClassCall: FirGetClassCall, data: Any?): IrElement = whileAnalysing(session, getClassCall) {
|
||||||
val argument = getClassCall.argument
|
val argument = getClassCall.argument
|
||||||
val irType = getClassCall.typeRef.toIrType()
|
val irType = getClassCall.coneType.toIrType()
|
||||||
val irClassType =
|
val irClassType =
|
||||||
if (argument is FirClassReferenceExpression) {
|
if (argument is FirClassReferenceExpression) {
|
||||||
argument.classTypeRef.toIrType()
|
argument.classTypeRef.toIrType()
|
||||||
} else {
|
} else {
|
||||||
argument.typeRef.toIrType()
|
argument.coneType.toIrType()
|
||||||
}
|
}
|
||||||
val irClassReferenceSymbol = when (argument) {
|
val irClassReferenceSymbol = when (argument) {
|
||||||
is FirResolvedReifiedParameterReference -> {
|
is FirResolvedReifiedParameterReference -> {
|
||||||
@@ -1509,7 +1510,7 @@ class Fir2IrVisitor(
|
|||||||
|
|
||||||
private fun convertToArrayLiteral(arrayLiteral: FirArrayLiteral): IrVararg {
|
private fun convertToArrayLiteral(arrayLiteral: FirArrayLiteral): IrVararg {
|
||||||
return arrayLiteral.convertWithOffsets { startOffset, endOffset ->
|
return arrayLiteral.convertWithOffsets { startOffset, endOffset ->
|
||||||
val arrayType = arrayLiteral.typeRef.toIrType()
|
val arrayType = arrayLiteral.coneType.toIrType()
|
||||||
val elementType = if (arrayLiteral.typeRef is FirResolvedTypeRef) {
|
val elementType = if (arrayLiteral.typeRef is FirResolvedTypeRef) {
|
||||||
arrayType.getArrayElementType(irBuiltIns)
|
arrayType.getArrayElementType(irBuiltIns)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+19
-19
@@ -368,7 +368,7 @@ class CallAndReferenceGenerator(
|
|||||||
@OptIn(IrSymbolInternals::class)
|
@OptIn(IrSymbolInternals::class)
|
||||||
fun convertToIrCall(
|
fun convertToIrCall(
|
||||||
qualifiedAccess: FirQualifiedAccessExpression,
|
qualifiedAccess: FirQualifiedAccessExpression,
|
||||||
typeRef: FirTypeRef,
|
type: ConeKotlinType,
|
||||||
explicitReceiverExpression: IrExpression?,
|
explicitReceiverExpression: IrExpression?,
|
||||||
dynamicOperator: IrDynamicOperator? = null,
|
dynamicOperator: IrDynamicOperator? = null,
|
||||||
variableAsFunctionMode: Boolean = false,
|
variableAsFunctionMode: Boolean = false,
|
||||||
@@ -377,8 +377,8 @@ class CallAndReferenceGenerator(
|
|||||||
try {
|
try {
|
||||||
injectGetValueCall(qualifiedAccess, qualifiedAccess.calleeReference)?.let { return it }
|
injectGetValueCall(qualifiedAccess, qualifiedAccess.calleeReference)?.let { return it }
|
||||||
|
|
||||||
val type = typeRef.toIrType()
|
val irType = type.toIrType()
|
||||||
val samConstructorCall = qualifiedAccess.tryConvertToSamConstructorCall(type)
|
val samConstructorCall = qualifiedAccess.tryConvertToSamConstructorCall(irType)
|
||||||
if (samConstructorCall != null) return samConstructorCall
|
if (samConstructorCall != null) return samConstructorCall
|
||||||
|
|
||||||
val dispatchReceiver = qualifiedAccess.dispatchReceiver
|
val dispatchReceiver = qualifiedAccess.dispatchReceiver
|
||||||
@@ -391,7 +391,7 @@ class CallAndReferenceGenerator(
|
|||||||
return convertToIrCallForDynamic(
|
return convertToIrCallForDynamic(
|
||||||
qualifiedAccess,
|
qualifiedAccess,
|
||||||
explicitReceiverExpression,
|
explicitReceiverExpression,
|
||||||
type,
|
irType,
|
||||||
calleeReference,
|
calleeReference,
|
||||||
firSymbol ?: error("Must have had a symbol"),
|
firSymbol ?: error("Must have had a symbol"),
|
||||||
dynamicOperator,
|
dynamicOperator,
|
||||||
@@ -431,7 +431,7 @@ class CallAndReferenceGenerator(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
when (symbol) {
|
when (symbol) {
|
||||||
is IrConstructorSymbol -> IrConstructorCallImpl.fromSymbolOwner(startOffset, endOffset, type, symbol)
|
is IrConstructorSymbol -> IrConstructorCallImpl.fromSymbolOwner(startOffset, endOffset, irType, symbol)
|
||||||
is IrSimpleFunctionSymbol -> {
|
is IrSimpleFunctionSymbol -> {
|
||||||
require(firSymbol is FirCallableSymbol<*>) { "Illegal symbol: ${firSymbol!!::class}" }
|
require(firSymbol is FirCallableSymbol<*>) { "Illegal symbol: ${firSymbol!!::class}" }
|
||||||
val valueParametersNumber = when (firSymbol) {
|
val valueParametersNumber = when (firSymbol) {
|
||||||
@@ -441,7 +441,7 @@ class CallAndReferenceGenerator(
|
|||||||
else -> error("Illegal symbol: ${firSymbol::class}")
|
else -> error("Illegal symbol: ${firSymbol::class}")
|
||||||
}
|
}
|
||||||
IrCallImpl(
|
IrCallImpl(
|
||||||
startOffset, endOffset, type, symbol,
|
startOffset, endOffset, irType, symbol,
|
||||||
typeArgumentsCount = firSymbol.typeParameterSymbols.size,
|
typeArgumentsCount = firSymbol.typeParameterSymbols.size,
|
||||||
valueArgumentsCount = valueParametersNumber,
|
valueArgumentsCount = valueParametersNumber,
|
||||||
origin = calleeReference.statementOrigin(),
|
origin = calleeReference.statementOrigin(),
|
||||||
@@ -451,7 +451,7 @@ class CallAndReferenceGenerator(
|
|||||||
|
|
||||||
is IrLocalDelegatedPropertySymbol -> {
|
is IrLocalDelegatedPropertySymbol -> {
|
||||||
IrCallImpl(
|
IrCallImpl(
|
||||||
startOffset, endOffset, type, symbol.owner.getter.symbol,
|
startOffset, endOffset, irType, symbol.owner.getter.symbol,
|
||||||
typeArgumentsCount = symbol.owner.getter.typeParameters.size,
|
typeArgumentsCount = symbol.owner.getter.typeParameters.size,
|
||||||
valueArgumentsCount = 0,
|
valueArgumentsCount = 0,
|
||||||
origin = IrStatementOrigin.GET_LOCAL_PROPERTY,
|
origin = IrStatementOrigin.GET_LOCAL_PROPERTY,
|
||||||
@@ -464,7 +464,7 @@ class CallAndReferenceGenerator(
|
|||||||
val backingField = symbol.owner.backingField
|
val backingField = symbol.owner.backingField
|
||||||
when {
|
when {
|
||||||
getter != null -> IrCallImpl(
|
getter != null -> IrCallImpl(
|
||||||
startOffset, endOffset, type, getter.symbol,
|
startOffset, endOffset, irType, getter.symbol,
|
||||||
typeArgumentsCount = getter.typeParameters.size,
|
typeArgumentsCount = getter.typeParameters.size,
|
||||||
valueArgumentsCount = getter.valueParameters.size,
|
valueArgumentsCount = getter.valueParameters.size,
|
||||||
origin = IrStatementOrigin.GET_PROPERTY,
|
origin = IrStatementOrigin.GET_PROPERTY,
|
||||||
@@ -472,12 +472,12 @@ class CallAndReferenceGenerator(
|
|||||||
)
|
)
|
||||||
|
|
||||||
backingField != null -> IrGetFieldImpl(
|
backingField != null -> IrGetFieldImpl(
|
||||||
startOffset, endOffset, backingField.symbol, type,
|
startOffset, endOffset, backingField.symbol, irType,
|
||||||
superQualifierSymbol = dispatchReceiver.superQualifierSymbol()
|
superQualifierSymbol = dispatchReceiver.superQualifierSymbol()
|
||||||
)
|
)
|
||||||
|
|
||||||
else -> IrErrorCallExpressionImpl(
|
else -> IrErrorCallExpressionImpl(
|
||||||
startOffset, endOffset, type,
|
startOffset, endOffset, irType,
|
||||||
description = "No getter or backing field found for ${calleeReference.render()}"
|
description = "No getter or backing field found for ${calleeReference.render()}"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -491,7 +491,7 @@ class CallAndReferenceGenerator(
|
|||||||
firConstExpression.toIrConst(returnType)
|
firConstExpression.toIrConst(returnType)
|
||||||
} else {
|
} else {
|
||||||
IrGetFieldImpl(
|
IrGetFieldImpl(
|
||||||
startOffset, endOffset, symbol, type,
|
startOffset, endOffset, symbol, irType,
|
||||||
origin = IrStatementOrigin.GET_PROPERTY.takeIf { calleeReference !is FirDelegateFieldReference },
|
origin = IrStatementOrigin.GET_PROPERTY.takeIf { calleeReference !is FirDelegateFieldReference },
|
||||||
superQualifierSymbol = dispatchReceiver.superQualifierSymbol()
|
superQualifierSymbol = dispatchReceiver.superQualifierSymbol()
|
||||||
)
|
)
|
||||||
@@ -508,8 +508,8 @@ class CallAndReferenceGenerator(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
is IrEnumEntrySymbol -> IrGetEnumValueImpl(startOffset, endOffset, type, symbol)
|
is IrEnumEntrySymbol -> IrGetEnumValueImpl(startOffset, endOffset, irType, symbol)
|
||||||
else -> generateErrorCallExpression(startOffset, endOffset, calleeReference, type)
|
else -> generateErrorCallExpression(startOffset, endOffset, calleeReference, irType)
|
||||||
}
|
}
|
||||||
}.applyTypeArguments(qualifiedAccess).applyReceivers(qualifiedAccess, convertedExplicitReceiver)
|
}.applyTypeArguments(qualifiedAccess).applyReceivers(qualifiedAccess, convertedExplicitReceiver)
|
||||||
.applyCallArguments(qualifiedAccess)
|
.applyCallArguments(qualifiedAccess)
|
||||||
@@ -797,7 +797,7 @@ class CallAndReferenceGenerator(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
val irType = qualifier.typeRef.toIrType()
|
val irType = qualifier.coneType.toIrType()
|
||||||
return qualifier.convertWithOffsets { startOffset, endOffset ->
|
return qualifier.convertWithOffsets { startOffset, endOffset ->
|
||||||
if (classSymbol != null) {
|
if (classSymbol != null) {
|
||||||
IrGetObjectValueImpl(
|
IrGetObjectValueImpl(
|
||||||
@@ -1010,7 +1010,7 @@ class CallAndReferenceGenerator(
|
|||||||
var irArgument = visitor.convertToIrExpression(argument)
|
var irArgument = visitor.convertToIrExpression(argument)
|
||||||
if (parameter != null) {
|
if (parameter != null) {
|
||||||
with(visitor.implicitCastInserter) {
|
with(visitor.implicitCastInserter) {
|
||||||
irArgument = irArgument.cast(argument, argument.typeRef, parameter.returnTypeRef)
|
irArgument = irArgument.cast(argument, argument.coneType, parameter.returnTypeRef.coneType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
with(adapterGenerator) {
|
with(adapterGenerator) {
|
||||||
@@ -1088,7 +1088,7 @@ class CallAndReferenceGenerator(
|
|||||||
)
|
)
|
||||||
if (conversionFunctions.isNotEmpty()) {
|
if (conversionFunctions.isNotEmpty()) {
|
||||||
elements.forEachIndexed { i, irVarargElement ->
|
elements.forEachIndexed { i, irVarargElement ->
|
||||||
val targetFun = argument.arguments[i].typeRef.toIrType().classifierOrNull?.let { conversionFunctions[it] }
|
val targetFun = argument.arguments[i].coneType.toIrType().classifierOrNull?.let { conversionFunctions[it] }
|
||||||
if (targetFun != null && irVarargElement is IrExpression) {
|
if (targetFun != null && irVarargElement is IrExpression) {
|
||||||
elements[i] =
|
elements[i] =
|
||||||
irVarargElement.applyToElement(argument.arguments[i], targetFun)
|
irVarargElement.applyToElement(argument.arguments[i], targetFun)
|
||||||
@@ -1103,7 +1103,7 @@ class CallAndReferenceGenerator(
|
|||||||
Name.identifier("to" + targetTypeFqName.shortName().asString()),
|
Name.identifier("to" + targetTypeFqName.shortName().asString()),
|
||||||
StandardNames.BUILT_INS_PACKAGE_NAME.asString()
|
StandardNames.BUILT_INS_PACKAGE_NAME.asString()
|
||||||
)
|
)
|
||||||
val sourceTypeClassifier = argument.typeRef.toIrType().classifierOrNull ?: return this
|
val sourceTypeClassifier = argument.coneType.toIrType().classifierOrNull ?: return this
|
||||||
|
|
||||||
val conversionFunction = conversionFunctions[sourceTypeClassifier] ?: return this
|
val conversionFunction = conversionFunctions[sourceTypeClassifier] ?: return this
|
||||||
|
|
||||||
@@ -1251,8 +1251,8 @@ class CallAndReferenceGenerator(
|
|||||||
with(visitor.implicitCastInserter) {
|
with(visitor.implicitCastInserter) {
|
||||||
it.cast(
|
it.cast(
|
||||||
qualifiedAccess.extensionReceiver,
|
qualifiedAccess.extensionReceiver,
|
||||||
qualifiedAccess.extensionReceiver.typeRef,
|
qualifiedAccess.extensionReceiver.coneType,
|
||||||
receiverType
|
receiverType.coneType,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} ?: it
|
} ?: it
|
||||||
|
|||||||
+1
-1
@@ -268,7 +268,7 @@ internal class ClassMemberGenerator(
|
|||||||
val irExpression = visitor.convertToIrExpression(initializerExpression, isDelegate = property.delegate != null)
|
val irExpression = visitor.convertToIrExpression(initializerExpression, isDelegate = property.delegate != null)
|
||||||
if (property.delegate == null) {
|
if (property.delegate == null) {
|
||||||
with(visitor.implicitCastInserter) {
|
with(visitor.implicitCastInserter) {
|
||||||
irExpression.cast(initializerExpression, initializerExpression.typeRef, property.returnTypeRef)
|
irExpression.cast(initializerExpression, initializerExpression.coneType, property.returnTypeRef.coneType)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
irExpression
|
irExpression
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.fir.expressions.FirConstExpression
|
|||||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||||
import org.jetbrains.kotlin.fir.symbols.Fir2IrPropertySymbol
|
import org.jetbrains.kotlin.fir.symbols.Fir2IrPropertySymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.Fir2IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.fir.symbols.Fir2IrSimpleFunctionSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.types.coneType
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.lazy.lazyVar
|
import org.jetbrains.kotlin.ir.declarations.lazy.lazyVar
|
||||||
@@ -97,7 +98,7 @@ class Fir2IrLazyProperty(
|
|||||||
containingClass?.classKind?.isAnnotationClass == true -> initializer?.asCompileTimeIrInitializer(components)
|
containingClass?.classKind?.isAnnotationClass == true -> initializer?.asCompileTimeIrInitializer(components)
|
||||||
// Setting initializers to every other class causes some cryptic errors in lowerings
|
// Setting initializers to every other class causes some cryptic errors in lowerings
|
||||||
initializer is FirConstExpression<*> -> {
|
initializer is FirConstExpression<*> -> {
|
||||||
val constType = with(typeConverter) { initializer.typeRef.toIrType() }
|
val constType = with(typeConverter) { initializer.coneType.toIrType() }
|
||||||
factory.createExpressionBody(initializer.toIrConst(constType))
|
factory.createExpressionBody(initializer.toIrConst(constType))
|
||||||
}
|
}
|
||||||
else -> null
|
else -> null
|
||||||
|
|||||||
Reference in New Issue
Block a user