From 351c592c83181526050b9510ed4028a42105c854 Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Wed, 29 Nov 2017 16:40:43 +0300 Subject: [PATCH] [NI] Drop hack that was used before `DefinitelyNotNull` types --- .../model/NewConstraintSystemImpl.kt | 30 ++----------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt index b568c16783d..d2640385392 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt @@ -25,13 +25,10 @@ import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstituto import org.jetbrains.kotlin.resolve.calls.inference.components.ResultTypeResolver import org.jetbrains.kotlin.resolve.calls.model.KotlinCallDiagnostic import org.jetbrains.kotlin.resolve.calls.tower.isSuccess -import org.jetbrains.kotlin.types.IntersectionTypeConstructor import org.jetbrains.kotlin.types.TypeConstructor import org.jetbrains.kotlin.types.UnwrappedType -import org.jetbrains.kotlin.types.typeUtil.builtIns import org.jetbrains.kotlin.types.typeUtil.contains import org.jetbrains.kotlin.utils.SmartList -import org.jetbrains.kotlin.utils.addToStdlib.safeAs class NewConstraintSystemImpl( private val constraintInjector: ConstraintInjector, @@ -44,10 +41,6 @@ class NewConstraintSystemImpl( KotlinConstraintSystemCompleter.Context, PostponedArgumentsAnalyzer.Context { - companion object { - private val TYPE_PARAMETER_FOR_EXCLXCL = "" // TODO: Get this variable from ResolveConstruct - } - private val storage = MutableConstraintStorage() private var state = State.BUILDING private val typeVariablesTransaction: MutableList = SmartList() @@ -213,8 +206,7 @@ class NewConstraintSystemImpl( override fun fixVariable(variable: NewTypeVariable, resultType: UnwrappedType) { checkState(State.BUILDING, State.COMPLETION) - val actualResultType = eliminateSpecialIntersectionType(variable, resultType) ?: resultType - constraintInjector.addInitialEqualityConstraint(this, variable.defaultType, actualResultType, FixVariableConstraintPosition(variable)) + constraintInjector.addInitialEqualityConstraint(this, variable.defaultType, resultType, FixVariableConstraintPosition(variable)) notFixedTypeVariables.remove(variable.freshTypeConstructor) for (variableWithConstraint in notFixedTypeVariables.values) { @@ -223,25 +215,7 @@ class NewConstraintSystemImpl( } } - storage.fixedTypeVariables[variable.freshTypeConstructor] = actualResultType - } - - private fun eliminateSpecialIntersectionType(variable: NewTypeVariable, type: UnwrappedType): UnwrappedType? { - if (variable.shouldBeDefinitelyNotNull()) return null - - val constructor = type.constructor.safeAs() ?: return null - - if (constructor.supertypes.size != 2) return null - val actualType = constructor.supertypes.singleOrNull { it != type.builtIns.anyType } - - return actualType?.unwrap() - } - - private fun NewTypeVariable.shouldBeDefinitelyNotNull(): Boolean { - return when (this) { - is TypeVariableFromCallableDescriptor -> originalTypeParameter.name.asString() == TYPE_PARAMETER_FOR_EXCLXCL - is TypeVariableForLambdaReturnType -> false - } + storage.fixedTypeVariables[variable.freshTypeConstructor] = resultType } // KotlinConstraintSystemCompleter.Context, PostponedArgumentsAnalyzer.Context