diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 64648898d95..4590bfa4bf8 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -24482,6 +24482,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/jvmField/kt47328_var.kt"); } + @Test + @TestMetadata("kt47739.kt") + public void testKt47739() throws Exception { + runTest("compiler/testData/codegen/box/jvmField/kt47739.kt"); + } + @Test @TestMetadata("publicField.kt") public void testPublicField() throws Exception { diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeclarationStubGenerator.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeclarationStubGenerator.kt index 004b029ec49..be7d7ac48b8 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeclarationStubGenerator.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeclarationStubGenerator.kt @@ -153,7 +153,8 @@ abstract class DeclarationStubGenerator( descriptor.name, descriptor.visibility, descriptor.modality, descriptor.isVar, descriptor.isConst, descriptor.isLateInit, descriptor.isDelegated, descriptor.isEffectivelyExternal(), descriptor.isExpect, - isFakeOverride = (origin == IrDeclarationOrigin.FAKE_OVERRIDE), + isFakeOverride = (origin == IrDeclarationOrigin.FAKE_OVERRIDE) + || descriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE, stubGenerator = this, typeTranslator, ) } @@ -165,7 +166,9 @@ abstract class DeclarationStubGenerator( return referenced.owner } - return symbolTable.declareField(UNDEFINED_OFFSET, UNDEFINED_OFFSET, computeOrigin(descriptor), descriptor.original, descriptor.type.toIrType()) { + return symbolTable.declareField( + UNDEFINED_OFFSET, UNDEFINED_OFFSET, computeOrigin(descriptor), descriptor.original, descriptor.type.toIrType() + ) { IrLazyField( UNDEFINED_OFFSET, UNDEFINED_OFFSET, computeOrigin(descriptor), it, descriptor, diff --git a/compiler/testData/codegen/box/jvmField/kt47739.kt b/compiler/testData/codegen/box/jvmField/kt47739.kt new file mode 100644 index 00000000000..77da39d198b --- /dev/null +++ b/compiler/testData/codegen/box/jvmField/kt47739.kt @@ -0,0 +1,32 @@ +// TARGET_BACKEND: JVM +// WITH_RUNTIME + +// MODULE: lib +// FILE: Value.kt +package vv + +sealed class Value(@JvmField val value: T) { + class StringValue(value: String) : Value(value) + class BooleanValue(value: Boolean): Value(value) +} + + +// MODULE: main(lib) +// FILE: kt47739.kt +import kotlin.test.* +import vv.* + +fun test(v: Value<*>) { + when (v) { + is Value.StringValue -> + assertEquals("a string", v.value) + is Value.BooleanValue -> + assertEquals(true, v.value) + } +} + +fun box(): String { + test(Value.StringValue("a string")) + test(Value.BooleanValue(true)) + return "OK" +} diff --git a/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.txt b/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.txt index 8a89718bd87..f915baf2445 100644 --- a/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.txt +++ b/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.txt @@ -85,7 +85,7 @@ FILE fqName: fileName:/inlineCollectionOfInlineClass.kt receiver: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.' type=.InlineMutableSet origin=null PROPERTY name:size visibility:public modality:OPEN [val] overridden: - public abstract size: kotlin.Int [val] + public abstract size: kotlin.Int [fake_override,val] FUN name: visibility:public modality:OPEN <> ($this:.InlineMutableSet) returnType:kotlin.Int correspondingProperty: PROPERTY name:size visibility:public modality:OPEN [val] overridden: diff --git a/compiler/testData/ir/irText/expressions/kt30020.txt b/compiler/testData/ir/irText/expressions/kt30020.txt index afd9df7fa25..4b1a3bcc9e9 100644 --- a/compiler/testData/ir/irText/expressions/kt30020.txt +++ b/compiler/testData/ir/irText/expressions/kt30020.txt @@ -234,7 +234,7 @@ FILE fqName: fileName:/kt30020.kt VALUE_PARAMETER name:toIndex index:1 type:kotlin.Int PROPERTY FAKE_OVERRIDE name:size visibility:public modality:ABSTRACT [fake_override,val] overridden: - public abstract size: kotlin.Int [val] + public abstract size: kotlin.Int [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:kotlin.collections.List) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:size visibility:public modality:ABSTRACT [fake_override,val] overridden: diff --git a/compiler/testData/ir/irText/firProblems/AbstractMutableMap.txt b/compiler/testData/ir/irText/firProblems/AbstractMutableMap.txt index 098a06f1308..3c01ab6630e 100644 --- a/compiler/testData/ir/irText/firProblems/AbstractMutableMap.txt +++ b/compiler/testData/ir/irText/firProblems/AbstractMutableMap.txt @@ -20,7 +20,7 @@ FILE fqName: fileName:/AbstractMutableMap.kt CONST Null type=kotlin.Nothing? value=null PROPERTY name:entries visibility:public modality:OPEN [val] overridden: - public abstract entries: kotlin.collections.MutableSet> [val] + public abstract entries: kotlin.collections.MutableSet> [fake_override,val] FUN name: visibility:public modality:OPEN <> ($this:.MyMap.MyMap, V of .MyMap>) returnType:kotlin.collections.MutableSet.MyMap, V of .MyMap>> correspondingProperty: PROPERTY name:entries visibility:public modality:OPEN [val] overridden: @@ -154,7 +154,7 @@ FILE fqName: fileName:/AbstractMutableMap.kt $this: VALUE_PARAMETER name: type:kotlin.Any PROPERTY FAKE_OVERRIDE name:keys visibility:public modality:OPEN [fake_override,val] overridden: - public open keys: kotlin.collections.MutableSet [val] + public open keys: kotlin.collections.MutableSet [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:OPEN <> ($this:kotlin.collections.MutableMap.MyMap, V of .MyMap>) returnType:kotlin.collections.MutableSet.MyMap> [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:keys visibility:public modality:OPEN [fake_override,val] overridden: @@ -162,7 +162,7 @@ FILE fqName: fileName:/AbstractMutableMap.kt $this: VALUE_PARAMETER name: type:kotlin.collections.MutableMap.MyMap, V of .MyMap> PROPERTY FAKE_OVERRIDE name:size visibility:public modality:OPEN [fake_override,val] overridden: - public open size: kotlin.Int [val] + public open size: kotlin.Int [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:OPEN <> ($this:kotlin.collections.Map.MyMap, V of .MyMap>) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:size visibility:public modality:OPEN [fake_override,val] overridden: @@ -170,7 +170,7 @@ FILE fqName: fileName:/AbstractMutableMap.kt $this: VALUE_PARAMETER name: type:kotlin.collections.Map.MyMap, V of .MyMap> PROPERTY FAKE_OVERRIDE name:values visibility:public modality:OPEN [fake_override,val] overridden: - public open values: kotlin.collections.MutableCollection [val] + public open values: kotlin.collections.MutableCollection [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:OPEN <> ($this:kotlin.collections.MutableMap.MyMap, V of .MyMap>) returnType:kotlin.collections.MutableCollection.MyMap> [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:values visibility:public modality:OPEN [fake_override,val] overridden: diff --git a/compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.txt b/compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.txt index 62e4e32d22d..c7e33199367 100644 --- a/compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.txt +++ b/compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.txt @@ -124,8 +124,8 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt elements: GET_VAR 'elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?> declared in .Impl.retainAll' type=kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?> origin=null PROPERTY DELEGATED_MEMBER name:size visibility:public modality:OPEN [val] overridden: - public abstract size: kotlin.Int [val] - public abstract size: kotlin.Int [val] + public abstract size: kotlin.Int [fake_override,val] + public abstract size: kotlin.Int [fake_override,val] FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Impl) returnType:kotlin.Int correspondingProperty: PROPERTY DELEGATED_MEMBER name:size visibility:public modality:OPEN [val] overridden: diff --git a/compiler/testData/ir/irText/firProblems/MultiList.txt b/compiler/testData/ir/irText/firProblems/MultiList.txt index d33c4db0394..4693fa95af8 100644 --- a/compiler/testData/ir/irText/firProblems/MultiList.txt +++ b/compiler/testData/ir/irText/firProblems/MultiList.txt @@ -198,7 +198,7 @@ FILE fqName: fileName:/MultiList.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:SomeList modality:OPEN visibility:public superTypes:[.MyList.SomeList>; java.util.ArrayList<.Some.SomeList>>]' PROPERTY FAKE_OVERRIDE name:modCount visibility:protected/*protected and package*/ modality:FINAL [fake_override,var] overridden: - protected/*protected and package*/ final modCount: kotlin.Int [var] + protected/*protected and package*/ final modCount: kotlin.Int [fake_override,var] FUN FAKE_OVERRIDE name:removeRange visibility:protected/*protected and package*/ modality:OPEN <> ($this:java.util.ArrayList<.Some.SomeList>>, p0:kotlin.Int, p1:kotlin.Int) returnType:kotlin.Unit [fake_override] overridden: protected/*protected and package*/ open fun removeRange (p0: kotlin.Int, p1: kotlin.Int): kotlin.Unit declared in java.util.ArrayList diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 45430f9d3fd..c361b11c27a 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -24440,6 +24440,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/jvmField/kt47328_var.kt"); } + @Test + @TestMetadata("kt47739.kt") + public void testKt47739() throws Exception { + runTest("compiler/testData/codegen/box/jvmField/kt47739.kt"); + } + @Test @TestMetadata("publicField.kt") public void testPublicField() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 090cd7609a6..bb85ac2c041 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -24482,6 +24482,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/jvmField/kt47328_var.kt"); } + @Test + @TestMetadata("kt47739.kt") + public void testKt47739() throws Exception { + runTest("compiler/testData/codegen/box/jvmField/kt47739.kt"); + } + @Test @TestMetadata("publicField.kt") public void testPublicField() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index bd78340c4f0..ffb9386d1ee 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -20589,6 +20589,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/jvmField/kt47328_var.kt"); } + @TestMetadata("kt47739.kt") + public void testKt47739() throws Exception { + runTest("compiler/testData/codegen/box/jvmField/kt47739.kt"); + } + @TestMetadata("publicField.kt") public void testPublicField() throws Exception { runTest("compiler/testData/codegen/box/jvmField/publicField.kt");