Skip to content

Commit b989bfc

Browse files
committed
Fix VerifyError with @JvmStatic annotated getter
The problem was that for property getter 'context.getContextDescriptor()' references the containing property, while 'context.getFunctionDescriptor()' the accessor itself #KT-15594 Fixed
1 parent dd275ed commit b989bfc

File tree

5 files changed

+37
-1
lines changed

5 files changed

+37
-1
lines changed

compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3192,7 +3192,7 @@ public StackValue generateThisOrOuter(@NotNull ClassDescriptor calleeContainingC
31923192
boolean isSingleton = calleeContainingClass.getKind().isSingleton();
31933193
if (isSingleton) {
31943194
if (calleeContainingClass.equals(context.getThisDescriptor()) &&
3195-
!CodegenUtilKt.isJvmStaticInObjectOrClass(context.getContextDescriptor())) {
3195+
!CodegenUtilKt.isJvmStaticInObjectOrClass(context.getFunctionDescriptor())) {
31963196
return StackValue.local(0, typeMapper.mapType(calleeContainingClass));
31973197
}
31983198
else if (isEnumEntry(calleeContainingClass)) {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// WITH_RUNTIME
2+
// TARGET_BACKEND: JVM
3+
object ObjectThisTest {
4+
5+
val testValue: String
6+
@JvmStatic get() = this.testValue2
7+
8+
val testValue2: String
9+
get() = "OK"
10+
}
11+
12+
fun box() = ObjectThisTest.testValue
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@kotlin.Metadata
2+
public final class ObjectThisTest {
3+
public final static field INSTANCE: ObjectThisTest
4+
private method <init>(): void
5+
public final static @kotlin.jvm.JvmStatic @org.jetbrains.annotations.NotNull method getTestValue(): java.lang.String
6+
public final @org.jetbrains.annotations.NotNull method getTestValue2(): java.lang.String
7+
}
8+
9+
@kotlin.Metadata
10+
public final class PropertyGetterDelegatesToAnotherKt {
11+
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
12+
}

compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9740,6 +9740,12 @@ public void testPropertyAsDefault() throws Exception {
97409740
doTest(fileName);
97419741
}
97429742

9743+
@TestMetadata("propertyGetterDelegatesToAnother.kt")
9744+
public void testPropertyGetterDelegatesToAnother() throws Exception {
9745+
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmStatic/propertyGetterDelegatesToAnother.kt");
9746+
doTest(fileName);
9747+
}
9748+
97439749
@TestMetadata("simple.kt")
97449750
public void testSimple() throws Exception {
97459751
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmStatic/simple.kt");

compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9740,6 +9740,12 @@ public void testPropertyAsDefault() throws Exception {
97409740
doTest(fileName);
97419741
}
97429742

9743+
@TestMetadata("propertyGetterDelegatesToAnother.kt")
9744+
public void testPropertyGetterDelegatesToAnother() throws Exception {
9745+
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmStatic/propertyGetterDelegatesToAnother.kt");
9746+
doTest(fileName);
9747+
}
9748+
97439749
@TestMetadata("simple.kt")
97449750
public void testSimple() throws Exception {
97459751
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmStatic/simple.kt");

0 commit comments

Comments
 (0)