Generate correct names for companion @JvmStatic accessors in annotation class
#KT-31389 Fixed
This commit is contained in:
@@ -50,6 +50,7 @@ import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContextUtils.getDelegationConstructorCall
|
||||
import org.jetbrains.kotlin.resolve.BindingContextUtils.isBoxedLocalCapturedInClosure
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.*
|
||||
import org.jetbrains.kotlin.resolve.annotations.hasJvmStaticAnnotation
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression
|
||||
import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
@@ -582,7 +583,9 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
||||
return when {
|
||||
descriptor is PropertyAccessorDescriptor -> {
|
||||
val property = descriptor.correspondingProperty
|
||||
if (isAnnotationClass(property.containingDeclaration)) {
|
||||
if (isAnnotationClass(property.containingDeclaration) &&
|
||||
(!property.hasJvmStaticAnnotation() && !descriptor.hasJvmStaticAnnotation())
|
||||
) {
|
||||
return property.name.asString()
|
||||
}
|
||||
|
||||
|
||||
Generated
+5
@@ -18022,6 +18022,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/jvmStatic/kt21246a.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt31389.kt")
|
||||
public void testKt31389() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmStatic/kt31389.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt35716.kt")
|
||||
public void testKt35716() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmStatic/kt35716.kt");
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// FILE: Test.java
|
||||
|
||||
class Test {
|
||||
public static String foo() {
|
||||
return Annotation.getTEST_FIELD();
|
||||
}
|
||||
|
||||
public static String foo2() {
|
||||
return Annotation.getTEST_FIELD2();
|
||||
}
|
||||
|
||||
public static void foo2Set() {
|
||||
Annotation.setTEST_FIELD2("OK");
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: kt31389.kt
|
||||
|
||||
annotation class Annotation {
|
||||
companion object {
|
||||
@JvmStatic val TEST_FIELD = "OK"
|
||||
|
||||
var TEST_FIELD2 = ""
|
||||
@JvmStatic get
|
||||
@JvmStatic set
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (Test.foo() != "OK") return "Fail 1: ${Test.foo()}"
|
||||
Test.foo2Set()
|
||||
return Test.foo2()
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
annotation class Annotation {
|
||||
companion object {
|
||||
@JvmStatic val TEST_FIELD = "OK"
|
||||
|
||||
var TEST_FIELD2 = ""
|
||||
@JvmStatic get
|
||||
@JvmStatic set
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
@kotlin.Metadata
|
||||
public final class Annotation$Companion {
|
||||
// source: 'kt31389.kt'
|
||||
synthetic final static field $$INSTANCE: Annotation$Companion
|
||||
private static @org.jetbrains.annotations.NotNull field TEST_FIELD2: java.lang.String
|
||||
private final static @org.jetbrains.annotations.NotNull field TEST_FIELD: java.lang.String
|
||||
static method <clinit>(): void
|
||||
private method <init>(): void
|
||||
public synthetic deprecated static @kotlin.jvm.JvmStatic method getTEST_FIELD$annotations(): void
|
||||
public final @org.jetbrains.annotations.NotNull method getTEST_FIELD(): java.lang.String
|
||||
public final @kotlin.jvm.JvmStatic @org.jetbrains.annotations.NotNull method getTEST_FIELD2(): java.lang.String
|
||||
public final @kotlin.jvm.JvmStatic method setTEST_FIELD2(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
|
||||
public final inner class Annotation$Companion
|
||||
}
|
||||
|
||||
@java.lang.annotation.Retention
|
||||
@kotlin.Metadata
|
||||
public annotation class Annotation {
|
||||
// source: 'kt31389.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull field Companion: Annotation$Companion
|
||||
static method <clinit>(): void
|
||||
public static method getTEST_FIELD(): java.lang.String
|
||||
public static @kotlin.jvm.JvmStatic method getTEST_FIELD2(): java.lang.String
|
||||
public static @kotlin.jvm.JvmStatic method setTEST_FIELD2(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
|
||||
public final inner class Annotation$Companion
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
@kotlin.Metadata
|
||||
public final class Annotation$Companion {
|
||||
// source: 'kt31389.kt'
|
||||
synthetic final static field $$INSTANCE: Annotation$Companion
|
||||
private static @org.jetbrains.annotations.NotNull field TEST_FIELD2: java.lang.String
|
||||
private final static @org.jetbrains.annotations.NotNull field TEST_FIELD: java.lang.String
|
||||
static method <clinit>(): void
|
||||
private method <init>(): void
|
||||
public synthetic deprecated static @kotlin.jvm.JvmStatic method getTEST_FIELD$annotations(): void
|
||||
public final @org.jetbrains.annotations.NotNull method getTEST_FIELD(): java.lang.String
|
||||
public final @kotlin.jvm.JvmStatic @org.jetbrains.annotations.NotNull method getTEST_FIELD2(): java.lang.String
|
||||
public final @kotlin.jvm.JvmStatic method setTEST_FIELD2(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
|
||||
public final inner class Annotation$Companion
|
||||
}
|
||||
|
||||
@java.lang.annotation.Retention
|
||||
@kotlin.Metadata
|
||||
public annotation class Annotation {
|
||||
// source: 'kt31389.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull field Companion: Annotation$Companion
|
||||
static method <clinit>(): void
|
||||
public static @org.jetbrains.annotations.NotNull method getTEST_FIELD(): java.lang.String
|
||||
public static @kotlin.jvm.JvmStatic @org.jetbrains.annotations.NotNull method getTEST_FIELD2(): java.lang.String
|
||||
public static @kotlin.jvm.JvmStatic method setTEST_FIELD2(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
|
||||
public final inner class Annotation$Companion
|
||||
}
|
||||
+5
@@ -19422,6 +19422,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/jvmStatic/kt21246a.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt31389.kt")
|
||||
public void testKt31389() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmStatic/kt31389.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt35716.kt")
|
||||
public void testKt35716() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmStatic/kt35716.kt");
|
||||
|
||||
+5
@@ -114,6 +114,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/jvmStaticWithDefaultParameters.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt31389.kt")
|
||||
public void testKt31389() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/kt31389.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42137.kt")
|
||||
public void testKt42137() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/kt42137.kt");
|
||||
|
||||
+5
@@ -19422,6 +19422,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/jvmStatic/kt21246a.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt31389.kt")
|
||||
public void testKt31389() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmStatic/kt31389.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt35716.kt")
|
||||
public void testKt35716() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmStatic/kt35716.kt");
|
||||
|
||||
+5
@@ -18022,6 +18022,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/jvmStatic/kt21246a.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt31389.kt")
|
||||
public void testKt31389() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmStatic/kt31389.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt35716.kt")
|
||||
public void testKt35716() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmStatic/kt35716.kt");
|
||||
|
||||
+5
@@ -114,6 +114,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
|
||||
runTest("compiler/testData/codegen/bytecodeListing/jvmStaticWithDefaultParameters.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt31389.kt")
|
||||
public void testKt31389() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/kt31389.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42137.kt")
|
||||
public void testKt42137() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/kt42137.kt");
|
||||
|
||||
Reference in New Issue
Block a user