[NI] Fix common supertype of types with error supertypes
Enable check for error supertypes during CST calculation in classic type system context. Cyclic upper bound + known type parameters of superclasses may create non-error types with error supertypes. Such types don't have common constructors with other normal types and cause assertion errors during intersection. ^KT-36951 Fixed
This commit is contained in:
@@ -33,7 +33,7 @@ import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
|
||||
interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSystemCommonBackendContext {
|
||||
override val isErrorTypeAllowed: Boolean get() = true
|
||||
override val isErrorTypeAllowed: Boolean get() = false
|
||||
|
||||
override fun TypeConstructorMarker.isDenotable(): Boolean {
|
||||
require(this is TypeConstructor, this::errorMessage)
|
||||
@@ -62,7 +62,8 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
}
|
||||
|
||||
override fun TypeConstructorMarker.toErrorType(): SimpleTypeMarker {
|
||||
throw IllegalStateException("Should not be called")
|
||||
require(this is TypeConstructor && ErrorUtils.isError(declarationDescriptor), this::errorMessage)
|
||||
return ErrorUtils.createErrorType("from type constructor(${toString()})")
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.isUninferredParameter(): Boolean {
|
||||
@@ -529,7 +530,8 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
}
|
||||
|
||||
override fun TypeConstructorMarker.isError(): Boolean {
|
||||
throw IllegalStateException("Should not be called")
|
||||
require(this is TypeConstructor, this::errorMessage)
|
||||
return ErrorUtils.isError(declarationDescriptor)
|
||||
}
|
||||
|
||||
override fun TypeConstructorMarker.getApproximatedIntegerLiteralType(): KotlinTypeMarker {
|
||||
|
||||
@@ -79,8 +79,7 @@ interface TypeCheckerProviderContext {
|
||||
|
||||
interface TypeSystemCommonSuperTypesContext : TypeSystemContext, TypeSystemTypeFactoryContext, TypeCheckerProviderContext {
|
||||
/*
|
||||
* If set in false then if there is an error type in input types list of `commonSuperType` it will be return
|
||||
* That flag is needed for FIR where there are a problems with recursive class hierarchies
|
||||
* If set in false then if there is an error supertype in input types list of `commonSuperType` it will be returned
|
||||
*/
|
||||
val isErrorTypeAllowed: Boolean
|
||||
|
||||
|
||||
Reference in New Issue
Block a user