KT-1860 Resolve annotations of function parameters

#KT-1860 Fixed
This commit is contained in:
Andrey Breslav
2012-04-24 21:53:23 +04:00
parent 81387c0745
commit c686184847
4 changed files with 26 additions and 5 deletions
@@ -264,7 +264,7 @@ public class DescriptorResolver {
type = typeResolver.resolveType(parameterScope, typeReference, trace, true);
}
ValueParameterDescriptor valueParameterDescriptor = resolveValueParameterDescriptor(functionDescriptor, valueParameter, i, type, trace);
ValueParameterDescriptor valueParameterDescriptor = resolveValueParameterDescriptor(parameterScope, functionDescriptor, valueParameter, i, type, trace);
parameterScope.addVariableDescriptor(valueParameterDescriptor);
result.add(valueParameterDescriptor);
}
@@ -272,7 +272,7 @@ public class DescriptorResolver {
}
@NotNull
public MutableValueParameterDescriptor resolveValueParameterDescriptor(DeclarationDescriptor declarationDescriptor, JetParameter valueParameter, int index, JetType type, BindingTrace trace) {
public MutableValueParameterDescriptor resolveValueParameterDescriptor(JetScope scope, DeclarationDescriptor declarationDescriptor, JetParameter valueParameter, int index, JetType type, BindingTrace trace) {
JetType varargElementType = null;
JetType variableType = type;
if (valueParameter.hasModifier(JetTokens.VARARG_KEYWORD)) {
@@ -282,7 +282,7 @@ public class DescriptorResolver {
MutableValueParameterDescriptor valueParameterDescriptor = new ValueParameterDescriptorImpl(
declarationDescriptor,
index,
annotationResolver.createAnnotationStubs(valueParameter.getModifierList(), trace),
annotationResolver.resolveAnnotations(scope, valueParameter.getModifierList(), trace),
JetPsiUtil.safeName(valueParameter.getName()),
valueParameter.isMutable(),
variableType,
@@ -735,7 +735,7 @@ public class DescriptorResolver {
}
}
MutableValueParameterDescriptor valueParameterDescriptor = resolveValueParameterDescriptor(setterDescriptor, parameter, 0, type, trace);
MutableValueParameterDescriptor valueParameterDescriptor = resolveValueParameterDescriptor(scope, setterDescriptor, parameter, 0, type, trace);
setterDescriptor.initialize(valueParameterDescriptor);
}
else {
@@ -195,7 +195,8 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
type = ErrorUtils.createErrorType("Cannot be inferred");
}
}
ValueParameterDescriptor valueParameterDescriptor = context.expressionTypingServices.getDescriptorResolver().resolveValueParameterDescriptor(functionDescriptor, declaredParameter, i, type, context.trace);
ValueParameterDescriptor valueParameterDescriptor = context.expressionTypingServices.getDescriptorResolver().resolveValueParameterDescriptor(
context.scope, functionDescriptor, declaredParameter, i, type, context.trace);
valueParameterDescriptors.add(valueParameterDescriptor);
}
}
@@ -0,0 +1,9 @@
fun foo(<!UNRESOLVED_REFERENCE!>varargs<!> <!UNUSED_PARAMETER!>f<!> : Int) {}
var bar : Int = 1
set(<!UNRESOLVED_REFERENCE!>varargs<!> v) {}
val x : (Int) -> Int = {([<!UNRESOLVED_REFERENCE!>varargs<!>] x : Int) -> x}
class Hello(<!UNRESOLVED_REFERENCE!>varargs<!> args: Any) {
}
@@ -0,0 +1,11 @@
annotation class test {}
fun foo(test <!UNUSED_PARAMETER!>f<!> : Int) {}
var bar : Int = 1
set(test v) {}
val x : (Int) -> Int = {([test] x : Int) -> x}
class Hello(test args: Any) {
}