diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/FunctionsHighlightingVisitor.java b/idea/src/org/jetbrains/jet/plugin/highlighter/FunctionsHighlightingVisitor.java
index b396ff14a15..c81a0ba1f2a 100644
--- a/idea/src/org/jetbrains/jet/plugin/highlighter/FunctionsHighlightingVisitor.java
+++ b/idea/src/org/jetbrains/jet/plugin/highlighter/FunctionsHighlightingVisitor.java
@@ -66,11 +66,13 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
ResolvedCall extends CallableDescriptor> resolvedCall =
bindingContext.get(BindingContext.RESOLVED_CALL, (JetReferenceExpression) callee);
if (resolvedCall != null) {
+ DeclarationDescriptor calleeDescriptor = resolvedCall.getResultingDescriptor();
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
- highlightVariableAsFunctionCall(callee, (VariableAsFunctionResolvedCall) resolvedCall);
+ JetPsiChecker.highlightName(holder, callee, containedInFunctionClassOrSubclass(calleeDescriptor)
+ ? JetHighlightingColors.VARIABLE_AS_FUNCTION_CALL
+ : JetHighlightingColors.VARIABLE_AS_FUNCTION_LIKE_CALL);
}
else {
- DeclarationDescriptor calleeDescriptor = resolvedCall.getResultingDescriptor();
if (calleeDescriptor instanceof ConstructorDescriptor) {
JetPsiChecker.highlightName(holder, callee, JetHighlightingColors.CONSTRUCTOR_CALL);
}
@@ -91,25 +93,6 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
super.visitCallExpression(expression);
}
- private void highlightVariableAsFunctionCall(JetExpression callee, VariableAsFunctionResolvedCall resolvedCall) {
- VariableDescriptor variableDescriptor = resolvedCall.getVariableCall().getResultingDescriptor();
-
- String kind = variableDescriptor instanceof ValueParameterDescriptor
- ? "parameter"
- : variableDescriptor instanceof PropertyDescriptor
- ? "property"
- : "variable";
-
- if (containedInFunctionClassOrSubclass(resolvedCall.getFunctionCall().getResultingDescriptor())) {
- holder.createInfoAnnotation(callee, "Calling " + kind + " as function").setTextAttributes(
- JetHighlightingColors.VARIABLE_AS_FUNCTION_CALL);
- }
- else {
- holder.createInfoAnnotation(callee, "Calling " + kind + " as function-like").setTextAttributes(
- JetHighlightingColors.VARIABLE_AS_FUNCTION_LIKE_CALL);
- }
- }
-
private static boolean containedInFunctionClassOrSubclass(DeclarationDescriptor calleeDescriptor) {
DeclarationDescriptor parent = calleeDescriptor.getContainingDeclaration();
if (!(parent instanceof ClassDescriptor)) {
diff --git a/idea/testData/checker/infos/VariableAsFunction.kt b/idea/testData/checker/infos/VariableAsFunction.kt
deleted file mode 100644
index 04104a1a7bf..00000000000
--- a/idea/testData/checker/infos/VariableAsFunction.kt
+++ /dev/null
@@ -1,21 +0,0 @@
-class FunctionLike {
- fun invoke() {
- }
-}
-
-val property = {}
-
-fun foo(param: (Int) -> Int, functionLike: FunctionLike) {
- param(1)
- functionLike()
-
- val v1 = param
- var v2 = param
-
- v1(1)
- v2(1)
-
- property();
-
- {}() //should not be highlighted as "calling variable as function"
-}
\ No newline at end of file
diff --git a/idea/testData/highlighter/VariablesAsFunctions.kt b/idea/testData/highlighter/VariablesAsFunctions.kt
index 3a133d4a695..029a52de78e 100644
--- a/idea/testData/highlighter/VariablesAsFunctions.kt
+++ b/idea/testData/highlighter/VariablesAsFunctions.kt
@@ -1,3 +1,8 @@
+trait FunctionLike {
+ fun invoke() {
+ }
+}
+
var global : () -> Unit = {}
val Int.ext : () -> Unit
@@ -5,8 +10,11 @@ val Int.foo(a : () -> Unit) {
+fun foo(a : () -> Unit, functionLike: FunctionLike) {
a()
+ functionLike()
global()
- 1.ext()
+ 1.ext();
+
+ {}() //should not be highlighted as "calling variable as function"!
}
\ No newline at end of file
diff --git a/idea/tests/org/jetbrains/jet/checkers/JetPsiCheckerTestGenerated.java b/idea/tests/org/jetbrains/jet/checkers/JetPsiCheckerTestGenerated.java
index eb1bf090847..6479d073a74 100644
--- a/idea/tests/org/jetbrains/jet/checkers/JetPsiCheckerTestGenerated.java
+++ b/idea/tests/org/jetbrains/jet/checkers/JetPsiCheckerTestGenerated.java
@@ -422,11 +422,6 @@ public class JetPsiCheckerTestGenerated extends AbstractJetPsiCheckerTest {
doTestWithInfos("idea/testData/checker/infos/PropertiesWithBackingFields.kt");
}
- @TestMetadata("VariableAsFunction.kt")
- public void testVariableAsFunction() throws Exception {
- doTestWithInfos("idea/testData/checker/infos/VariableAsFunction.kt");
- }
-
@TestMetadata("WrapIntoRef.kt")
public void testWrapIntoRef() throws Exception {
doTestWithInfos("idea/testData/checker/infos/WrapIntoRef.kt");