diff --git a/compiler/frontend/src/org/jetbrains/jet/checkers/DebugInfoUtil.java b/compiler/frontend/src/org/jetbrains/jet/checkers/DebugInfoUtil.java
index 1931e7c7950..b8afe6ee88d 100644
--- a/compiler/frontend/src/org/jetbrains/jet/checkers/DebugInfoUtil.java
+++ b/compiler/frontend/src/org/jetbrains/jet/checkers/DebugInfoUtil.java
@@ -23,18 +23,16 @@ import com.intellij.psi.tree.TokenSet;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.JetNodeTypes;
-import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
-import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor;
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory;
import org.jetbrains.jet.lang.diagnostics.Errors;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
+import org.jetbrains.jet.lang.resolve.calls.tasks.TasksPackage;
import org.jetbrains.jet.lang.types.ErrorUtils;
import org.jetbrains.jet.lang.types.JetType;
-import org.jetbrains.jet.lang.types.TypesPackage;
import org.jetbrains.jet.lexer.JetTokens;
import java.util.Collection;
@@ -119,12 +117,8 @@ public class DebugInfoUtil {
if (declarationDescriptor != null) {
target = declarationDescriptor.toString();
- if (declarationDescriptor instanceof CallableDescriptor) {
- CallableDescriptor callableDescriptor = (CallableDescriptor) declarationDescriptor;
- ReceiverParameterDescriptor dispatchReceiverParameter = callableDescriptor.getDispatchReceiverParameter();
- if (dispatchReceiverParameter != null && TypesPackage.isDynamic(dispatchReceiverParameter.getReturnType())) {
- debugInfoReporter.reportDynamicCall(expression);
- }
+ if (TasksPackage.isDynamic(declarationDescriptor)) {
+ debugInfoReporter.reportDynamicCall(expression);
}
}
if (target == null) {
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/dynamicCalls.kt b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/dynamicCalls.kt
index 4a634c1d5bc..006f3fa07b9 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/dynamicCalls.kt
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/dynamicCalls.kt
@@ -38,6 +38,7 @@ import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.jet.lang.types.JetType
import kotlin.platform.platformStatic
import org.jetbrains.jet.lang.resolve.scopes.receivers.TransientReceiver
+import org.jetbrains.jet.lang.types.isDynamic
object DynamicCallableDescriptors {
@@ -123,4 +124,11 @@ object DynamicCallableDescriptors {
SourceElement.NO_SOURCE
)
}
-}
\ No newline at end of file
+}
+
+fun DeclarationDescriptor.isDynamic(): Boolean {
+ if (this !is CallableDescriptor) return false
+ val dispatchReceiverParameter = getDispatchReceiverParameter()
+ return dispatchReceiverParameter != null && dispatchReceiverParameter.getType().isDynamic()
+}
+
diff --git a/idea/idea-analysis/src/org/jetbrains/jet/plugin/JetBundle.properties b/idea/idea-analysis/src/org/jetbrains/jet/plugin/JetBundle.properties
index 8007f7c5c83..1ebb0cf7f85 100644
--- a/idea/idea-analysis/src/org/jetbrains/jet/plugin/JetBundle.properties
+++ b/idea/idea-analysis/src/org/jetbrains/jet/plugin/JetBundle.properties
@@ -159,9 +159,11 @@ options.kotlin.attribute.descriptor.package.property=Package-level property
options.kotlin.attribute.descriptor.property.with.backing=Property with backing field
options.kotlin.attribute.descriptor.backing.field.access=Backing field access
options.kotlin.attribute.descriptor.extension.property=Extension property
+options.kotlin.attribute.descriptor.dynamic.property=Dynamic property
options.kotlin.attribute.descriptor.it=Function literal default parameter
options.kotlin.attribute.descriptor.fun=Function declaration
options.kotlin.attribute.descriptor.fun.call=Function call
+options.kotlin.attribute.descriptor.dynamic.fun.call=Dynamic function call
options.kotlin.attribute.descriptor.package.fun.call=Package-level function call
options.kotlin.attribute.descriptor.extension.fun.call=Extension function call
options.kotlin.attribute.descriptor.constructor.call=Constructor call
diff --git a/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/FunctionsHighlightingVisitor.java b/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/FunctionsHighlightingVisitor.java
index 85999cace1a..161e46b7398 100644
--- a/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/FunctionsHighlightingVisitor.java
+++ b/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/FunctionsHighlightingVisitor.java
@@ -19,16 +19,14 @@ package org.jetbrains.jet.plugin.highlighter;
import com.intellij.lang.annotation.AnnotationHolder;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
-import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor;
-import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
-import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
+import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall;
+import org.jetbrains.jet.lang.resolve.calls.tasks.TasksPackage;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeUtils;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
@@ -69,8 +67,12 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
JetExpression callee = expression.getCalleeExpression();
ResolvedCall> resolvedCall = CallUtilPackage.getResolvedCall(expression, bindingContext);
if (callee instanceof JetReferenceExpression && resolvedCall != null) {
- DeclarationDescriptor calleeDescriptor = resolvedCall.getResultingDescriptor();
- if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
+ CallableDescriptor calleeDescriptor = resolvedCall.getResultingDescriptor();
+
+ if (TasksPackage.isDynamic(calleeDescriptor)) {
+ JetPsiChecker.highlightName(holder, callee, JetHighlightingColors.DYNAMIC_FUNCTION_CALL);
+ }
+ else if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
JetPsiChecker.highlightName(holder, callee, containedInFunctionClassOrSubclass(calleeDescriptor)
? JetHighlightingColors.VARIABLE_AS_FUNCTION_CALL
: JetHighlightingColors.VARIABLE_AS_FUNCTION_LIKE_CALL);
diff --git a/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java b/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java
index 9321f31f9fd..68320d48dce 100644
--- a/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java
+++ b/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java
@@ -66,6 +66,7 @@ public class JetHighlightingColors {
public static final TextAttributesKey PROPERTY_WITH_BACKING_FIELD = createTextAttributesKey("KOTLIN_PROPERTY_WITH_BACKING_FIELD");
public static final TextAttributesKey BACKING_FIELD_ACCESS = createTextAttributesKey("KOTLIN_BACKING_FIELD_ACCESS");
public static final TextAttributesKey EXTENSION_PROPERTY = createTextAttributesKey("KOTLIN_EXTENSION_PROPERTY");
+ public static final TextAttributesKey DYNAMIC_PROPERTY_CALL = createTextAttributesKey("KOTLIN_DYNAMIC_PROPERTY_CALL");
// functions
public static final TextAttributesKey FUNCTION_LITERAL_DEFAULT_PARAMETER = createTextAttributesKey("KOTLIN_CLOSURE_DEFAULT_PARAMETER");
@@ -74,6 +75,7 @@ public class JetHighlightingColors {
public static final TextAttributesKey PACKAGE_FUNCTION_CALL = createTextAttributesKey("KOTLIN_PACKAGE_FUNCTION_CALL", CodeInsightColors.STATIC_METHOD_ATTRIBUTES);
public static final TextAttributesKey EXTENSION_FUNCTION_CALL = createTextAttributesKey("KOTLIN_EXTENSION_FUNCTION_CALL");
public static final TextAttributesKey CONSTRUCTOR_CALL = createTextAttributesKey("KOTLIN_CONSTRUCTOR", CodeInsightColors.CONSTRUCTOR_CALL_ATTRIBUTES);
+ public static final TextAttributesKey DYNAMIC_FUNCTION_CALL = createTextAttributesKey("KOTLIN_DYNAMIC_FUNCTION_CALL");
public static final TextAttributesKey VARIABLE_AS_FUNCTION_CALL = createTextAttributesKey("KOTLIN_VARIABLE_AS_FUNCTION");
public static final TextAttributesKey VARIABLE_AS_FUNCTION_LIKE_CALL = createTextAttributesKey("KOTLIN_VARIABLE_AS_FUNCTION_LIKE");
diff --git a/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/PropertiesHighlightingVisitor.java b/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/PropertiesHighlightingVisitor.java
index 9bdaa1c26b3..8d92dd12211 100644
--- a/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/PropertiesHighlightingVisitor.java
+++ b/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/PropertiesHighlightingVisitor.java
@@ -28,6 +28,7 @@ import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
import org.jetbrains.jet.lang.psi.JetThisExpression;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
+import org.jetbrains.jet.lang.resolve.calls.tasks.TasksPackage;
import org.jetbrains.jet.lexer.JetTokens;
class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
@@ -82,6 +83,11 @@ class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
@NotNull PropertyDescriptor descriptor,
boolean withBackingField
) {
+ if (TasksPackage.isDynamic(descriptor)) {
+ JetPsiChecker.highlightName(holder, elementToHighlight, JetHighlightingColors.DYNAMIC_PROPERTY_CALL);
+ return;
+ }
+
boolean isStatic = DescriptorUtils.isStaticDeclaration(descriptor);
JetPsiChecker.highlightName(
holder, elementToHighlight,
diff --git a/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/TypeKindHighlightingVisitor.java b/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/TypeKindHighlightingVisitor.java
index 1e459b9409f..187f63e8e67 100644
--- a/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/TypeKindHighlightingVisitor.java
+++ b/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/TypeKindHighlightingVisitor.java
@@ -81,6 +81,11 @@ class TypeKindHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
super.visitClass(klass);
}
+ @Override
+ public void visitDynamicType(@NotNull JetDynamicType type) {
+ // Do nothing: 'dynamic' is highlighted as a keyword
+ }
+
private void highlightName(@NotNull PsiElement whatToHighlight, @NotNull TextAttributesKey textAttributesKey) {
JetPsiChecker.highlightName(holder, whatToHighlight, textAttributesKey);
}
diff --git a/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/VariablesHighlightingVisitor.java b/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/VariablesHighlightingVisitor.java
index cbec4af4820..1172f2b07a3 100644
--- a/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/VariablesHighlightingVisitor.java
+++ b/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/VariablesHighlightingVisitor.java
@@ -25,6 +25,7 @@ import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
import org.jetbrains.jet.lang.descriptors.impl.LocalVariableDescriptor;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
+import org.jetbrains.jet.lang.resolve.calls.tasks.TasksPackage;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.expressions.CaptureKind;
import org.jetbrains.jet.renderer.DescriptorRenderer;
@@ -87,6 +88,12 @@ class VariablesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
private void highlightVariable(@NotNull PsiElement elementToHighlight, @NotNull DeclarationDescriptor descriptor) {
if (descriptor instanceof VariableDescriptor) {
VariableDescriptor variableDescriptor = (VariableDescriptor) descriptor;
+
+ if (TasksPackage.isDynamic(variableDescriptor)) {
+ JetPsiChecker.highlightName(holder, elementToHighlight, JetHighlightingColors.DYNAMIC_PROPERTY_CALL);
+ return;
+ }
+
if (variableDescriptor.isVar()) {
JetPsiChecker.highlightName(holder, elementToHighlight, JetHighlightingColors.MUTABLE_VARIABLE);
}
diff --git a/idea/resources/colorScheme/Darcula_Kotlin.xml b/idea/resources/colorScheme/Darcula_Kotlin.xml
index ae1099b441e..79741151794 100644
--- a/idea/resources/colorScheme/Darcula_Kotlin.xml
+++ b/idea/resources/colorScheme/Darcula_Kotlin.xml
@@ -30,6 +30,18 @@
+
+
+
+
+
+
+
diff --git a/idea/resources/colorScheme/Default_Kotlin.xml b/idea/resources/colorScheme/Default_Kotlin.xml
index 7eb82f5c3e9..db7419810d2 100644
--- a/idea/resources/colorScheme/Default_Kotlin.xml
+++ b/idea/resources/colorScheme/Default_Kotlin.xml
@@ -30,6 +30,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java b/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java
index fd10ce9b9d5..d4b905ca6a5 100644
--- a/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java
+++ b/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java
@@ -58,7 +58,7 @@ public class JetColorSettingsPage implements ColorSettingsPage {
" */\n" +
"[Deprecated]\n" +
"public class MyClass<out T : Iterable<T>>(var prop1 : Int) {\n" +
- " fun foo(nullable : String?, r : Runnable, f : () -> Int, fl : FunctionLike) {\n" +
+ " fun foo(nullable : String?, r : Runnable, f : () -> Int, fl : FunctionLike, dyn: dynamic) {\n" +
" println(\"length\\nis ${nullable?.length} \\e\")\n" +
" val ints = java.util.ArrayList(2)\n" +
" ints[0] = 102 + f() + fl()\n" +
@@ -70,6 +70,8 @@ public class JetColorSettingsPage implements ColorSettingsPage {
" println(it + ref)\n" +
" }\n" +
" }\n" +
+ " dyn.dynamicCall()\n" +
+ " dyn.dynamicProp = 5\n" +
" }\n" +
"}\n" +
"\n" +
@@ -147,10 +149,12 @@ public class JetColorSettingsPage implements ColorSettingsPage {
new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.property.with.backing"), JetHighlightingColors.PROPERTY_WITH_BACKING_FIELD),
new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.backing.field.access"), JetHighlightingColors.BACKING_FIELD_ACCESS),
new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.extension.property"), JetHighlightingColors.EXTENSION_PROPERTY),
+ new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.dynamic.property"), JetHighlightingColors.DYNAMIC_PROPERTY_CALL),
new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.it"), JetHighlightingColors.FUNCTION_LITERAL_DEFAULT_PARAMETER),
new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.fun"), JetHighlightingColors.FUNCTION_DECLARATION),
new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.fun.call"), JetHighlightingColors.FUNCTION_CALL),
+ new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.dynamic.fun.call"), JetHighlightingColors.DYNAMIC_FUNCTION_CALL),
new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.package.fun.call"), JetHighlightingColors.PACKAGE_FUNCTION_CALL),
new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.extension.fun.call"), JetHighlightingColors.EXTENSION_FUNCTION_CALL),
new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.constructor.call"), JetHighlightingColors.CONSTRUCTOR_CALL),
diff --git a/idea/testData/highlighter/Dynamic.kt b/idea/testData/highlighter/Dynamic.kt
new file mode 100644
index 00000000000..894922be3b4
--- /dev/null
+++ b/idea/testData/highlighter/Dynamic.kt
@@ -0,0 +1,7 @@
+package testing
+
+fun tst(d: dynamic) {
+ d.foo()
+ d.foo
+ d.foo = 1
+}
\ No newline at end of file
diff --git a/idea/tests/org/jetbrains/jet/plugin/highlighter/HighlightingTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/highlighter/HighlightingTestGenerated.java
index 59b9c18b5ea..4055413efe5 100644
--- a/idea/tests/org/jetbrains/jet/plugin/highlighter/HighlightingTestGenerated.java
+++ b/idea/tests/org/jetbrains/jet/plugin/highlighter/HighlightingTestGenerated.java
@@ -37,6 +37,12 @@ public class HighlightingTestGenerated extends AbstractHighlightingTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/highlighter"), Pattern.compile("^(.+)\\.kt$"), true);
}
+ @TestMetadata("Dynamic.kt")
+ public void testDynamic() throws Exception {
+ String fileName = JetTestUtils.navigationMetadata("idea/testData/highlighter/Dynamic.kt");
+ doTest(fileName);
+ }
+
@TestMetadata("Enums.kt")
public void testEnums() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/highlighter/Enums.kt");