Fixed annotation resolve for loop parameter or catched exceptions type
This commit is contained in:
@@ -612,6 +612,8 @@ public class DescriptorResolver {
|
||||
toSourceElement(parameter)
|
||||
);
|
||||
trace.record(BindingContext.VALUE_PARAMETER, parameter, variableDescriptor);
|
||||
// Type annotations also should be resolved
|
||||
AnnotationResolver.resolveAnnotationsArguments(type.getAnnotations());
|
||||
return variableDescriptor;
|
||||
}
|
||||
|
||||
@@ -623,6 +625,8 @@ public class DescriptorResolver {
|
||||
BindingTrace trace
|
||||
) {
|
||||
DeclarationDescriptor containingDeclaration = scope.getContainingDeclaration();
|
||||
VariableDescriptor result;
|
||||
JetType type;
|
||||
// SCRIPT: Create property descriptors
|
||||
if (JetPsiUtil.isScriptDeclaration(variable)) {
|
||||
PropertyDescriptorImpl propertyDescriptor = PropertyDescriptorImpl.create(
|
||||
@@ -635,25 +639,26 @@ public class DescriptorResolver {
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
toSourceElement(variable)
|
||||
);
|
||||
|
||||
JetType type =
|
||||
getVariableType(propertyDescriptor, scope, variable, dataFlowInfo, false, trace); // For a local variable the type must not be deferred
|
||||
// For a local variable the type must not be deferred
|
||||
type = getVariableType(propertyDescriptor, scope, variable, dataFlowInfo, false, trace);
|
||||
|
||||
ReceiverParameterDescriptor receiverParameter = ((ScriptDescriptor) containingDeclaration).getThisAsReceiverParameter();
|
||||
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(), receiverParameter, (JetType) null);
|
||||
initializeWithDefaultGetterSetter(propertyDescriptor);
|
||||
trace.record(BindingContext.VARIABLE, variable, propertyDescriptor);
|
||||
return propertyDescriptor;
|
||||
result = propertyDescriptor;
|
||||
}
|
||||
else {
|
||||
VariableDescriptorImpl variableDescriptor =
|
||||
resolveLocalVariableDescriptorWithType(scope, variable, null, trace);
|
||||
|
||||
JetType type =
|
||||
getVariableType(variableDescriptor, scope, variable, dataFlowInfo, false, trace); // For a local variable the type must not be deferred
|
||||
// For a local variable the type must not be deferred
|
||||
type = getVariableType(variableDescriptor, scope, variable, dataFlowInfo, false, trace);
|
||||
variableDescriptor.setOutType(type);
|
||||
return variableDescriptor;
|
||||
result = variableDescriptor;
|
||||
}
|
||||
// Type annotations also should be resolved
|
||||
AnnotationResolver.resolveAnnotationsArguments(type.getAnnotations());
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void initializeWithDefaultGetterSetter(PropertyDescriptorImpl propertyDescriptor) {
|
||||
|
||||
-1
@@ -136,7 +136,6 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
||||
|
||||
VariableDescriptor propertyDescriptor = components.descriptorResolver.
|
||||
resolveLocalVariableDescriptor(scope, property, context.dataFlowInfo, context.trace);
|
||||
AnnotationResolver.resolveAnnotationsArguments(propertyDescriptor.getType().getAnnotations());
|
||||
JetExpression initializer = property.getInitializer();
|
||||
JetTypeInfo typeInfo;
|
||||
if (initializer != null) {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
annotation class My
|
||||
|
||||
fun foo() {
|
||||
for (i: @My Int in 0..41) {
|
||||
if (i == 13) return
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
internal fun foo(): kotlin.Unit
|
||||
|
||||
internal final annotation class My : kotlin.Annotation {
|
||||
public constructor My()
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
annotation class My
|
||||
|
||||
fun foo(arg: Int): Int {
|
||||
try {
|
||||
return 1 / (arg - arg)
|
||||
} catch (e: @My Exception) {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
internal fun foo(/*0*/ arg: kotlin.Int): kotlin.Int
|
||||
|
||||
internal final annotation class My : kotlin.Annotation {
|
||||
public constructor My()
|
||||
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
|
||||
}
|
||||
@@ -627,12 +627,24 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("AnnotatedLoop.kt")
|
||||
public void testAnnotatedLoop() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/AnnotatedLoop.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("AnnotatedResultType.kt")
|
||||
public void testAnnotatedResultType() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("AnnotatedTryCatch.kt")
|
||||
public void testAnnotatedTryCatch() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/AnnotatedTryCatch.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("AnnotationForClassTypeParameter.kt")
|
||||
public void testAnnotationForClassTypeParameter() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.kt");
|
||||
|
||||
Reference in New Issue
Block a user