[FE 1.0] Refactor error utils: split error entities and introduce error type and error scope kinds
This commit is contained in:
committed by
teamcity
parent
8c1fcddea3
commit
b5933c70e2
+9
-6
@@ -8,25 +8,28 @@ package org.jetbrains.kotlin.backend.common.serialization.metadata
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DYNAMIC_TYPE_DESERIALIZER_ID
|
||||
import org.jetbrains.kotlin.serialization.deserialization.FlexibleTypeDeserializer
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.SimpleType
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.checker.StrictEqualityTypeChecker
|
||||
import org.jetbrains.kotlin.types.createDynamicType
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
|
||||
object DynamicTypeDeserializer : FlexibleTypeDeserializer {
|
||||
const val id = DYNAMIC_TYPE_DESERIALIZER_ID
|
||||
|
||||
override fun create(proto: ProtoBuf.Type, flexibleId: String, lowerBound: SimpleType, upperBound: SimpleType): KotlinType {
|
||||
if (flexibleId != id) return ErrorUtils.createErrorType("Unexpected id: $flexibleId. ($lowerBound..$upperBound)")
|
||||
if (flexibleId != id) {
|
||||
return ErrorUtils.createErrorType(
|
||||
ErrorTypeKind.UNEXPECTED_FLEXIBLE_TYPE_ID, flexibleId, lowerBound.toString(), upperBound.toString()
|
||||
)
|
||||
}
|
||||
|
||||
return if (StrictEqualityTypeChecker.strictEqualTypes(lowerBound, lowerBound.builtIns.nothingType) &&
|
||||
StrictEqualityTypeChecker.strictEqualTypes(upperBound, upperBound.builtIns.nullableAnyType)
|
||||
) {
|
||||
createDynamicType(lowerBound.builtIns)
|
||||
} else {
|
||||
ErrorUtils.createErrorType("Illegal type range for dynamic type: $lowerBound..$upperBound")
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.ILLEGAL_TYPE_RANGE_FOR_DYNAMIC, lowerBound.toString(), upperBound.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user