Create proper annotation descriptors when annotation arguments don't match

This commit is contained in:
Andrey Breslav
2013-09-22 14:49:05 +04:00
parent 3d754dd788
commit 836eef67fa
5 changed files with 32 additions and 5 deletions
@@ -118,7 +118,7 @@ public class AnnotationResolver {
) {
TemporaryBindingTrace temporaryBindingTrace = new TemporaryBindingTrace(trace, "Trace for resolve annotation type");
OverloadResolutionResults<FunctionDescriptor> results = resolveAnnotationCall(entryElement, scope, temporaryBindingTrace);
if (results.isSuccess()) {
if (results.isSingleResult()) {
FunctionDescriptor descriptor = results.getResultingDescriptor();
if (!ErrorUtils.isError(descriptor)) {
if (descriptor instanceof ConstructorDescriptor) {
@@ -136,7 +136,9 @@ public class AnnotationResolver {
annotationDescriptor.setAnnotationType(annotationType);
}
else {
annotationDescriptor.setAnnotationType(ErrorUtils.createErrorType("Unresolved annotation type"));
JetConstructorCalleeExpression calleeExpression = entryElement.getCalleeExpression();
annotationDescriptor.setAnnotationType(ErrorUtils.createErrorType("Unresolved annotation type: " +
(calleeExpression == null ? "null" : calleeExpression.getText())));
}
}
@@ -176,7 +178,7 @@ public class AnnotationResolver {
@NotNull BindingTrace trace
) {
OverloadResolutionResults<FunctionDescriptor> results = resolveAnnotationCall(annotationEntry, scope, trace);
if (results.isSuccess()) {
if (results.isSingleResult()) {
AnnotationDescriptor annotationDescriptor = trace.getBindingContext().get(BindingContext.ANNOTATION, annotationEntry);
assert annotationDescriptor != null : "Annotation descriptor should be created before resolving arguments for " + annotationEntry.getText();
resolveAnnotationArgument(annotationDescriptor, results.getResultingCall(), trace);
@@ -1,8 +1,8 @@
package test
[ERROR : Unresolved annotation type]() internal val SomeObject: test.SomeObject
[ERROR : Unresolved annotation type: BadAnnotation]() internal val SomeObject: test.SomeObject
internal val some: test.SomeObject
[ERROR : Unresolved annotation type]() internal object SomeObject {
[ERROR : Unresolved annotation type: BadAnnotation]() internal object SomeObject {
/*primary*/ private constructor SomeObject()
}
@@ -0,0 +1,8 @@
package test
BadAnnotation(1)
object SomeObject
val some = SomeObject
annotation class BadAnnotation(s: String)
@@ -0,0 +1,12 @@
package test
test.BadAnnotation(s = 1.toInt(): jet.Int) internal val SomeObject: test.SomeObject
internal val some: test.SomeObject
internal final annotation class BadAnnotation : jet.Annotation {
/*primary*/ public constructor BadAnnotation(/*0*/ s: jet.String)
}
test.BadAnnotation(s = 1.toInt(): jet.Int) internal object SomeObject {
/*primary*/ private constructor SomeObject()
}
@@ -2409,6 +2409,11 @@ public class LazyResolveNamespaceComparingTestGenerated extends AbstractLazyReso
doTestCheckingPrimaryConstructors("compiler/testData/lazyResolve/namespaceComparator/varargIterator.kt");
}
@TestMetadata("WrongAnnotationArgsOnObject.kt")
public void testWrongAnnotationArgsOnObject() throws Exception {
doTestCheckingPrimaryConstructors("compiler/testData/lazyResolve/namespaceComparator/WrongAnnotationArgsOnObject.kt");
}
}
public static Test suite() {