Disable slow assertions in type checker everywhere except for tests
This commit is contained in:
+2
-1
@@ -253,6 +253,7 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck
|
||||
AbstractTypeChecker.isSubtypeOf(this as AbstractTypeCheckerContext, subType, superType)
|
||||
|
||||
private fun assertInputTypes(subType: KotlinTypeMarker, superType: KotlinTypeMarker) {
|
||||
if (!AbstractTypeChecker.RUN_SLOW_ASSERTIONS) return
|
||||
fun correctSubType(subType: SimpleTypeMarker) =
|
||||
subType.isSingleClassifierType() || subType.typeConstructor().isIntersection() || isMyTypeVariable(subType) || subType.isError() || subType.isIntegerLiteralType()
|
||||
|
||||
@@ -278,4 +279,4 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck
|
||||
is FlexibleTypeMarker -> f(lowerBound()) || f(upperBound())
|
||||
else -> error("sealed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-8
@@ -88,13 +88,15 @@ interface NewTypeSubstitutor: TypeSubstitutorMarker {
|
||||
"original lower type: '${capturedType.lowerType}"
|
||||
)
|
||||
|
||||
typeConstructor.supertypes.forEach { supertype ->
|
||||
substitute(supertype, keepAnnotation, runCapturedChecks = false)?.let {
|
||||
throw IllegalStateException(
|
||||
"Illegal type substitutor: $this, " +
|
||||
"because for captured type '$type' supertype approximation should be null, but it is: '$supertype'," +
|
||||
"original supertype: '$supertype'"
|
||||
)
|
||||
if (AbstractTypeChecker.RUN_SLOW_ASSERTIONS) {
|
||||
typeConstructor.supertypes.forEach { supertype ->
|
||||
substitute(supertype, keepAnnotation, runCapturedChecks = false)?.let {
|
||||
throw IllegalStateException(
|
||||
"Illegal type substitutor: $this, " +
|
||||
"because for captured type '$type' supertype approximation should be null, but it is: '$supertype'," +
|
||||
"original supertype: '$supertype'"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,4 +180,4 @@ class FreshVariableNewTypeSubstitutor(val freshVariables: List<TypeVariableFromC
|
||||
fun UnwrappedType.substituteTypeVariable(typeVariable: NewTypeVariable, value: UnwrappedType): UnwrappedType {
|
||||
val substitutor = NewTypeSubstitutorByConstructorMap(mapOf(typeVariable.freshTypeConstructor to value))
|
||||
return substitutor.safeSubstitute(this)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user