Kapt3: Allow annotations with Kotlin-only targets, such as PROPERTY (KT-15697)

This commit is contained in:
Yan Zhulanow
2017-01-31 19:47:52 +03:00
committed by Yan Zhulanow
parent 6ded5939eb
commit 1819194a4c
9 changed files with 24 additions and 3 deletions
@@ -45,7 +45,8 @@ class KaptJavaLog(
"compiler.err.name.clash.same.erasure.no.override",
"compiler.err.name.clash.same.erasure.no.override.1",
"compiler.err.name.clash.same.erasure.no.hide",
"compiler.err.already.defined")
"compiler.err.already.defined",
"compiler.err.annotation.type.not.applicable")
internal fun preRegister(context: Context, messageCollector: MessageCollector) {
context.put(Log.logKey, Context.Factory<Log> {
@@ -66,7 +66,6 @@ class ClassFileToSourceStubConverter(
"java.lang.Deprecated", "kotlin.Deprecated", // Deprecated annotations
"java.lang.Synthetic",
"synthetic.kotlin.jvm.GeneratedByJvmOverloads", // kapt3-related annotation for marking JvmOverloads-generated methods
"java.lang.annotation.", // Java annotations
"kotlin.jvm.", "kotlin.Metadata" // Kotlin annotations from runtime
)
+3
View File
@@ -1,9 +1,11 @@
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
public abstract @interface Anno1 {
}
////////////////////
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
public abstract @interface Anno2 {
public abstract int i() default 5;
@@ -28,6 +30,7 @@ public abstract @interface Anno2 {
////////////////////
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
public abstract @interface Anno3 {
public abstract java.lang.String value();
+1
View File
@@ -1,5 +1,6 @@
package test;
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
@Anno(value = "anno-class")
public abstract @interface Anno {
+1
View File
@@ -1,3 +1,4 @@
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
public abstract @interface Anno1 {
public abstract java.lang.String value();
+4 -1
View File
@@ -1,6 +1,9 @@
annotation class Anno
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.CLASS)
annotation class Anno2
class Test {
@property:Anno
@property:[Anno Anno2]
val prop = "A"
}
@@ -1,13 +1,24 @@
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
public abstract @interface Anno {
}
////////////////////
@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.TYPE})
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.PROPERTY, kotlin.annotation.AnnotationTarget.CLASS})
public abstract @interface Anno2 {
}
////////////////////
public final class Test {
@org.jetbrains.annotations.NotNull()
private final java.lang.String prop = "A";
@Anno2()
@Anno()
private static void prop$annotations() {
}
+1
View File
@@ -1,5 +1,6 @@
package test.another;
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
public abstract @interface Anno {
public abstract java.lang.String value();
@@ -1,5 +1,6 @@
package test;
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
public abstract @interface MyAnnotation {
}