Load annotations on compiled Kotlin enum entries
#KT-10339 Fixed
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
// ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
annotation class Anno(val value: String = "0", val x: Int = 0)
|
||||
annotation class Bnno
|
||||
|
||||
enum class Eee {
|
||||
@Anno()
|
||||
Entry1,
|
||||
Entry2,
|
||||
@Anno("3") @Bnno
|
||||
Entry3,
|
||||
@Anno("4", 4)
|
||||
Entry4,
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package test
|
||||
|
||||
public final annotation class Anno : kotlin.Annotation {
|
||||
/*primary*/ public constructor Anno(/*0*/ value: kotlin.String = ..., /*1*/ x: kotlin.Int = ...)
|
||||
public final val value: kotlin.String
|
||||
public final fun <get-value>(): kotlin.String
|
||||
public final val x: kotlin.Int
|
||||
public final fun <get-x>(): kotlin.Int
|
||||
}
|
||||
|
||||
public final annotation class Bnno : kotlin.Annotation {
|
||||
/*primary*/ public constructor Bnno()
|
||||
}
|
||||
|
||||
public final enum class Eee : kotlin.Enum<test.Eee> {
|
||||
@test.Anno() enum entry Entry1
|
||||
|
||||
enum entry Entry2
|
||||
|
||||
@test.Anno(value = "3") @test.Bnno() enum entry Entry3
|
||||
|
||||
@test.Anno(value = "4", x = 4) enum entry Entry4
|
||||
|
||||
/*primary*/ private constructor Eee()
|
||||
public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ fun <get-name>(): kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun <get-ordinal>(): kotlin.Int
|
||||
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: test.Eee): kotlin.Int
|
||||
|
||||
// Static members
|
||||
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use 'values()' function instead", replaceWith = kotlin.ReplaceWith(expression = "this.values()", imports = {})) public final /*synthesized*/ val values: kotlin.Array<test.Eee>
|
||||
public final fun <get-values>(): kotlin.Array<test.Eee>
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): test.Eee
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<test.Eee>
|
||||
}
|
||||
@@ -1872,6 +1872,12 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
doTestCompiledKotlin(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("EnumEntry.kt")
|
||||
public void testEnumEntry() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classMembers/EnumEntry.kt");
|
||||
doTestCompiledKotlin(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Function.kt")
|
||||
public void testFunction() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Function.kt");
|
||||
|
||||
+6
@@ -117,6 +117,12 @@ public class LoadKotlinWithTypeTableTestGenerated extends AbstractLoadKotlinWith
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("EnumEntry.kt")
|
||||
public void testEnumEntry() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classMembers/EnumEntry.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Function.kt")
|
||||
public void testFunction() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Function.kt");
|
||||
|
||||
+6
@@ -119,6 +119,12 @@ public class JvmRuntimeDescriptorLoaderTestGenerated extends AbstractJvmRuntimeD
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("EnumEntry.kt")
|
||||
public void testEnumEntry() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classMembers/EnumEntry.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Function.kt")
|
||||
public void testFunction() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Function.kt");
|
||||
|
||||
+7
-6
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||
import org.jetbrains.kotlin.serialization.jvm.ClassMapperLite
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.*
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil
|
||||
@@ -109,12 +110,12 @@ public abstract class AbstractBinaryClassAnnotationAndConstantLoader<A : Any, C
|
||||
return transformAnnotations(findClassAndLoadMemberAnnotations(container, proto, signature))
|
||||
}
|
||||
|
||||
override fun loadEnumEntryAnnotations(
|
||||
container: ProtoContainer,
|
||||
proto: ProtoBuf.EnumEntry
|
||||
): List<A> {
|
||||
// TODO
|
||||
return listOf()
|
||||
override fun loadEnumEntryAnnotations(container: ProtoContainer, proto: ProtoBuf.EnumEntry): List<A> {
|
||||
val signature = MemberSignature.fromFieldNameAndDesc(
|
||||
container.nameResolver.getString(proto.name),
|
||||
ClassMapperLite.mapClass(container.nameResolver.getClassId(container.classProto!!.fqName))
|
||||
)
|
||||
return findClassAndLoadMemberAnnotations(container, proto, signature)
|
||||
}
|
||||
|
||||
protected abstract fun loadPropertyAnnotations(propertyAnnotations: List<A>, fieldAnnotations: List<A>): List<T>
|
||||
|
||||
@@ -21,30 +21,30 @@ import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf
|
||||
|
||||
// The purpose of this class is to hold a unique signature of either a method or a field, so that annotations on a member can be put
|
||||
// into a map indexed by these signatures
|
||||
data class MemberSignature private constructor(private val signature: String) {
|
||||
internal data class MemberSignature private constructor(private val signature: String) {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
public fun fromMethod(nameResolver: NameResolver, signature: JvmProtoBuf.JvmMethodSignature): MemberSignature {
|
||||
fun fromMethod(nameResolver: NameResolver, signature: JvmProtoBuf.JvmMethodSignature): MemberSignature {
|
||||
return fromMethodNameAndDesc(nameResolver.getString(signature.name), nameResolver.getString(signature.desc))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun fromMethodNameAndDesc(name: String, desc: String): MemberSignature {
|
||||
fun fromMethodNameAndDesc(name: String, desc: String): MemberSignature {
|
||||
return MemberSignature(name + desc)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun fromMethodNameAndDesc(namePlusDesc: String): MemberSignature {
|
||||
fun fromMethodNameAndDesc(namePlusDesc: String): MemberSignature {
|
||||
return MemberSignature(namePlusDesc)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun fromFieldNameAndDesc(name: String, desc: String): MemberSignature {
|
||||
fun fromFieldNameAndDesc(name: String, desc: String): MemberSignature {
|
||||
return MemberSignature(name + "#" + desc)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun fromMethodSignatureAndParameterIndex(signature: MemberSignature, index: Int): MemberSignature {
|
||||
fun fromMethodSignatureAndParameterIndex(signature: MemberSignature, index: Int): MemberSignature {
|
||||
return MemberSignature(signature.signature + "@" + index)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +117,12 @@ public class ResolveByStubTestGenerated extends AbstractResolveByStubTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("EnumEntry.kt")
|
||||
public void testEnumEntry() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classMembers/EnumEntry.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Function.kt")
|
||||
public void testFunction() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Function.kt");
|
||||
|
||||
Reference in New Issue
Block a user