IR: IrField.isFakeOverride
This commit is contained in:
@@ -21,6 +21,7 @@ interface IrField :
|
|||||||
val isFinal: Boolean
|
val isFinal: Boolean
|
||||||
val isExternal: Boolean
|
val isExternal: Boolean
|
||||||
val isStatic: Boolean
|
val isStatic: Boolean
|
||||||
|
val isFakeOverride: Boolean
|
||||||
|
|
||||||
var initializer: IrExpressionBody?
|
var initializer: IrExpressionBody?
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ class IrFieldImpl(
|
|||||||
override val visibility: Visibility,
|
override val visibility: Visibility,
|
||||||
override val isFinal: Boolean,
|
override val isFinal: Boolean,
|
||||||
override val isExternal: Boolean,
|
override val isExternal: Boolean,
|
||||||
override val isStatic: Boolean
|
override val isStatic: Boolean,
|
||||||
|
override val isFakeOverride: Boolean
|
||||||
) : IrDeclarationBase(startOffset, endOffset, origin),
|
) : IrDeclarationBase(startOffset, endOffset, origin),
|
||||||
IrField {
|
IrField {
|
||||||
|
|
||||||
@@ -60,7 +61,8 @@ class IrFieldImpl(
|
|||||||
symbol.descriptor.name, type, visibility,
|
symbol.descriptor.name, type, visibility,
|
||||||
isFinal = !symbol.descriptor.isVar,
|
isFinal = !symbol.descriptor.isVar,
|
||||||
isExternal = symbol.descriptor.isEffectivelyExternal(),
|
isExternal = symbol.descriptor.isEffectivelyExternal(),
|
||||||
isStatic = symbol.descriptor.dispatchReceiverParameter == null
|
isStatic = symbol.descriptor.dispatchReceiverParameter == null,
|
||||||
|
isFakeOverride = origin == IrDeclarationOrigin.FAKE_OVERRIDE
|
||||||
)
|
)
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class IrLazyField(
|
|||||||
override val isFinal: Boolean,
|
override val isFinal: Boolean,
|
||||||
override val isExternal: Boolean,
|
override val isExternal: Boolean,
|
||||||
override val isStatic: Boolean,
|
override val isStatic: Boolean,
|
||||||
|
override val isFakeOverride: Boolean,
|
||||||
stubGenerator: DeclarationStubGenerator,
|
stubGenerator: DeclarationStubGenerator,
|
||||||
typeTranslator: TypeTranslator
|
typeTranslator: TypeTranslator
|
||||||
) : IrLazyDeclarationBase(startOffset, endOffset, origin, stubGenerator, typeTranslator),
|
) : IrLazyDeclarationBase(startOffset, endOffset, origin, stubGenerator, typeTranslator),
|
||||||
@@ -50,11 +51,12 @@ class IrLazyField(
|
|||||||
startOffset, endOffset, origin, symbol,
|
startOffset, endOffset, origin, symbol,
|
||||||
symbol.descriptor.name,
|
symbol.descriptor.name,
|
||||||
symbol.descriptor.visibility,
|
symbol.descriptor.visibility,
|
||||||
!symbol.descriptor.isVar,
|
isFinal = !symbol.descriptor.isVar,
|
||||||
symbol.descriptor.isEffectivelyExternal(),
|
isExternal = symbol.descriptor.isEffectivelyExternal(),
|
||||||
symbol.descriptor.dispatchReceiverParameter == null,
|
isStatic = symbol.descriptor.dispatchReceiverParameter == null,
|
||||||
stubGenerator,
|
isFakeOverride = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
|
||||||
typeTranslator
|
stubGenerator = stubGenerator,
|
||||||
|
typeTranslator = typeTranslator
|
||||||
)
|
)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -243,9 +243,10 @@ open class DeepCopyIrTreeWithSymbols(
|
|||||||
symbolRenamer.getFieldName(declaration.symbol),
|
symbolRenamer.getFieldName(declaration.symbol),
|
||||||
declaration.type.remapType(),
|
declaration.type.remapType(),
|
||||||
declaration.visibility,
|
declaration.visibility,
|
||||||
declaration.isFinal,
|
isFinal = declaration.isFinal,
|
||||||
declaration.isExternal,
|
isExternal = declaration.isExternal,
|
||||||
declaration.isStatic
|
isStatic = declaration.isStatic,
|
||||||
|
isFakeOverride = declaration.isFakeOverride
|
||||||
).apply {
|
).apply {
|
||||||
transformAnnotations(declaration)
|
transformAnnotations(declaration)
|
||||||
declaration.overriddenSymbols.mapTo(overriddenSymbols) {
|
declaration.overriddenSymbols.mapTo(overriddenSymbols) {
|
||||||
|
|||||||
@@ -431,7 +431,8 @@ class RenderIrElementVisitor : IrElementVisitor<String, Nothing?> {
|
|||||||
renderFlagsList(
|
renderFlagsList(
|
||||||
"final".takeIf { isFinal },
|
"final".takeIf { isFinal },
|
||||||
"external".takeIf { isExternal },
|
"external".takeIf { isExternal },
|
||||||
"static".takeIf { isStatic }
|
"static".takeIf { isStatic },
|
||||||
|
"fake_override".takeIf { isFakeOverride }
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun visitClass(declaration: IrClass, data: Nothing?): String =
|
override fun visitClass(declaration: IrClass, data: Nothing?): String =
|
||||||
|
|||||||
@@ -7,24 +7,24 @@ FILE fqName:<root> fileName:/Derived.kt
|
|||||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[<root>.Base]'
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[<root>.Base]'
|
||||||
ANONYMOUS_INITIALIZER isStatic=false
|
ANONYMOUS_INITIALIZER isStatic=false
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
SET_FIELD 'FIELD FAKE_OVERRIDE name:value type:kotlin.Int visibility:public' type=kotlin.Unit origin=EQ
|
SET_FIELD 'FIELD FAKE_OVERRIDE name:value type:kotlin.Int visibility:public [fake_override]' type=kotlin.Unit origin=EQ
|
||||||
receiver: GET_VAR '<this>: <root>.Derived declared in <root>.Derived' type=<root>.Derived origin=null
|
receiver: GET_VAR '<this>: <root>.Derived declared in <root>.Derived' type=<root>.Derived origin=null
|
||||||
value: CONST Int type=kotlin.Int value=0
|
value: CONST Int type=kotlin.Int value=0
|
||||||
FUN name:getValue visibility:public modality:FINAL <> ($this:<root>.Derived) returnType:kotlin.Int
|
FUN name:getValue visibility:public modality:FINAL <> ($this:<root>.Derived) returnType:kotlin.Int
|
||||||
$this: VALUE_PARAMETER name:<this> type:<root>.Derived
|
$this: VALUE_PARAMETER name:<this> type:<root>.Derived
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
RETURN type=kotlin.Nothing from='public final fun getValue (): kotlin.Int declared in <root>.Derived'
|
RETURN type=kotlin.Nothing from='public final fun getValue (): kotlin.Int declared in <root>.Derived'
|
||||||
GET_FIELD 'FIELD FAKE_OVERRIDE name:value type:kotlin.Int visibility:public' type=kotlin.Int origin=GET_PROPERTY
|
GET_FIELD 'FIELD FAKE_OVERRIDE name:value type:kotlin.Int visibility:public [fake_override]' type=kotlin.Int origin=GET_PROPERTY
|
||||||
receiver: GET_VAR '<this>: <root>.Derived declared in <root>.Derived.getValue' type=<root>.Derived origin=null
|
receiver: GET_VAR '<this>: <root>.Derived declared in <root>.Derived.getValue' type=<root>.Derived origin=null
|
||||||
FUN name:setValue visibility:public modality:FINAL <> ($this:<root>.Derived, value:kotlin.Int) returnType:kotlin.Unit
|
FUN name:setValue visibility:public modality:FINAL <> ($this:<root>.Derived, value:kotlin.Int) returnType:kotlin.Unit
|
||||||
$this: VALUE_PARAMETER name:<this> type:<root>.Derived
|
$this: VALUE_PARAMETER name:<this> type:<root>.Derived
|
||||||
VALUE_PARAMETER name:value index:0 type:kotlin.Int
|
VALUE_PARAMETER name:value index:0 type:kotlin.Int
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
SET_FIELD 'FIELD FAKE_OVERRIDE name:value type:kotlin.Int visibility:public' type=kotlin.Unit origin=EQ
|
SET_FIELD 'FIELD FAKE_OVERRIDE name:value type:kotlin.Int visibility:public [fake_override]' type=kotlin.Unit origin=EQ
|
||||||
receiver: GET_VAR '<this>: <root>.Derived declared in <root>.Derived.setValue' type=<root>.Derived origin=null
|
receiver: GET_VAR '<this>: <root>.Derived declared in <root>.Derived.setValue' type=<root>.Derived origin=null
|
||||||
value: GET_VAR 'value: kotlin.Int declared in <root>.Derived.setValue' type=kotlin.Int origin=null
|
value: GET_VAR 'value: kotlin.Int declared in <root>.Derived.setValue' type=kotlin.Int origin=null
|
||||||
PROPERTY FAKE_OVERRIDE name:value visibility:public modality:FINAL [fake_override,var]
|
PROPERTY FAKE_OVERRIDE name:value visibility:public modality:FINAL [fake_override,var]
|
||||||
FIELD FAKE_OVERRIDE name:value type:kotlin.Int visibility:public
|
FIELD FAKE_OVERRIDE name:value type:kotlin.Int visibility:public [fake_override]
|
||||||
overridden:
|
overridden:
|
||||||
FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:value type:kotlin.Int visibility:public
|
FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:value type:kotlin.Int visibility:public
|
||||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override]
|
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override]
|
||||||
|
|||||||
+2
-2
@@ -132,11 +132,11 @@ FILE fqName:<root> fileName:/kt16904.kt
|
|||||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[<root>.J]'
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[<root>.J]'
|
||||||
ANONYMOUS_INITIALIZER isStatic=false
|
ANONYMOUS_INITIALIZER isStatic=false
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
SET_FIELD 'FIELD FAKE_OVERRIDE name:field type:kotlin.Int visibility:public' type=kotlin.Unit origin=EQ
|
SET_FIELD 'FIELD FAKE_OVERRIDE name:field type:kotlin.Int visibility:public [fake_override]' type=kotlin.Unit origin=EQ
|
||||||
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2' type=<root>.Test2 origin=null
|
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2' type=<root>.Test2 origin=null
|
||||||
value: CONST Int type=kotlin.Int value=42
|
value: CONST Int type=kotlin.Int value=42
|
||||||
PROPERTY FAKE_OVERRIDE name:field visibility:public modality:FINAL [fake_override,var]
|
PROPERTY FAKE_OVERRIDE name:field visibility:public modality:FINAL [fake_override,var]
|
||||||
FIELD FAKE_OVERRIDE name:field type:kotlin.Int visibility:public
|
FIELD FAKE_OVERRIDE name:field type:kotlin.Int visibility:public [fake_override]
|
||||||
overridden:
|
overridden:
|
||||||
FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:field type:kotlin.Int visibility:public
|
FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:field type:kotlin.Int visibility:public
|
||||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override]
|
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override]
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ FILE fqName:<root> fileName:/Derived.kt
|
|||||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.String
|
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.String
|
||||||
GET_VAR 'v: kotlin.Any declared in <root>.Derived.setValue' type=kotlin.Any origin=null
|
GET_VAR 'v: kotlin.Any declared in <root>.Derived.setValue' type=kotlin.Any origin=null
|
||||||
then: BLOCK type=kotlin.Unit origin=null
|
then: BLOCK type=kotlin.Unit origin=null
|
||||||
SET_FIELD 'FIELD FAKE_OVERRIDE name:value type:kotlin.String? visibility:public' type=kotlin.Unit origin=EQ
|
SET_FIELD 'FIELD FAKE_OVERRIDE name:value type:kotlin.String? visibility:public [fake_override]' type=kotlin.Unit origin=EQ
|
||||||
receiver: GET_VAR '<this>: <root>.Derived declared in <root>.Derived.setValue' type=<root>.Derived origin=null
|
receiver: GET_VAR '<this>: <root>.Derived declared in <root>.Derived.setValue' type=<root>.Derived origin=null
|
||||||
value: TYPE_OP type=kotlin.String origin=IMPLICIT_CAST typeOperand=kotlin.String
|
value: TYPE_OP type=kotlin.String origin=IMPLICIT_CAST typeOperand=kotlin.String
|
||||||
GET_VAR 'v: kotlin.Any declared in <root>.Derived.setValue' type=kotlin.Any origin=null
|
GET_VAR 'v: kotlin.Any declared in <root>.Derived.setValue' type=kotlin.Any origin=null
|
||||||
PROPERTY FAKE_OVERRIDE name:value visibility:public modality:FINAL [fake_override,var]
|
PROPERTY FAKE_OVERRIDE name:value visibility:public modality:FINAL [fake_override,var]
|
||||||
FIELD FAKE_OVERRIDE name:value type:kotlin.String? visibility:public
|
FIELD FAKE_OVERRIDE name:value type:kotlin.String? visibility:public [fake_override]
|
||||||
overridden:
|
overridden:
|
||||||
FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:value type:kotlin.String? visibility:public
|
FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:value type:kotlin.String? visibility:public
|
||||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override]
|
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override]
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ FILE fqName:<root> fileName:/javaInnerClass.kt
|
|||||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test type:<root>.J.JInner visibility:private [final]' type=<root>.J.JInner origin=null
|
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test type:<root>.J.JInner visibility:private [final]' type=<root>.J.JInner origin=null
|
||||||
receiver: GET_VAR '<this>: <root>.Test1 declared in <root>.Test1.<get-test>' type=<root>.Test1 origin=null
|
receiver: GET_VAR '<this>: <root>.Test1 declared in <root>.Test1.<get-test>' type=<root>.Test1 origin=null
|
||||||
PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,var]
|
PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,var]
|
||||||
FIELD FAKE_OVERRIDE name:x type:kotlin.Int visibility:public
|
FIELD FAKE_OVERRIDE name:x type:kotlin.Int visibility:public [fake_override]
|
||||||
overridden:
|
overridden:
|
||||||
FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:x type:kotlin.Int visibility:public
|
FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:x type:kotlin.Int visibility:public
|
||||||
FUN FAKE_OVERRIDE name:bar visibility:public modality:OPEN <> ($this:<root>.J) returnType:kotlin.Unit [fake_override]
|
FUN FAKE_OVERRIDE name:bar visibility:public modality:OPEN <> ($this:<root>.J) returnType:kotlin.Unit [fake_override]
|
||||||
|
|||||||
@@ -205,6 +205,14 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun visitField(declaration: IrField) {
|
||||||
|
visitDeclaration(declaration)
|
||||||
|
|
||||||
|
require((declaration.origin == IrDeclarationOrigin.FAKE_OVERRIDE) == declaration.isFakeOverride) {
|
||||||
|
"${declaration.descriptor}: origin: ${declaration.origin}; isFakeOverride: ${declaration.isFakeOverride}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun visitFunction(declaration: IrFunction) {
|
override fun visitFunction(declaration: IrFunction) {
|
||||||
visitDeclaration(declaration)
|
visitDeclaration(declaration)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user