Fix tests with type annotations

This commit is contained in:
Svetlana Isakova
2015-10-17 15:48:38 +03:00
parent fafca76ac5
commit 7208efc784
4 changed files with 27 additions and 7 deletions
@@ -180,13 +180,13 @@ public class AnnotationResolver {
} }
@NotNull @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(); JetTypeReference typeReference = entryElement.getTypeReference();
if (typeReference == null) { if (typeReference == null) {
return ErrorUtils.createErrorType("No type reference: " + entryElement.getText()); 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)) { if (!(type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor)) {
return ErrorUtils.createErrorType("Not an annotation: " + type); return ErrorUtils.createErrorType("Not an annotation: " + type);
} }
@@ -122,7 +122,8 @@ public class LazyAnnotationDescriptor(
private val type = c.storageManager.createLazyValue { private val type = c.storageManager.createLazyValue {
c.annotationResolver.resolveAnnotationType( c.annotationResolver.resolveAnnotationType(
c.scope, c.scope,
annotationEntry annotationEntry,
c.trace
) )
} }
@@ -1,6 +1,15 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_PARAMETER // !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_PARAMETER
class A class A
fun <!UNRESOLVED_REFERENCE!>@x<!> A.foo(a: <!UNRESOLVED_REFERENCE!>@x<!> Int) { @Target(AnnotationTarget.TYPE)
val v: <!UNRESOLVED_REFERENCE!>@x<!> Int = 1 annotation class x
fun @x A.foo(a: @x Int) {
val v: @x Int = 1
} }
fun <T> @x List<@x T>.foo(l: List<@x T>): @x List<@x T> = throw Exception()
fun <T, U: T> List<@x T>.firstTyped(): U = throw Exception()
val <T> @x List<@x T>.f: Int get() = 42
@@ -1,6 +1,9 @@
package package
public fun @[ERROR : x]() A.foo(/*0*/ a: @[ERROR : x]() kotlin.Int): kotlin.Unit public val </*0*/ T> @x() kotlin.List<@x() T>.f: kotlin.Int
public fun </*0*/ T, /*1*/ U : T> kotlin.List<@x() T>.firstTyped(): U
public fun @x() A.foo(/*0*/ a: @x() kotlin.Int): kotlin.Unit
public fun </*0*/ T> @x() kotlin.List<@x() T>.foo(/*0*/ l: kotlin.List<@x() T>): @x() kotlin.List<@x() T>
public final class A { public final class A {
public constructor 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 hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String 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
}