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