Replace usage of ClassicTCContext with abstract context in NewCSTCalculator
This commit is contained in:
committed by
Mikhail Glukhikh
parent
0276a6262f
commit
6215662e33
@@ -5,8 +5,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir
|
||||
|
||||
import org.jetbrains.kotlin.fir.types.ConeTypeCheckerContext
|
||||
import org.jetbrains.kotlin.fir.types.ConeTypeContext
|
||||
import org.jetbrains.kotlin.types.AbstractTypeCheckerContext
|
||||
|
||||
private class SessionBasedTypeContext(override val session: FirSession) : ConeTypeContext
|
||||
private class SessionBasedTypeContext(override val session: FirSession) : ConeTypeContext {
|
||||
override fun newBaseTypeCheckerContext(errorTypesEqualToAnything: Boolean): AbstractTypeCheckerContext {
|
||||
return ConeTypeCheckerContext(errorTypesEqualToAnything, session)
|
||||
}
|
||||
}
|
||||
|
||||
val FirSession.typeContext: ConeTypeContext get() = SessionBasedTypeContext(this)
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.types.model.*
|
||||
|
||||
class ErrorTypeConstructor(reason: String) : TypeConstructorMarker
|
||||
|
||||
interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext {
|
||||
interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, TypeCheckerProviderContext {
|
||||
val session: FirSession
|
||||
|
||||
override fun TypeConstructorMarker.isIntegerLiteralTypeConstructor(): Boolean {
|
||||
@@ -460,4 +460,10 @@ class ConeTypeCheckerContext(override val isErrorTypeEqualsToAnything: Boolean,
|
||||
override val KotlinTypeMarker.isAllowedTypeVariable: Boolean
|
||||
get() = this is ConeKotlinType && this is ConeTypeVariableType
|
||||
|
||||
override fun newBaseTypeCheckerContext(errorTypesEqualToAnything: Boolean): AbstractTypeCheckerContext =
|
||||
if (this.isErrorTypeEqualsToAnything == errorTypesEqualToAnything)
|
||||
this
|
||||
else
|
||||
ConeTypeCheckerContext(errorTypesEqualToAnything, session)
|
||||
|
||||
}
|
||||
|
||||
+1
-4
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.resolve.constants.IntegerLiteralTypeConstructor
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.*
|
||||
import org.jetbrains.kotlin.types.AbstractNullabilityChecker.hasPathByNotMarkedNullableNodes
|
||||
@@ -181,7 +178,7 @@ object NewCommonSuperTypeCalculator {
|
||||
nullable = false
|
||||
)
|
||||
|
||||
val typeCheckerContext = ClassicTypeCheckerContext(false)
|
||||
val typeCheckerContext = newBaseTypeCheckerContext(false)
|
||||
|
||||
/**
|
||||
* Sometimes one type can have several supertypes with given type constructor, suppose A <: List<Int> and A <: List<Double>.
|
||||
|
||||
+3
-1
@@ -86,7 +86,9 @@ class ResultTypeResolver(
|
||||
val lowerConstraints = variableWithConstraints.constraints.filter { it.kind == ConstraintKind.LOWER && isProperType(it.type) }
|
||||
if (lowerConstraints.isNotEmpty()) {
|
||||
val types = sinkIntegerLiteralTypes(lowerConstraints.map { it.type })
|
||||
val commonSuperType = with(NewCommonSuperTypeCalculator) { commonSuperType(types) }
|
||||
val commonSuperType = with(NewCommonSuperTypeCalculator) {
|
||||
this@findSubType.commonSuperType(types)
|
||||
}
|
||||
/**
|
||||
*
|
||||
* fun <T> Array<out T>.intersect(other: Iterable<T>) {
|
||||
|
||||
Reference in New Issue
Block a user