From 568b21e31c11f3306b2cd3379a68465fa9c491a6 Mon Sep 17 00:00:00 2001 From: Pavel Kirpichenkov Date: Tue, 24 Mar 2020 17:53:28 +0300 Subject: [PATCH] minor: refactor cast into context operation --- .../components/KotlinConstraintSystemCompleter.kt | 10 +++------- .../calls/inference/model/NewConstraintSystemImpl.kt | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/KotlinConstraintSystemCompleter.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/KotlinConstraintSystemCompleter.kt index ed61d86ee1b..864845cf4ef 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/KotlinConstraintSystemCompleter.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/KotlinConstraintSystemCompleter.kt @@ -33,8 +33,8 @@ class KotlinConstraintSystemCompleter( } interface Context : VariableFixationFinder.Context, ResultTypeResolver.Context { + val allTypeVariables: Map override val notFixedTypeVariables: Map - override val postponedTypeVariables: List // type can be proper if it not contains not fixed type variables @@ -170,8 +170,6 @@ class KotlinConstraintSystemCompleter( analyze: (PostponedResolvedAtom) -> Unit, fixationFinder: VariableFixationFinder ): Boolean { - if (this !is NewConstraintSystem) return false - val isReturnArgumentOfAnotherLambda = postponedArguments.any { it is LambdaWithTypeVariableAsExpectedTypeAtom && it.isReturnArgumentOfAnotherLambda } @@ -186,7 +184,7 @@ class KotlinConstraintSystemCompleter( return false val expectedTypeVariable = - atomExpectedType?.constructor?.takeIf { it in this.getBuilder().currentStorage().allTypeVariables } ?: return false + atomExpectedType?.constructor?.takeIf { it in allTypeVariables } ?: return false analyze(preparePostponedAtom(expectedTypeVariable, postponedAtom, expectedTypeVariable.builtIns, diagnosticsHolder) ?: return false) @@ -202,8 +200,6 @@ class KotlinConstraintSystemCompleter( diagnosticsHolder: KotlinDiagnosticsHolder, analyze: (PostponedResolvedAtom) -> Unit ): Boolean { - if (this !is NewConstraintSystem) return false - val variable = variableForFixation.variable as? TypeConstructor ?: return false val hasProperAtom = postponedArguments.any { when (it) { @@ -216,7 +212,7 @@ class KotlinConstraintSystemCompleter( val postponedAtom = postponedArguments.firstOrNull() ?: return false val expectedTypeAtom = postponedAtom.expectedType val expectedTypeVariable = - expectedTypeAtom?.constructor?.takeIf { it in this.getBuilder().currentStorage().allTypeVariables } ?: variable + expectedTypeAtom?.constructor?.takeIf { it in allTypeVariables } ?: variable val shouldAnalyzeByEqualityExpectedTypeToVariable = hasProperAtom || !variableForFixation.hasProperConstraint || variableForFixation.hasOnlyTrivialProperConstraint 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 33a6e9ef118..d5380cc6b4f 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 @@ -246,7 +246,7 @@ class NewConstraintSystemImpl( return typeVariable in postponedTypeVariables } - // ConstraintInjector.Context + // ConstraintInjector.Context, KotlinConstraintSystemCompleter.Context override val allTypeVariables: Map get() { checkState(State.BUILDING, State.COMPLETION, State.TRANSACTION)