Get rid of FE 1.0 classes usage in ConstraintIncorporator
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.fir.resolve.inference
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemUtilContext
|
||||||
|
import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
||||||
|
|
||||||
|
object ConeConstraintSystemUtilContext : ConstraintSystemUtilContext {
|
||||||
|
override fun TypeVariableMarker.shouldBeFlexible(): Boolean {
|
||||||
|
// TODO
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -26,7 +26,7 @@ class InferenceComponents(
|
|||||||
) {
|
) {
|
||||||
val approximator: AbstractTypeApproximator = object : AbstractTypeApproximator(ctx) {}
|
val approximator: AbstractTypeApproximator = object : AbstractTypeApproximator(ctx) {}
|
||||||
val trivialConstraintTypeInferenceOracle = TrivialConstraintTypeInferenceOracle.create(ctx)
|
val trivialConstraintTypeInferenceOracle = TrivialConstraintTypeInferenceOracle.create(ctx)
|
||||||
private val incorporator = ConstraintIncorporator(approximator, trivialConstraintTypeInferenceOracle)
|
private val incorporator = ConstraintIncorporator(approximator, trivialConstraintTypeInferenceOracle, ConeConstraintSystemUtilContext)
|
||||||
private val injector = ConstraintInjector(incorporator, approximator, KotlinTypeRefiner.Default)
|
private val injector = ConstraintInjector(incorporator, approximator, KotlinTypeRefiner.Default)
|
||||||
val resultTypeResolver = ResultTypeResolver(approximator, trivialConstraintTypeInferenceOracle)
|
val resultTypeResolver = ResultTypeResolver(approximator, trivialConstraintTypeInferenceOracle)
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.platform.TargetPlatformVersion
|
|||||||
import org.jetbrains.kotlin.platform.isCommon
|
import org.jetbrains.kotlin.platform.isCommon
|
||||||
import org.jetbrains.kotlin.resolve.*
|
import org.jetbrains.kotlin.resolve.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.ClassicTypeSystemContextForCS
|
import org.jetbrains.kotlin.resolve.calls.components.ClassicTypeSystemContextForCS
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ClassicConstraintSystemUtilContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactoryImpl
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactoryImpl
|
||||||
import org.jetbrains.kotlin.resolve.calls.tower.KotlinResolutionStatelessCallbacksImpl
|
import org.jetbrains.kotlin.resolve.calls.tower.KotlinResolutionStatelessCallbacksImpl
|
||||||
import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker
|
import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker
|
||||||
@@ -100,6 +101,7 @@ private fun StorageComponentContainer.configurePlatformIndependentComponents() {
|
|||||||
useImpl<CompilerDeserializationConfiguration>()
|
useImpl<CompilerDeserializationConfiguration>()
|
||||||
|
|
||||||
useImpl<ClassicTypeSystemContextForCS>()
|
useImpl<ClassicTypeSystemContextForCS>()
|
||||||
|
useInstance(ClassicConstraintSystemUtilContext)
|
||||||
useInstance(ProgressManagerBasedCancellationChecker)
|
useInstance(ProgressManagerBasedCancellationChecker)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.resolve.calls.inference.components
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.components.CreateFreshVariablesSubstitutor.shouldBeFlexible
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableFromCallableDescriptor
|
||||||
|
import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
||||||
|
|
||||||
|
object ClassicConstraintSystemUtilContext : ConstraintSystemUtilContext {
|
||||||
|
override fun TypeVariableMarker.shouldBeFlexible(): Boolean {
|
||||||
|
return this is TypeVariableFromCallableDescriptor && this.originalTypeParameter.shouldBeFlexible()
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-5
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.resolve.calls.inference.components
|
package org.jetbrains.kotlin.resolve.calls.inference.components
|
||||||
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.CreateFreshVariablesSubstitutor.shouldBeFlexible
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.*
|
import org.jetbrains.kotlin.resolve.calls.inference.model.*
|
||||||
import org.jetbrains.kotlin.types.AbstractTypeApproximator
|
import org.jetbrains.kotlin.types.AbstractTypeApproximator
|
||||||
import org.jetbrains.kotlin.types.TypeApproximatorConfiguration
|
import org.jetbrains.kotlin.types.TypeApproximatorConfiguration
|
||||||
@@ -19,7 +18,8 @@ import java.util.*
|
|||||||
// todo problem: intersection types in constrains: A <: Number, B <: Inv<A & Any> =>? B <: Inv<out Number & Any>
|
// todo problem: intersection types in constrains: A <: Number, B <: Inv<A & Any> =>? B <: Inv<out Number & Any>
|
||||||
class ConstraintIncorporator(
|
class ConstraintIncorporator(
|
||||||
val typeApproximator: AbstractTypeApproximator,
|
val typeApproximator: AbstractTypeApproximator,
|
||||||
val trivialConstraintTypeInferenceOracle: TrivialConstraintTypeInferenceOracle
|
val trivialConstraintTypeInferenceOracle: TrivialConstraintTypeInferenceOracle,
|
||||||
|
val utilContext: ConstraintSystemUtilContext
|
||||||
) {
|
) {
|
||||||
|
|
||||||
interface Context : TypeSystemInferenceExtensionContext {
|
interface Context : TypeSystemInferenceExtensionContext {
|
||||||
@@ -66,8 +66,7 @@ class ConstraintIncorporator(
|
|||||||
typeVariable: TypeVariableMarker,
|
typeVariable: TypeVariableMarker,
|
||||||
constraint: Constraint
|
constraint: Constraint
|
||||||
) {
|
) {
|
||||||
val shouldBeTypeVariableFlexible =
|
val shouldBeTypeVariableFlexible = with(utilContext) { typeVariable.shouldBeFlexible() }
|
||||||
typeVariable is TypeVariableFromCallableDescriptor && typeVariable.originalTypeParameter.shouldBeFlexible()
|
|
||||||
|
|
||||||
// \alpha <: constraint.type
|
// \alpha <: constraint.type
|
||||||
if (constraint.kind != ConstraintKind.LOWER) {
|
if (constraint.kind != ConstraintKind.LOWER) {
|
||||||
@@ -83,7 +82,7 @@ class ConstraintIncorporator(
|
|||||||
getConstraintsForVariable(typeVariable).forEach {
|
getConstraintsForVariable(typeVariable).forEach {
|
||||||
if (it.kind != ConstraintKind.LOWER) {
|
if (it.kind != ConstraintKind.LOWER) {
|
||||||
val isFromDeclaredUpperBound =
|
val isFromDeclaredUpperBound =
|
||||||
it.position.from is DeclaredUpperBoundConstraintPosition<*> && it.type.typeConstructor() !is TypeVariableTypeConstructor
|
it.position.from is DeclaredUpperBoundConstraintPosition<*> && !it.type.typeConstructor().isTypeVariable()
|
||||||
|
|
||||||
addNewIncorporatedConstraint(
|
addNewIncorporatedConstraint(
|
||||||
constraint.type,
|
constraint.type,
|
||||||
|
|||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.resolve.calls.inference.components
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Functions from this context can not be moved to TypeSystemInferenceExtensionContext, because
|
||||||
|
* it's classic implementation, ClassicTypeSystemContext lays in :core:descriptors,
|
||||||
|
* but we need access classes from :compiler:resolution for this function implementation
|
||||||
|
*/
|
||||||
|
interface ConstraintSystemUtilContext {
|
||||||
|
fun TypeVariableMarker.shouldBeFlexible(): Boolean
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user