[NI] There is no need in copying constraint storage as it read-only
This commit is contained in:
+1
-1
@@ -102,7 +102,7 @@ class PostponedArgumentsAnalyzer(
|
||||
}
|
||||
|
||||
if (inferenceSession != null) {
|
||||
val storageSnapshot = c.getBuilder().copyCurrentStorage()
|
||||
val storageSnapshot = c.getBuilder().currentStorage()
|
||||
|
||||
val postponedVariables = inferenceSession.inferPostponedVariables(storageSnapshot)
|
||||
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ interface ConstraintSystemBuilder : ConstraintSystemOperation {
|
||||
|
||||
fun buildCurrentSubstitutor(): NewTypeSubstitutor
|
||||
|
||||
fun copyCurrentStorage(): ConstraintStorage
|
||||
fun currentStorage(): ConstraintStorage
|
||||
}
|
||||
|
||||
fun ConstraintSystemBuilder.addSubtypeConstraintIfCompatible(
|
||||
|
||||
-28
@@ -97,32 +97,4 @@ internal class MutableConstraintStorage : ConstraintStorage {
|
||||
override val hasContradiction: Boolean get() = errors.any { !it.candidateApplicability.isSuccess }
|
||||
override val fixedTypeVariables: MutableMap<TypeConstructor, UnwrappedType> = LinkedHashMap()
|
||||
override val postponedTypeVariables: ArrayList<NewTypeVariable> = ArrayList()
|
||||
|
||||
fun copy(): ConstraintStorage {
|
||||
return object : ConstraintStorage {
|
||||
override val allTypeVariables: Map<TypeConstructor, NewTypeVariable> =
|
||||
this@MutableConstraintStorage.allTypeVariables.toMap()
|
||||
|
||||
override val notFixedTypeVariables: Map<TypeConstructor, VariableWithConstraints> =
|
||||
this@MutableConstraintStorage.notFixedTypeVariables.toMap()
|
||||
|
||||
override val initialConstraints: List<InitialConstraint> =
|
||||
this@MutableConstraintStorage.initialConstraints.toList()
|
||||
|
||||
override val maxTypeDepthFromInitialConstraints: Int =
|
||||
this@MutableConstraintStorage.maxTypeDepthFromInitialConstraints
|
||||
|
||||
override val errors: List<KotlinCallDiagnostic> =
|
||||
this@MutableConstraintStorage.errors.toList()
|
||||
|
||||
override val hasContradiction: Boolean =
|
||||
this@MutableConstraintStorage.hasContradiction
|
||||
|
||||
override val fixedTypeVariables: Map<TypeConstructor, UnwrappedType> =
|
||||
this@MutableConstraintStorage.fixedTypeVariables.toMap()
|
||||
|
||||
override val postponedTypeVariables: List<NewTypeVariable> =
|
||||
this@MutableConstraintStorage.postponedTypeVariables.toList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -278,9 +278,9 @@ class NewConstraintSystemImpl(
|
||||
return storage.postponedTypeVariables.associate { it to NonFixedType(it.freshTypeConstructor, it.defaultType.isMarkedNullable) }
|
||||
}
|
||||
|
||||
override fun copyCurrentStorage(): ConstraintStorage {
|
||||
override fun currentStorage(): ConstraintStorage {
|
||||
checkState(State.BUILDING, State.COMPLETION)
|
||||
return storage.copy()
|
||||
return storage
|
||||
}
|
||||
|
||||
// PostponedArgumentsAnalyzer.Context
|
||||
|
||||
Reference in New Issue
Block a user