Kapt: Allow Kotlin @Repeatable annotations (KT-22451)

We don't generate a wrapper for repeatable annotations, and Javac complains to it.
This commit is contained in:
Yan Zhulanow
2018-02-08 22:42:27 +03:00
parent a3a46fe259
commit edcf0aef53
4 changed files with 121 additions and 7 deletions
@@ -222,13 +222,15 @@ class KaptJavaLog(
private val KOTLIN_LOCATION_PREFIX = "Kotlin location: "
private val IGNORED_DIAGNOSTICS = setOf(
"compiler.err.name.clash.same.erasure",
"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.annotation.type.not.applicable",
"compiler.err.doesnt.exist")
"compiler.err.name.clash.same.erasure",
"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.annotation.type.not.applicable",
"compiler.err.doesnt.exist",
"compiler.err.duplicate.annotation.missing.container"
)
internal fun preRegister(kaptContext: KaptContext<*>, messageCollector: MessageCollector, mapDiagnosticLocations: Boolean) {
val interceptorData = DiagnosticInterceptorData()
@@ -55,6 +55,12 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
doTest(fileName);
}
@TestMetadata("annotations3.kt")
public void testAnnotations3() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/kapt3-compiler/testData/converter/annotations3.kt");
doTest(fileName);
}
@TestMetadata("comments.kt")
public void testComments() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/kapt3-compiler/testData/converter/comments.kt");
@@ -0,0 +1,18 @@
// WITH_RUNTIME
interface Parceler<T>
@Retention(AnnotationRetention.SOURCE)
@Repeatable
@Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY)
annotation class TypeParceler<T, P: Parceler<in T>>
@TypeParceler<B, BParceler>
@TypeParceler<C, CParceler>
class Test
class B
class C
object BParceler : Parceler<B>
object CParceler : Parceler<C>
@@ -0,0 +1,88 @@
import java.lang.System;
@kotlin.Metadata()
public final class B {
public B() {
super();
}
}
////////////////////
import java.lang.System;
@kotlin.Metadata()
public final class BParceler implements Parceler<B> {
public static final BParceler INSTANCE = null;
private BParceler() {
super();
}
}
////////////////////
import java.lang.System;
@kotlin.Metadata()
public final class C {
public C() {
super();
}
}
////////////////////
import java.lang.System;
@kotlin.Metadata()
public final class CParceler implements Parceler<C> {
public static final CParceler INSTANCE = null;
private CParceler() {
super();
}
}
////////////////////
import java.lang.System;
@kotlin.Metadata()
public abstract interface Parceler<T extends java.lang.Object> {
}
////////////////////
import java.lang.System;
@TypeParceler()
@TypeParceler()
@kotlin.Metadata()
public final class Test {
public Test() {
super();
}
}
////////////////////
import java.lang.System;
@kotlin.Metadata()
@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.TYPE})
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.SOURCE)
@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.CLASS, kotlin.annotation.AnnotationTarget.PROPERTY})
@kotlin.annotation.Repeatable()
@kotlin.annotation.Retention(value = kotlin.annotation.AnnotationRetention.SOURCE)
public abstract @interface TypeParceler<T extends java.lang.Object, P extends Parceler<? super T>> extends java.lang.annotation.Annotation {
}