Don't generate primary constructor body for expect classes
This commit is contained in:
@@ -232,7 +232,9 @@ class BodyGenerator(
|
||||
// If we are here, we didn't find a superclass entry in super types.
|
||||
// Thus, super class should be Any.
|
||||
val superClass = classDescriptor.getSuperClassOrAny()
|
||||
assert(KotlinBuiltIns.isAny(superClass)) { "$classDescriptor: Super class should be any: $superClass" }
|
||||
assert(KotlinBuiltIns.isAny(superClass)) {
|
||||
"$classDescriptor: Super class should be any: $superClass"
|
||||
}
|
||||
generateAnySuperConstructorCall(irBlockBody, ktClassOrObject)
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -196,7 +196,10 @@ class FunctionGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
||||
ktClassOrObject: KtClassOrObject
|
||||
): IrConstructor =
|
||||
declareConstructor(ktClassOrObject, ktClassOrObject.primaryConstructor ?: ktClassOrObject, primaryConstructorDescriptor) {
|
||||
generatePrimaryConstructorBody(ktClassOrObject)
|
||||
if (primaryConstructorDescriptor.isExpect)
|
||||
null
|
||||
else
|
||||
generatePrimaryConstructorBody(ktClassOrObject)
|
||||
}
|
||||
|
||||
fun generateSecondaryConstructor(ktConstructor: KtSecondaryConstructor): IrConstructor =
|
||||
@@ -215,7 +218,7 @@ class FunctionGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
||||
ktConstructorElement: KtElement,
|
||||
ktParametersElement: KtElement,
|
||||
constructorDescriptor: ClassConstructorDescriptor,
|
||||
generateBody: BodyGenerator.() -> IrBody
|
||||
generateBody: BodyGenerator.() -> IrBody?
|
||||
): IrConstructor =
|
||||
context.symbolTable.declareConstructor(
|
||||
ktConstructorElement.startOffset, ktConstructorElement.endOffset, IrDeclarationOrigin.DEFINED, constructorDescriptor
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ class IrConstructorImpl(
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: ClassConstructorDescriptor,
|
||||
body: IrBody
|
||||
body: IrBody?
|
||||
) : this(startOffset, endOffset, origin, descriptor) {
|
||||
this.body = body
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ open class DeepCopyIrTree : IrElementTransformerVoid() {
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapConstructorDeclaration(declaration.descriptor),
|
||||
declaration.body!!.transform()
|
||||
declaration.body?.transform()
|
||||
).transformParameters(declaration)
|
||||
|
||||
protected fun <T : IrTypeParametersContainer> T.transformTypeParameters(
|
||||
|
||||
Reference in New Issue
Block a user