IR: create IrExpressionBody via IrFactory
This commit is contained in:
@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.ir.descriptors.WrappedEnumEntryDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedTypeAliasDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedTypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrEnumConstructorCallImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeAliasSymbol
|
||||
@@ -408,7 +407,7 @@ class Fir2IrClassifierStorage(
|
||||
// which will be translated via visitor later.
|
||||
} else if (irParent != null && origin == IrDeclarationOrigin.DEFINED) {
|
||||
val constructor = irParent.constructors.first()
|
||||
this.initializerExpression = IrExpressionBodyImpl(
|
||||
this.initializerExpression = factory.createExpressionBody(
|
||||
IrEnumConstructorCallImpl(
|
||||
startOffset, endOffset, irType, constructor.symbol,
|
||||
valueArgumentsCount = constructor.valueParameters.size,
|
||||
|
||||
+2
-3
@@ -43,7 +43,6 @@ import org.jetbrains.kotlin.ir.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.types.IrErrorType
|
||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||
@@ -670,7 +669,7 @@ class Fir2IrDeclarationStorage(
|
||||
if (initializer is FirConstExpression<*>) {
|
||||
// TODO: Normally we shouldn't have error type here
|
||||
val constType = initializer.typeRef.toIrType().takeIf { it !is IrErrorType } ?: type
|
||||
field.initializer = IrExpressionBodyImpl(initializer.toIrConst(constType))
|
||||
field.initializer = factory.createExpressionBody(initializer.toIrConst(constType))
|
||||
}
|
||||
}
|
||||
} else if (delegate != null) {
|
||||
@@ -794,7 +793,7 @@ class Fir2IrDeclarationStorage(
|
||||
it != null && (useStubForDefaultValueStub || it !is FirExpressionStub)
|
||||
}
|
||||
) {
|
||||
this.defaultValue = IrExpressionBodyImpl(
|
||||
this.defaultValue = factory.createExpressionBody(
|
||||
IrErrorExpressionImpl(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, type,
|
||||
"Stub expression for default value of ${valueParameter.name}"
|
||||
|
||||
@@ -127,7 +127,7 @@ class Fir2IrVisitor(
|
||||
memberGenerator.convertClassContent(correspondingClass, anonymousObject)
|
||||
}
|
||||
val constructor = correspondingClass.constructors.first()
|
||||
irEnumEntry.initializerExpression = IrExpressionBodyImpl(
|
||||
irEnumEntry.initializerExpression = irFactory.createExpressionBody(
|
||||
IrEnumConstructorCallImpl(
|
||||
startOffset, endOffset, enumEntry.returnTypeRef.toIrType(),
|
||||
constructor.symbol,
|
||||
@@ -144,7 +144,9 @@ class Fir2IrVisitor(
|
||||
val delegatedConstructor = primaryConstructor?.delegatedConstructor
|
||||
if (delegatedConstructor != null) {
|
||||
with(memberGenerator) {
|
||||
irEnumEntry.initializerExpression = IrExpressionBodyImpl(delegatedConstructor.toIrDelegatingConstructorCall())
|
||||
irEnumEntry.initializerExpression = irFactory.createExpressionBody(
|
||||
delegatedConstructor.toIrDelegatingConstructorCall()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-4
@@ -27,7 +27,10 @@ import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.ir.util.constructedClassType
|
||||
import org.jetbrains.kotlin.ir.util.isAnnotationClass
|
||||
import org.jetbrains.kotlin.ir.util.isSetter
|
||||
import org.jetbrains.kotlin.ir.util.parentAsClass
|
||||
|
||||
internal class ClassMemberGenerator(
|
||||
private val components: Fir2IrComponents,
|
||||
@@ -221,7 +224,7 @@ internal class ClassMemberGenerator(
|
||||
declarationStorage.enterScope(this@initializeBackingField)
|
||||
// NB: initializer can be already converted
|
||||
if (initializer == null && initializerExpression != null) {
|
||||
initializer = IrExpressionBodyImpl(visitor.convertToIrExpression(initializerExpression))
|
||||
initializer = irFactory.createExpressionBody(visitor.convertToIrExpression(initializerExpression))
|
||||
}
|
||||
declarationStorage.leaveScope(this@initializeBackingField)
|
||||
}
|
||||
@@ -356,7 +359,7 @@ internal class ClassMemberGenerator(
|
||||
private fun IrValueParameter.setDefaultValue(firValueParameter: FirValueParameter) {
|
||||
val firDefaultValue = firValueParameter.defaultValue
|
||||
if (firDefaultValue != null) {
|
||||
this.defaultValue = IrExpressionBodyImpl(visitor.convertToIrExpression(firDefaultValue))
|
||||
this.defaultValue = factory.createExpressionBody(visitor.convertToIrExpression(firDefaultValue))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import org.jetbrains.kotlin.fir.symbols.Fir2IrPropertySymbol
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.lazy.lazyVar
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
||||
import org.jetbrains.kotlin.ir.types.IrErrorType
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.util.isInterface
|
||||
@@ -103,7 +102,7 @@ class Fir2IrLazyProperty(
|
||||
if (initializer is FirConstExpression<*>) {
|
||||
// TODO: Normally we shouldn't have error type here
|
||||
val constType = with(typeConverter) { initializer.typeRef.toIrType().takeIf { it !is IrErrorType } ?: type }
|
||||
field.initializer = IrExpressionBodyImpl(initializer.toIrConst(constType))
|
||||
field.initializer = factory.createExpressionBody(initializer.toIrConst(constType))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user