Support serialization of built-in ranges as error types

This will be needed to move ranges and progressions out of builtins.
Currently they're only used in signatures of "rangeTo" functions on
primitives
This commit is contained in:
Alexander Udalov
2017-04-25 12:14:26 +03:00
parent f648f0235c
commit e2c62cbded
4 changed files with 40 additions and 2 deletions
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.types
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.resolve.scopes.MemberScope
class ErrorType @JvmOverloads internal constructor(
open class ErrorType @JvmOverloads internal constructor(
override val constructor: TypeConstructor,
override val memberScope: MemberScope,
override val arguments: List<TypeProjection> = emptyList(),
@@ -36,3 +36,14 @@ class ErrorType @JvmOverloads internal constructor(
override fun makeNullableAsSpecified(newNullability: Boolean): SimpleType =
ErrorType(constructor, memberScope, arguments, newNullability)
}
class UnresolvedType(
val presentableName: String,
constructor: TypeConstructor,
memberScope: MemberScope,
arguments: List<TypeProjection>,
isMarkedNullable: Boolean
) : ErrorType(constructor, memberScope, arguments, isMarkedNullable) {
override fun makeNullableAsSpecified(newNullability: Boolean): SimpleType =
UnresolvedType(presentableName, constructor, memberScope, arguments, newNullability)
}
@@ -411,6 +411,12 @@ public class ErrorUtils {
return new ErrorType(createErrorTypeConstructor(debugMessage), createErrorScope(debugMessage), arguments, false);
}
@NotNull
public static SimpleType createUnresolvedType(@NotNull String presentableName, @NotNull List<TypeProjection> arguments) {
return new UnresolvedType(presentableName, createErrorTypeConstructor(presentableName), createErrorScope(presentableName),
arguments, false);
}
@NotNull
public static TypeConstructor createErrorTypeConstructor(@NotNull String debugMessage) {
return createErrorTypeConstructorWithCustomDebugName("[ERROR : " + debugMessage + "]", ERROR_CLASS);