KT-2906 If function parameter/variable is invoked in closure using parenthesis syntax, in IDEA it is not highlighted as captured in closure
#KT-2906 fixed
This commit is contained in:
@@ -39,6 +39,7 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices;
|
||||
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||
@@ -149,6 +150,8 @@ public class CallResolver {
|
||||
JetSimpleNameExpression expression = (JetSimpleNameExpression) calleeExpression;
|
||||
functionReference = expression;
|
||||
|
||||
ExpressionTypingUtils.checkWrappingInRef(expression, context.trace, context.scope);
|
||||
|
||||
Name name = expression.getReferencedNameAsName();
|
||||
if (name == null) return checkArgumentTypesAndFail(context);
|
||||
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
// TODO : type substitutions???
|
||||
JetTypeInfo typeInfo = getSelectorReturnTypeInfo(NO_RECEIVER, null, expression, context);
|
||||
JetType type = DataFlowUtils.checkType(typeInfo.getType(), expression, context);
|
||||
ExpressionTypingUtils.checkWrappingInRef(expression, context);
|
||||
ExpressionTypingUtils.checkWrappingInRef(expression, context.trace, context.scope);
|
||||
return JetTypeInfo.create(type, typeInfo.getDataFlowInfo()); // TODO : Extensions to this
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -137,12 +137,12 @@ public class ExpressionTypingUtils {
|
||||
).contains(expression.getNode().getElementType());
|
||||
}
|
||||
|
||||
public static void checkWrappingInRef(JetSimpleNameExpression expression, ExpressionTypingContext context) {
|
||||
VariableDescriptor variable = BindingContextUtils.extractVariableDescriptorIfAny(context.trace.getBindingContext(), expression, true);
|
||||
public static void checkWrappingInRef(JetSimpleNameExpression expression, BindingTrace trace, JetScope scope) {
|
||||
VariableDescriptor variable = BindingContextUtils.extractVariableDescriptorIfAny(trace.getBindingContext(), expression, true);
|
||||
if (variable != null) {
|
||||
DeclarationDescriptor containingDeclaration = variable.getContainingDeclaration();
|
||||
if (context.scope.getContainingDeclaration() != containingDeclaration && containingDeclaration instanceof CallableDescriptor) {
|
||||
context.trace.record(CAPTURED_IN_CLOSURE, variable);
|
||||
if (scope.getContainingDeclaration() != containingDeclaration && containingDeclaration instanceof CallableDescriptor) {
|
||||
trace.record(CAPTURED_IN_CLOSURE, variable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user