Check for repeated annotations in type alias declaration.

This commit is contained in:
Dmitry Petrov
2016-10-18 08:59:38 +03:00
parent c2554bd30e
commit 5531762ab1
4 changed files with 22 additions and 0 deletions
@@ -46,6 +46,9 @@ class AnnotationChecker(private val additionalCheckers: Iterable<AdditionalAnnot
annotated.typeReference?.let { check(it, trace) }
annotated.receiverTypeReference?.let { check(it, trace) }
}
if (annotated is KtTypeAlias) {
annotated.getTypeReference()?.let { check(it, trace) }
}
if (annotated is KtTypeParameterListOwner && annotated is KtCallableDeclaration) {
// TODO: support type parameter annotations for type parameters on classes and properties
annotated.typeParameters.forEach { check(it, trace) }
@@ -0,0 +1,4 @@
@Target(AnnotationTarget.TYPE)
annotation class A
typealias Test1 = @A <!REPEATED_ANNOTATION!>@A<!> Int
@@ -0,0 +1,9 @@
package
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class A : kotlin.Annotation {
public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public typealias Test1 = @A @A kotlin.Int
@@ -20910,6 +20910,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("typealiasRhsRepeatedAnnotations.kt")
public void testTypealiasRhsRepeatedAnnotations() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typealiasRhsRepeatedAnnotations.kt");
doTest(fileName);
}
@TestMetadata("unsupportedTypeAlias.kt")
public void testUnsupportedTypeAlias() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/unsupportedTypeAlias.kt");