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.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
|
||||
|
||||
import org.jetbrains.kotlin.resolve.calls.components.CreateFreshVariablesSubstitutor.shouldBeFlexible
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.*
|
||||
import org.jetbrains.kotlin.types.AbstractTypeApproximator
|
||||
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>
|
||||
class ConstraintIncorporator(
|
||||
val typeApproximator: AbstractTypeApproximator,
|
||||
val trivialConstraintTypeInferenceOracle: TrivialConstraintTypeInferenceOracle
|
||||
val trivialConstraintTypeInferenceOracle: TrivialConstraintTypeInferenceOracle,
|
||||
val utilContext: ConstraintSystemUtilContext
|
||||
) {
|
||||
|
||||
interface Context : TypeSystemInferenceExtensionContext {
|
||||
@@ -66,8 +66,7 @@ class ConstraintIncorporator(
|
||||
typeVariable: TypeVariableMarker,
|
||||
constraint: Constraint
|
||||
) {
|
||||
val shouldBeTypeVariableFlexible =
|
||||
typeVariable is TypeVariableFromCallableDescriptor && typeVariable.originalTypeParameter.shouldBeFlexible()
|
||||
val shouldBeTypeVariableFlexible = with(utilContext) { typeVariable.shouldBeFlexible() }
|
||||
|
||||
// \alpha <: constraint.type
|
||||
if (constraint.kind != ConstraintKind.LOWER) {
|
||||
@@ -83,7 +82,7 @@ class ConstraintIncorporator(
|
||||
getConstraintsForVariable(typeVariable).forEach {
|
||||
if (it.kind != ConstraintKind.LOWER) {
|
||||
val isFromDeclaredUpperBound =
|
||||
it.position.from is DeclaredUpperBoundConstraintPosition<*> && it.type.typeConstructor() !is TypeVariableTypeConstructor
|
||||
it.position.from is DeclaredUpperBoundConstraintPosition<*> && !it.type.typeConstructor().isTypeVariable()
|
||||
|
||||
addNewIncorporatedConstraint(
|
||||
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