diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/DebugTextUtil.kt b/compiler/frontend/src/org/jetbrains/jet/lang/psi/DebugTextUtil.kt index e45ac4266ae..e5d95b468f8 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/DebugTextUtil.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/DebugTextUtil.kt @@ -56,6 +56,7 @@ import org.jetbrains.jet.lang.psi.JetFile import org.jetbrains.jet.lang.psi.JetPackageDirective import org.jetbrains.jet.lang.psi.JetImportDirective import org.jetbrains.jet.lang.psi.JetImportList +import org.jetbrains.jet.lang.psi.JetDynamicType // invoke this instead of getText() when you need debug text to identify some place in PSI without storing the element itself // this is need to avoid unnecessary file parses @@ -123,6 +124,10 @@ private object DebugTextBuildingVisitor : JetVisitor() { return render(userType, userType.getQualifier(), userType.getReferenceExpression(), userType.getTypeArgumentList()) } + override fun visitDynamicType(type: JetDynamicType, data: Unit?): String? { + return "dynamic" + } + override fun visitAnnotation(annotation: JetAnnotation, data: Unit?): String? { return renderChildren(annotation, " ", "[", "]") } diff --git a/compiler/testData/diagnostics/tests/dynamicTypes/assignment.txt b/compiler/testData/diagnostics/tests/dynamicTypes/assignment.txt index 7a544c63a17..62542891368 100644 --- a/compiler/testData/diagnostics/tests/dynamicTypes/assignment.txt +++ b/compiler/testData/diagnostics/tests/dynamicTypes/assignment.txt @@ -1,3 +1,3 @@ package -internal fun foo(/*0*/ d: (kotlin.Nothing..kotlin.Any?)): kotlin.Unit +internal fun foo(/*0*/ d: dynamic): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/dynamicTypes/overloading.txt b/compiler/testData/diagnostics/tests/dynamicTypes/overloading.txt index 3c681b4dd3a..e0e4052fb15 100644 --- a/compiler/testData/diagnostics/tests/dynamicTypes/overloading.txt +++ b/compiler/testData/diagnostics/tests/dynamicTypes/overloading.txt @@ -1,7 +1,7 @@ package -internal fun dyn(/*0*/ d: (kotlin.Nothing..kotlin.Any?)): kotlin.Unit -internal fun foo(/*0*/ d: (kotlin.Nothing..kotlin.Any?)): kotlin.String +internal fun dyn(/*0*/ d: dynamic): kotlin.Unit +internal fun foo(/*0*/ d: dynamic): kotlin.String internal fun foo(/*0*/ d: kotlin.Int): kotlin.Int internal fun nothing(/*0*/ d: dynamic): kotlin.Int internal fun nothing(/*0*/ d: kotlin.Nothing): kotlin.String diff --git a/core/descriptors/src/org/jetbrains/jet/renderer/DescriptorRendererImpl.java b/core/descriptors/src/org/jetbrains/jet/renderer/DescriptorRendererImpl.java index ef15dbabae7..458bbdf20bd 100644 --- a/core/descriptors/src/org/jetbrains/jet/renderer/DescriptorRendererImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/renderer/DescriptorRendererImpl.java @@ -311,6 +311,9 @@ public class DescriptorRendererImpl implements DescriptorRenderer { if (type instanceof LazyType && debugMode) { return type.toString(); } + if (TypesPackage.isDynamic(type)) { + return "dynamic"; + } if (TypesPackage.isFlexible(type)) { if (debugMode) { return renderFlexibleTypeWithBothBounds(TypesPackage.flexibility(type).getLowerBound(), diff --git a/idea/ide-common/src/org/jetbrains/jet/plugin/util/TypeUtils.kt b/idea/ide-common/src/org/jetbrains/jet/plugin/util/TypeUtils.kt index bb87c45515f..78fc817ee0f 100644 --- a/idea/ide-common/src/org/jetbrains/jet/plugin/util/TypeUtils.kt +++ b/idea/ide-common/src/org/jetbrains/jet/plugin/util/TypeUtils.kt @@ -27,8 +27,8 @@ import org.jetbrains.jet.lang.descriptors.ClassDescriptor import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames import org.jetbrains.jet.lang.types.isFlexible import org.jetbrains.jet.lang.types.flexibility -import java.util.ArrayList import java.util.LinkedHashSet +import org.jetbrains.jet.lang.types.isDynamic fun JetType.makeNullable() = TypeUtils.makeNullable(this) fun JetType.makeNotNullable() = TypeUtils.makeNotNullable(this) @@ -39,6 +39,7 @@ fun JetType.isUnit(): Boolean = KotlinBuiltIns.getInstance().isUnit(this) fun JetType.isAny(): Boolean = KotlinBuiltIns.getInstance().isAnyOrNullableAny(this) public fun approximateFlexibleTypes(jetType: JetType, outermost: Boolean = true): JetType { + if (jetType.isDynamic()) return jetType if (jetType.isFlexible()) { val flexible = jetType.flexibility() val lowerClass = flexible.lowerBound.getConstructor().getDeclarationDescriptor() as? ClassDescriptor? diff --git a/idea/idea-analysis/src/org/jetbrains/jet/plugin/decompiler/navigation/MemberMatching.java b/idea/idea-analysis/src/org/jetbrains/jet/plugin/decompiler/navigation/MemberMatching.java index dd6454a6cf2..b9cfffdf1f6 100644 --- a/idea/idea-analysis/src/org/jetbrains/jet/plugin/decompiler/navigation/MemberMatching.java +++ b/idea/idea-analysis/src/org/jetbrains/jet/plugin/decompiler/navigation/MemberMatching.java @@ -97,6 +97,11 @@ public class MemberMatching { assert innerType != null : "No inner type: " + nullableType; return innerType.accept(this, null); } + + @Override + public String visitDynamicType(@NotNull JetDynamicType type, Void data) { + return "dynamic"; + } }, null); }