IrTypes: IrClass.superTypes can depend on type parameters
IrClass.superTypes can depend on type parameters of a class and thus should be initialized after type parameters are in put in scope.
This commit is contained in:
@@ -54,6 +54,8 @@ class ClassGenerator(
|
|||||||
return context.symbolTable.declareClass(
|
return context.symbolTable.declareClass(
|
||||||
startOffset, endOffset, IrDeclarationOrigin.DEFINED, classDescriptor
|
startOffset, endOffset, IrDeclarationOrigin.DEFINED, classDescriptor
|
||||||
).buildWithScope { irClass ->
|
).buildWithScope { irClass ->
|
||||||
|
declarationGenerator.generateGlobalTypeParametersDeclarations(irClass, classDescriptor.declaredTypeParameters)
|
||||||
|
|
||||||
classDescriptor.typeConstructor.supertypes.mapTo(irClass.superTypes) {
|
classDescriptor.typeConstructor.supertypes.mapTo(irClass.superTypes) {
|
||||||
it.toIrType()
|
it.toIrType()
|
||||||
}
|
}
|
||||||
@@ -65,8 +67,6 @@ class ClassGenerator(
|
|||||||
classDescriptor.thisAsReceiverParameter.type.toIrType()
|
classDescriptor.thisAsReceiverParameter.type.toIrType()
|
||||||
)
|
)
|
||||||
|
|
||||||
declarationGenerator.generateGlobalTypeParametersDeclarations(irClass, classDescriptor.declaredTypeParameters)
|
|
||||||
|
|
||||||
val irPrimaryConstructor = generatePrimaryConstructor(irClass, ktClassOrObject)
|
val irPrimaryConstructor = generatePrimaryConstructor(irClass, ktClassOrObject)
|
||||||
if (irPrimaryConstructor != null) {
|
if (irPrimaryConstructor != null) {
|
||||||
generateDeclarationsForPrimaryConstructorParameters(irClass, irPrimaryConstructor, ktClassOrObject)
|
generateDeclarationsForPrimaryConstructorParameters(irClass, irPrimaryConstructor, ktClassOrObject)
|
||||||
|
|||||||
@@ -138,12 +138,13 @@ class DeclarationStubGenerator(
|
|||||||
|
|
||||||
private fun generateClassStub(descriptor: ClassDescriptor): IrClass =
|
private fun generateClassStub(descriptor: ClassDescriptor): IrClass =
|
||||||
symbolTable.declareClass(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor).also { irClass ->
|
symbolTable.declareClass(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor).also { irClass ->
|
||||||
|
generateTypeParameterStubs(descriptor.declaredTypeParameters, irClass)
|
||||||
|
|
||||||
// TODO get rid of code duplication, see ClassGenerator#generateClass
|
// TODO get rid of code duplication, see ClassGenerator#generateClass
|
||||||
descriptor.typeConstructor.supertypes.mapNotNullTo(irClass.superTypes) {
|
descriptor.typeConstructor.supertypes.mapNotNullTo(irClass.superTypes) {
|
||||||
it.toIrType()
|
it.toIrType()
|
||||||
}
|
}
|
||||||
|
|
||||||
generateTypeParameterStubs(descriptor.declaredTypeParameters, irClass)
|
|
||||||
irClass.thisReceiver = descriptor.thisAsReceiverParameter.generateReceiverParameterStub()
|
irClass.thisReceiver = descriptor.thisAsReceiverParameter.generateReceiverParameterStub()
|
||||||
generateChildStubs(descriptor.constructors, irClass)
|
generateChildStubs(descriptor.constructors, irClass)
|
||||||
generateMemberStubs(descriptor.defaultType.memberScope, irClass)
|
generateMemberStubs(descriptor.defaultType.memberScope, irClass)
|
||||||
|
|||||||
@@ -99,11 +99,11 @@ open class DeepCopyIrTreeWithSymbols(
|
|||||||
symbolRemapper.getDeclaredClass(declaration.symbol)
|
symbolRemapper.getDeclaredClass(declaration.symbol)
|
||||||
).apply {
|
).apply {
|
||||||
transformAnnotations(declaration)
|
transformAnnotations(declaration)
|
||||||
|
declaration.typeParameters.transformTo(typeParameters)
|
||||||
declaration.superTypes.mapTo(superTypes) {
|
declaration.superTypes.mapTo(superTypes) {
|
||||||
it.remapType()
|
it.remapType()
|
||||||
}
|
}
|
||||||
thisReceiver = declaration.thisReceiver?.transform()
|
thisReceiver = declaration.thisReceiver?.transform()
|
||||||
declaration.typeParameters.transformTo(typeParameters)
|
|
||||||
declaration.transformDeclarationsTo(this)
|
declaration.transformDeclarationsTo(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user