From e53e152f83c30bcfa6dc2afa058ab6e3233b03cd Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Mon, 25 Jan 2016 16:15:20 +0300 Subject: [PATCH] Removed hacks for code migration from ConstraintSystemImpl. --- .../calls/inference/ConstraintSystemImpl.kt | 8 +++--- .../resolveWithLowPriorityAnnotation.kt | 25 +++++-------------- .../direct/invariant/varSubDepEq.bounds | 2 +- .../direct/invariant/varSuperDepEq.bounds | 2 +- .../nullable/invariant/varSubDepEq.bounds | 2 +- .../nullable/invariant/varSuperDepEq.bounds | 2 +- .../other/nestedInvConsumer.bounds | 2 +- .../other/nestedInvProducer.bounds | 2 +- .../recursive/mutuallyRecursive.bounds | 2 +- .../reversed/invariant/varSubDepEq.bounds | 2 +- .../reversed/invariant/varSuperDepEq.bounds | 2 +- .../testsWithStdLib/cast/AsInsideIn.kt | 2 +- .../noInferAndLowPriority.kt | 2 +- .../onlyInputTypesAndLowPriority.kt | 4 +-- 14 files changed, 23 insertions(+), 36 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index b493a4e9b1d..773ae34cec4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -45,14 +45,14 @@ internal class ConstraintSystemImpl( override val status = object : ConstraintSystemStatus { // for debug ConstraintsUtil.getDebugMessageForStatus might be used - override fun isSuccessful() = !hasContradiction() && !hasUnknownParameters() + override fun isSuccessful() = !hasContradiction() && !hasUnknownParameters() && satisfyInitialConstraints() override fun hasContradiction() = hasParameterConstraintError() || hasConflictingConstraints() - || hasCannotCaptureTypesError() || hasTypeInferenceIncorporationError() - // hacks for library migration todo: remove its later - || hasTypeParameterWithUnsatisfiedOnlyInputTypesError() + || hasCannotCaptureTypesError() || errors.any { it is TypeInferenceError } /** + * All hacks were removed. This comment is left for information. + * * Hacks above are needed for the following example: * * @kotlin.jvm.JvmName("containsAny") diff --git a/compiler/testData/codegen/boxWithStdlib/annotations/resolveWithLowPriorityAnnotation.kt b/compiler/testData/codegen/boxWithStdlib/annotations/resolveWithLowPriorityAnnotation.kt index c6d843454ec..c54cd584bbf 100644 --- a/compiler/testData/codegen/boxWithStdlib/annotations/resolveWithLowPriorityAnnotation.kt +++ b/compiler/testData/codegen/boxWithStdlib/annotations/resolveWithLowPriorityAnnotation.kt @@ -4,27 +4,14 @@ fun foo(i: Int) = 1 fun foo(a: Any) = 2 -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -fun Iterable.contains1(element: @kotlin.internal.NoInfer T): Boolean = false - -@kotlin.jvm.JvmName("containsAny") @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.internal.LowPriorityInOverloadResolution -fun Iterable.contains1(element: T): Boolean = true +fun bar(a: String?) = 3 + +fun bar(a: Any) = 4 -fun main(args: Array) { - println(box()) -} fun box(): String { - if (foo(1) != 2) return "fail" - val l = listOf(1, 2) - val i: Int? = 42 - val a: Any = "" - return when { - l.contains1(3) -> "fail0" - !l.contains1(i) -> "fail1" - !l.contains1(a) -> "fail2" - !l.contains1("") -> "fail3" - else -> "OK" - } + if (foo(1) != 2) return "fail1" + if (bar(null) != 3) return "fail2" + return "OK" } \ No newline at end of file diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds index 096fe59e071..75d79b16cda 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds @@ -10,7 +10,7 @@ P := My* status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false --hasContradiction: true +-hasContradiction: false -hasErrorInConstrainingTypes: false -hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds index 732043c9d53..9e36c4e9dc2 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds @@ -10,7 +10,7 @@ P := My* status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false --hasContradiction: true +-hasContradiction: false -hasErrorInConstrainingTypes: false -hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.bounds index d43b7c1ea6f..46e120d8a13 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.bounds @@ -10,7 +10,7 @@ P := My* status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false --hasContradiction: true +-hasContradiction: false -hasErrorInConstrainingTypes: false -hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.bounds index 2de18553d26..2dfae2d7b29 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.bounds @@ -10,7 +10,7 @@ P := My* status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false --hasContradiction: true +-hasContradiction: false -hasErrorInConstrainingTypes: false -hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.bounds index 40b5c1d6d50..1851168470c 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.bounds @@ -10,7 +10,7 @@ P <: My>>*, <: My>> status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false --hasContradiction: true +-hasContradiction: false -hasErrorInConstrainingTypes: false -hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.bounds index d3421895791..d403cdc2bae 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.bounds @@ -10,7 +10,7 @@ P <: My>>*, <: My>> status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false --hasContradiction: true +-hasContradiction: false -hasErrorInConstrainingTypes: false -hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds b/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds index db94adb37e6..8237c875ff5 100644 --- a/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds +++ b/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds @@ -10,7 +10,7 @@ P := Two* status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false --hasContradiction: true +-hasContradiction: false -hasErrorInConstrainingTypes: false -hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds index 7d3a63c9450..b34161cf868 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds @@ -10,7 +10,7 @@ P := My* status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false --hasContradiction: true +-hasContradiction: false -hasErrorInConstrainingTypes: false -hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds index ea77a82c0ca..327b6bf0f48 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds @@ -10,7 +10,7 @@ P := My* status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false --hasContradiction: true +-hasContradiction: false -hasErrorInConstrainingTypes: false -hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true diff --git a/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.kt b/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.kt index adbb29c98d8..980b487be50 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.kt @@ -3,7 +3,7 @@ interface A class B : A fun foo1(list: List, arg: B?): Boolean { // Type mismatch - return arg in list + return arg in list // resolved to extension } fun foo2(list: List, arg: B?): Boolean { // FAKE: no cast needed diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.kt index 8e25d532b80..31775c3c04e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.kt @@ -10,6 +10,6 @@ public fun Iterable.contains1(element: @kotlin.internal.NoInfer T): Boole fun test() { - val a: Int = listOf(1).contains1("") + val a: Boolean = listOf(1).contains1("") val b: Boolean = listOf(1).contains1(1) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.kt index 9219014ce94..5ffb9e30d1a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.kt @@ -17,9 +17,9 @@ public fun Map.get1(key: Any?): Int = null!! public fun <@kotlin.internal.OnlyInputTypes K, V> Map.get1(key: K): V? = null!! fun test(map: Map) { - val a: Int = listOf(1).contains1("") + val a: Int = listOf(1).contains1("") val b: Boolean = listOf(1).contains1(1) - val c: Int = map.get1("") + val c: String? = map.get1("") val d: String? = map.get1(1) } \ No newline at end of file