PSI2IR: copy isPropertyWithPlatformField to GeneratorExtensions
This commit is contained in:
@@ -65,6 +65,9 @@ object JvmGeneratorExtensions : GeneratorExtensions() {
|
|||||||
descriptor.visibility
|
descriptor.visibility
|
||||||
else
|
else
|
||||||
null
|
null
|
||||||
|
|
||||||
|
override fun isPropertyWithPlatformField(descriptor: PropertyDescriptor): Boolean =
|
||||||
|
descriptor.hasJvmFieldAnnotation()
|
||||||
}
|
}
|
||||||
|
|
||||||
class JvmStubGeneratorExtensions : StubGeneratorExtensions() {
|
class JvmStubGeneratorExtensions : StubGeneratorExtensions() {
|
||||||
|
|||||||
+2
@@ -29,4 +29,6 @@ open class GeneratorExtensions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open fun computeFieldVisibility(descriptor: PropertyDescriptor): Visibility? = null
|
open fun computeFieldVisibility(descriptor: PropertyDescriptor): Visibility? = null
|
||||||
|
|
||||||
|
open fun isPropertyWithPlatformField(descriptor: PropertyDescriptor): Boolean = false
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-3
@@ -102,6 +102,9 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
|||||||
DelegatedPropertyGenerator(declarationGenerator)
|
DelegatedPropertyGenerator(declarationGenerator)
|
||||||
.generateDelegatedProperty(ktProperty, ktDelegate, propertyDescriptor)
|
.generateDelegatedProperty(ktProperty, ktDelegate, propertyDescriptor)
|
||||||
|
|
||||||
|
private fun PropertyDescriptor.actuallyHasBackingField(bindingContext: BindingContext) =
|
||||||
|
hasBackingField(bindingContext) || context.extensions.isPropertyWithPlatformField(this)
|
||||||
|
|
||||||
private fun generateSimpleProperty(ktProperty: KtProperty, propertyDescriptor: PropertyDescriptor): IrProperty =
|
private fun generateSimpleProperty(ktProperty: KtProperty, propertyDescriptor: PropertyDescriptor): IrProperty =
|
||||||
context.symbolTable.declareProperty(
|
context.symbolTable.declareProperty(
|
||||||
ktProperty.startOffsetSkippingComments, ktProperty.endOffset,
|
ktProperty.startOffsetSkippingComments, ktProperty.endOffset,
|
||||||
@@ -110,7 +113,7 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
|||||||
isDelegated = false
|
isDelegated = false
|
||||||
).buildWithScope { irProperty ->
|
).buildWithScope { irProperty ->
|
||||||
irProperty.backingField =
|
irProperty.backingField =
|
||||||
if (propertyDescriptor.hasBackingField(context.bindingContext))
|
if (propertyDescriptor.actuallyHasBackingField(context.bindingContext))
|
||||||
generatePropertyBackingField(ktProperty, propertyDescriptor) { irField ->
|
generatePropertyBackingField(ktProperty, propertyDescriptor) { irField ->
|
||||||
ktProperty.initializer?.let { ktInitializer ->
|
ktProperty.initializer?.let { ktInitializer ->
|
||||||
val compileTimeConst = propertyDescriptor.compileTimeInitializer
|
val compileTimeConst = propertyDescriptor.compileTimeInitializer
|
||||||
@@ -139,11 +142,11 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
|||||||
val endOffset = ktElement.pureEndOffsetOrUndefined
|
val endOffset = ktElement.pureEndOffsetOrUndefined
|
||||||
|
|
||||||
val backingField =
|
val backingField =
|
||||||
if (propertyDescriptor.hasBackingField(context.bindingContext) && propertyDescriptor.fieldVisibility.admitsFakeOverride)
|
if (propertyDescriptor.actuallyHasBackingField(context.bindingContext) && propertyDescriptor.fieldVisibility.admitsFakeOverride)
|
||||||
context.symbolTable.declareFieldWithOverrides(
|
context.symbolTable.declareFieldWithOverrides(
|
||||||
startOffset, endOffset, IrDeclarationOrigin.FAKE_OVERRIDE,
|
startOffset, endOffset, IrDeclarationOrigin.FAKE_OVERRIDE,
|
||||||
propertyDescriptor, propertyDescriptor.type.toIrType()
|
propertyDescriptor, propertyDescriptor.type.toIrType()
|
||||||
) { it.hasBackingField(context.bindingContext) }
|
) { it.actuallyHasBackingField(context.bindingContext) }
|
||||||
else
|
else
|
||||||
null
|
null
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ open class B : A() {
|
|||||||
|
|
||||||
open class C : B() {
|
open class C : B() {
|
||||||
fun test(): String {
|
fun test(): String {
|
||||||
return super.publicField + super.internalField + super.protectedfield
|
return publicField + super.internalField + super.protectedfield
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ open class B : A()
|
|||||||
|
|
||||||
open class C : B() {
|
open class C : B() {
|
||||||
fun test(): String {
|
fun test(): String {
|
||||||
return super.publicField + super.internalField + super.protectedfield
|
return publicField + super.internalField + super.protectedfield
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user