FIR inference: use generic version of error type in type approximator

This commit is contained in:
Mikhail Glukhikh
2019-04-18 12:25:36 +03:00
parent 7d793f6750
commit b4019b0cc1
2 changed files with 8 additions and 2 deletions
@@ -103,7 +103,9 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext,
}
override fun KotlinTypeMarker.typeDepth(): Int {
require(this is ConeKotlinType)
require(this is ConeKotlinType) {
"Incorrect type of class ${this::class.java}: $this"
}
return when (this) {
is ConeFlexibleType -> Math.max(lowerBound.typeDepthSimple(), upperBound.typeDepthSimple())
else -> typeDepthSimple()
@@ -45,7 +45,11 @@ open class ConeTypeVariable(name: String) : TypeVariableMarker {
}
class InferenceComponents(val ctx: TypeSystemInferenceExtensionContextDelegate) {
private val approximator = object : AbstractTypeApproximator(ctx) {}
private val approximator = object : AbstractTypeApproximator(ctx) {
override fun createErrorType(message: String): SimpleTypeMarker {
return ConeClassErrorType(message)
}
}
val trivialConstraintTypeInferenceOracle = TrivialConstraintTypeInferenceOracle(ctx)
private val incorporator = ConstraintIncorporator(approximator, trivialConstraintTypeInferenceOracle)
private val injector = ConstraintInjector(incorporator, approximator)