Rendering for dynamic types
This commit is contained in:
@@ -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<String, Unit>() {
|
||||
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, " ", "[", "]")
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
package
|
||||
|
||||
internal fun foo(/*0*/ d: (kotlin.Nothing..kotlin.Any?)): kotlin.Unit
|
||||
internal fun foo(/*0*/ d: dynamic): kotlin.Unit
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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?
|
||||
|
||||
+5
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user