Use resolveAnnotations instead of getResolvedAnnotations for typeReference

This commit is contained in:
Natalia Ukhorskaya
2014-10-29 12:47:58 +03:00
parent 3aadd6f880
commit 7bb4e538a6
5 changed files with 23 additions and 18 deletions
@@ -364,23 +364,6 @@ public class AnnotationResolver {
return constants;
}
@SuppressWarnings("MethodMayBeStatic")
@NotNull
public Annotations getResolvedAnnotations(@NotNull List<JetAnnotationEntry> annotations, @NotNull BindingTrace trace) {
List<AnnotationDescriptor> result = new ArrayList<AnnotationDescriptor>(annotations.size());
for (JetAnnotationEntry annotation : annotations) {
AnnotationDescriptor annotationDescriptor = trace.get(BindingContext.ANNOTATION, annotation);
if (annotationDescriptor == null) {
throw new IllegalStateException("Annotation for annotation should have been resolved: \n" +
JetPsiUtil.getElementTextWithContext(annotation));
}
result.add(annotationDescriptor);
}
return new AnnotationsImpl(result);
}
public static void reportUnsupportedAnnotationForTypeParameter(@NotNull JetTypeParameter jetTypeParameter, @NotNull BindingTrace trace) {
JetModifierList modifierList = jetTypeParameter.getModifierList();
if (modifierList == null) return;
@@ -88,7 +88,7 @@ public class TypeResolver {
JetType cachedType = c.trace.getBindingContext().get(BindingContext.TYPE, typeReference);
if (cachedType != null) return type(cachedType);
Annotations annotations = annotationResolver.getResolvedAnnotations(typeReference.getAnnotations(), c.trace);
Annotations annotations = annotationResolver.resolveAnnotationsWithArguments(c.scope, typeReference.getAnnotations(), c.trace);
JetTypeElement typeElement = typeReference.getTypeElement();
PossiblyBareType type = resolveTypeElement(c, annotations, typeElement);
@@ -0,0 +1,6 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_PARAMETER
class A
fun [<!UNRESOLVED_REFERENCE!>x<!>] A.foo(a: [<!UNRESOLVED_REFERENCE!>x<!>] Int) {
val v: [<!UNRESOLVED_REFERENCE!>x<!>] Int = 1
}
@@ -0,0 +1,10 @@
package
internal fun A.foo(/*0*/ a: kotlin.Int): kotlin.Unit
internal final class A {
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
}
@@ -685,6 +685,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("typeAnnotations.kt")
public void testTypeAnnotations() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/typeAnnotations.kt");
doTest(fileName);
}
@TestMetadata("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)