FIR: Optimize simple things in inference

This commit is contained in:
Denis Zharkov
2019-12-16 15:05:49 +03:00
parent 03c2350e79
commit b53c00cf69
4 changed files with 35 additions and 13 deletions
@@ -60,10 +60,10 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck
}
private fun KotlinTypeMarker.isTypeVariableWithExact() =
anyBound(this@AbstractTypeCheckerContextForConstraintSystem::isMyTypeVariable) && hasExactAnnotation()
hasExactAnnotation() && anyBound(this@AbstractTypeCheckerContextForConstraintSystem::isMyTypeVariable)
private fun KotlinTypeMarker.isTypeVariableWithNoInfer() =
anyBound(this@AbstractTypeCheckerContextForConstraintSystem::isMyTypeVariable) && hasNoInferAnnotation()
hasNoInferAnnotation() && anyBound(this@AbstractTypeCheckerContextForConstraintSystem::isMyTypeVariable)
private fun internalAddSubtypeConstraint(subType: KotlinTypeMarker, superType: KotlinTypeMarker): Boolean? {
assertInputTypes(subType, superType)
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.components.ResultTypeResolve
import org.jetbrains.kotlin.resolve.calls.model.KotlinCallDiagnostic
import org.jetbrains.kotlin.resolve.calls.model.OnlyInputTypesDiagnostic
import org.jetbrains.kotlin.resolve.calls.model.ResolvedAtom
import org.jetbrains.kotlin.types.AbstractTypeChecker
import org.jetbrains.kotlin.types.IntersectionTypeConstructor
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.checker.NewKotlinTypeChecker
@@ -43,7 +44,28 @@ class NewConstraintSystemImpl(
COMPLETION
}
private fun checkState(a: State) {
if (!AbstractTypeChecker.RUN_SLOW_ASSERTIONS) return
checkState(*arrayOf(a))
}
private fun checkState(a: State, b: State) {
if (!AbstractTypeChecker.RUN_SLOW_ASSERTIONS) return
checkState(*arrayOf(a, b))
}
private fun checkState(a: State, b: State, c: State) {
if (!AbstractTypeChecker.RUN_SLOW_ASSERTIONS) return
checkState(*arrayOf(a, b, c))
}
private fun checkState(a: State, b: State, c: State, d: State) {
if (!AbstractTypeChecker.RUN_SLOW_ASSERTIONS) return
checkState(*arrayOf(a, b, c, d))
}
private fun checkState(vararg allowedState: State) {
if (!AbstractTypeChecker.RUN_SLOW_ASSERTIONS) return
assert(state in allowedState) {
"State $state is not allowed. AllowedStates: ${allowedState.joinToString()}"
}