Prevent external IR field stub from being bound twice
This commit is contained in:
@@ -83,14 +83,7 @@ class DeclarationStubGenerator(
|
|||||||
IrPropertyImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor).also { irProperty ->
|
IrPropertyImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor).also { irProperty ->
|
||||||
val getterDescriptor = descriptor.getter
|
val getterDescriptor = descriptor.getter
|
||||||
if (descriptor.hasBackingField(bindingContext)) {
|
if (descriptor.hasBackingField(bindingContext)) {
|
||||||
irProperty.backingField =
|
irProperty.backingField = generateFieldStub(descriptor)
|
||||||
symbolTable.declareField(
|
|
||||||
UNDEFINED_OFFSET,
|
|
||||||
UNDEFINED_OFFSET,
|
|
||||||
origin,
|
|
||||||
descriptor.original,
|
|
||||||
descriptor.type.toIrType()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
if (getterDescriptor != null) {
|
if (getterDescriptor != null) {
|
||||||
irProperty.getter = generateFunctionStub(getterDescriptor)
|
irProperty.getter = generateFunctionStub(getterDescriptor)
|
||||||
@@ -99,6 +92,21 @@ class DeclarationStubGenerator(
|
|||||||
irProperty.setter = descriptor.setter?.let { generateFunctionStub(it) }
|
irProperty.setter = descriptor.setter?.let { generateFunctionStub(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun generateFieldStub(descriptor: PropertyDescriptor): IrField {
|
||||||
|
val referenced = symbolTable.referenceField(descriptor)
|
||||||
|
if (referenced.isBound) {
|
||||||
|
return referenced.owner
|
||||||
|
}
|
||||||
|
|
||||||
|
return symbolTable.declareField(
|
||||||
|
UNDEFINED_OFFSET,
|
||||||
|
UNDEFINED_OFFSET,
|
||||||
|
origin,
|
||||||
|
descriptor.original,
|
||||||
|
descriptor.type.toIrType()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun generateFunctionStub(descriptor: FunctionDescriptor): IrSimpleFunction {
|
fun generateFunctionStub(descriptor: FunctionDescriptor): IrSimpleFunction {
|
||||||
val referenced = symbolTable.referenceSimpleFunction(descriptor)
|
val referenced = symbolTable.referenceSimpleFunction(descriptor)
|
||||||
if (referenced.isBound) {
|
if (referenced.isBound) {
|
||||||
|
|||||||
Reference in New Issue
Block a user