diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java index 5f703fe203e..8ce55f494e2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java @@ -180,13 +180,13 @@ public class AnnotationResolver { } @NotNull - public JetType resolveAnnotationType(@NotNull LexicalScope scope, @NotNull JetAnnotationEntry entryElement) { + public JetType resolveAnnotationType(@NotNull LexicalScope scope, @NotNull JetAnnotationEntry entryElement, @NotNull BindingTrace trace) { JetTypeReference typeReference = entryElement.getTypeReference(); if (typeReference == null) { return ErrorUtils.createErrorType("No type reference: " + entryElement.getText()); } - JetType type = typeResolver.resolveType(scope, typeReference, new BindingTraceContext(), true); + JetType type = typeResolver.resolveType(scope, typeReference, trace, true); if (!(type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor)) { return ErrorUtils.createErrorType("Not an annotation: " + type); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt index aa33fbffa6c..b692c7ba434 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt @@ -122,7 +122,8 @@ public class LazyAnnotationDescriptor( private val type = c.storageManager.createLazyValue { c.annotationResolver.resolveAnnotationType( c.scope, - annotationEntry + annotationEntry, + c.trace ) } diff --git a/compiler/testData/diagnostics/tests/annotations/typeAnnotations.kt b/compiler/testData/diagnostics/tests/annotations/typeAnnotations.kt index 81718795d30..d0e22f7c574 100644 --- a/compiler/testData/diagnostics/tests/annotations/typeAnnotations.kt +++ b/compiler/testData/diagnostics/tests/annotations/typeAnnotations.kt @@ -1,6 +1,15 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_PARAMETER class A -fun @x A.foo(a: @x Int) { - val v: @x Int = 1 -} \ No newline at end of file +@Target(AnnotationTarget.TYPE) +annotation class x + +fun @x A.foo(a: @x Int) { + val v: @x Int = 1 +} + +fun @x List<@x T>.foo(l: List<@x T>): @x List<@x T> = throw Exception() + +fun List<@x T>.firstTyped(): U = throw Exception() + +val @x List<@x T>.f: Int get() = 42 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/typeAnnotations.txt b/compiler/testData/diagnostics/tests/annotations/typeAnnotations.txt index 6e65f67e336..52569f6d4d6 100644 --- a/compiler/testData/diagnostics/tests/annotations/typeAnnotations.txt +++ b/compiler/testData/diagnostics/tests/annotations/typeAnnotations.txt @@ -1,6 +1,9 @@ package -public fun @[ERROR : x]() A.foo(/*0*/ a: @[ERROR : x]() kotlin.Int): kotlin.Unit +public val @x() kotlin.List<@x() T>.f: kotlin.Int +public fun kotlin.List<@x() T>.firstTyped(): U +public fun @x() A.foo(/*0*/ a: @x() kotlin.Int): kotlin.Unit +public fun @x() kotlin.List<@x() T>.foo(/*0*/ l: kotlin.List<@x() T>): @x() kotlin.List<@x() T> public final class A { public constructor A() @@ -8,3 +11,10 @@ public final class A { 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 x : kotlin.Annotation { + public constructor x() + 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 +}