Check annotations on type arguments

This commit is contained in:
Svetlana Isakova
2015-10-15 16:37:43 +03:00
parent 6c4771147a
commit b401d46ae4
6 changed files with 21 additions and 4 deletions
@@ -42,6 +42,9 @@ public class AnnotationChecker(private val additionalCheckers: Iterable<Addition
annotated.typeReference?.let { check(it, trace) }
annotated.receiverTypeReference?.let { check(it, trace) }
}
if (annotated is JetTypeReference) {
annotated.typeElement?.typeArgumentsAsTypes?.filterNotNull()?.forEach { check(it, trace) }
}
if (annotated is JetDeclarationWithBody) {
// JetFunction or JetPropertyAccessor
for (parameter in annotated.valueParameters) {
@@ -37,7 +37,7 @@ val baz2: @[a b(1)] Int? = 1
fun foo3(i: <!WRONG_ANNOTATION_TARGET!>@c<!> Int?) {}
fun foo3(l: List<@c Int?>) {}
fun foo3(l: List<<!WRONG_ANNOTATION_TARGET!>@c<!> Int?>) {}
fun <!WRONG_ANNOTATION_TARGET!>@c<!> Int?.bar3() {}
@@ -1,5 +1,6 @@
// This test checks that annotations on extension function types are preserved. See the corresponding .txt file
@Target(AnnotationTarget.TYPE)
annotation class ann
interface Some {
@@ -10,7 +10,7 @@ public interface Some {
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@kotlin.annotation.annotation() public final class ann : kotlin.Annotation {
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) @kotlin.annotation.annotation() public final class ann : kotlin.Annotation {
public constructor ann()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -1,5 +1,10 @@
annotation class base
val x: List<@base String>? = null
val x: List<<!WRONG_ANNOTATION_TARGET!>@base<!> String>? = null
val y: List<@[base] String>? = null
val y: List<@[<!WRONG_ANNOTATION_TARGET!>base<!>] String>? = null
@Target(AnnotationTarget.TYPE)
annotation class typeAnn
fun foo(list: List<@typeAnn Int>) = list
@@ -2,6 +2,7 @@ package
public val x: kotlin.List<@base() kotlin.String>? = null
public val y: kotlin.List<@base() kotlin.String>? = null
public fun foo(/*0*/ list: kotlin.List<@typeAnn() kotlin.Int>): kotlin.List<@typeAnn() kotlin.Int>
@kotlin.annotation.annotation() public final class base : kotlin.Annotation {
public constructor base()
@@ -9,3 +10,10 @@ public val y: kotlin.List<@base() kotlin.String>? = null
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) @kotlin.annotation.annotation() public final class typeAnn : kotlin.Annotation {
public constructor typeAnn()
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
}