Removed hacks for code migration from ConstraintSystemImpl.

This commit is contained in:
Stanislav Erokhin
2016-01-25 16:15:20 +03:00
parent 7703252239
commit e53e152f83
14 changed files with 23 additions and 36 deletions
@@ -45,14 +45,14 @@ internal class ConstraintSystemImpl(
override val status = object : ConstraintSystemStatus { override val status = object : ConstraintSystemStatus {
// for debug ConstraintsUtil.getDebugMessageForStatus might be used // for debug ConstraintsUtil.getDebugMessageForStatus might be used
override fun isSuccessful() = !hasContradiction() && !hasUnknownParameters() override fun isSuccessful() = !hasContradiction() && !hasUnknownParameters() && satisfyInitialConstraints()
override fun hasContradiction() = hasParameterConstraintError() || hasConflictingConstraints() override fun hasContradiction() = hasParameterConstraintError() || hasConflictingConstraints()
|| hasCannotCaptureTypesError() || hasTypeInferenceIncorporationError() || hasCannotCaptureTypesError() || errors.any { it is TypeInferenceError }
// hacks for library migration todo: remove its later
|| hasTypeParameterWithUnsatisfiedOnlyInputTypesError()
/** /**
* All hacks were removed. This comment is left for information.
*
* Hacks above are needed for the following example: * Hacks above are needed for the following example:
* *
* @kotlin.jvm.JvmName("containsAny") * @kotlin.jvm.JvmName("containsAny")
@@ -4,27 +4,14 @@ fun foo(i: Int) = 1
fun foo(a: Any) = 2 fun foo(a: Any) = 2
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <T> Iterable<T>.contains1(element: @kotlin.internal.NoInfer T): Boolean = false
@kotlin.jvm.JvmName("containsAny")
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@kotlin.internal.LowPriorityInOverloadResolution @kotlin.internal.LowPriorityInOverloadResolution
fun <T> Iterable<T>.contains1(element: T): Boolean = true fun bar(a: String?) = 3
fun bar(a: Any) = 4
fun main(args: Array<String>) {
println(box())
}
fun box(): String { fun box(): String {
if (foo(1) != 2) return "fail" if (foo(1) != 2) return "fail1"
val l = listOf(1, 2) if (bar(null) != 3) return "fail2"
val i: Int? = 42 return "OK"
val a: Any = ""
return when {
l.contains1(3) -> "fail0"
!l.contains1(i) -> "fail1"
!l.contains1(a) -> "fail2"
!l.contains1("") -> "fail3"
else -> "OK"
}
} }
@@ -10,7 +10,7 @@ P := My<T>*
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
-hasConflictingConstraints: false -hasConflictingConstraints: false
-hasContradiction: true -hasContradiction: false
-hasErrorInConstrainingTypes: false -hasErrorInConstrainingTypes: false
-hasParameterConstraintError: false -hasParameterConstraintError: false
-hasTypeInferenceIncorporationError: true -hasTypeInferenceIncorporationError: true
@@ -10,7 +10,7 @@ P := My<T>*
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
-hasConflictingConstraints: false -hasConflictingConstraints: false
-hasContradiction: true -hasContradiction: false
-hasErrorInConstrainingTypes: false -hasErrorInConstrainingTypes: false
-hasParameterConstraintError: false -hasParameterConstraintError: false
-hasTypeInferenceIncorporationError: true -hasTypeInferenceIncorporationError: true
@@ -10,7 +10,7 @@ P := My<T?>*
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
-hasConflictingConstraints: false -hasConflictingConstraints: false
-hasContradiction: true -hasContradiction: false
-hasErrorInConstrainingTypes: false -hasErrorInConstrainingTypes: false
-hasParameterConstraintError: false -hasParameterConstraintError: false
-hasTypeInferenceIncorporationError: true -hasTypeInferenceIncorporationError: true
@@ -10,7 +10,7 @@ P := My<T?>*
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
-hasConflictingConstraints: false -hasConflictingConstraints: false
-hasContradiction: true -hasContradiction: false
-hasErrorInConstrainingTypes: false -hasErrorInConstrainingTypes: false
-hasParameterConstraintError: false -hasParameterConstraintError: false
-hasTypeInferenceIncorporationError: true -hasTypeInferenceIncorporationError: true
@@ -10,7 +10,7 @@ P <: My<My<Consumer<T>>>*, <: My<out My<out Consumer<Int>>>
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
-hasConflictingConstraints: false -hasConflictingConstraints: false
-hasContradiction: true -hasContradiction: false
-hasErrorInConstrainingTypes: false -hasErrorInConstrainingTypes: false
-hasParameterConstraintError: false -hasParameterConstraintError: false
-hasTypeInferenceIncorporationError: true -hasTypeInferenceIncorporationError: true
@@ -10,7 +10,7 @@ P <: My<My<Producer<T>>>*, <: My<out My<out Producer<Int>>>
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
-hasConflictingConstraints: false -hasConflictingConstraints: false
-hasContradiction: true -hasContradiction: false
-hasErrorInConstrainingTypes: false -hasErrorInConstrainingTypes: false
-hasParameterConstraintError: false -hasParameterConstraintError: false
-hasTypeInferenceIncorporationError: true -hasTypeInferenceIncorporationError: true
@@ -10,7 +10,7 @@ P := Two<T, P>*
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
-hasConflictingConstraints: false -hasConflictingConstraints: false
-hasContradiction: true -hasContradiction: false
-hasErrorInConstrainingTypes: false -hasErrorInConstrainingTypes: false
-hasParameterConstraintError: false -hasParameterConstraintError: false
-hasTypeInferenceIncorporationError: true -hasTypeInferenceIncorporationError: true
@@ -10,7 +10,7 @@ P := My<T>*
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
-hasConflictingConstraints: false -hasConflictingConstraints: false
-hasContradiction: true -hasContradiction: false
-hasErrorInConstrainingTypes: false -hasErrorInConstrainingTypes: false
-hasParameterConstraintError: false -hasParameterConstraintError: false
-hasTypeInferenceIncorporationError: true -hasTypeInferenceIncorporationError: true
@@ -10,7 +10,7 @@ P := My<T>*
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
-hasConflictingConstraints: false -hasConflictingConstraints: false
-hasContradiction: true -hasContradiction: false
-hasErrorInConstrainingTypes: false -hasErrorInConstrainingTypes: false
-hasParameterConstraintError: false -hasParameterConstraintError: false
-hasTypeInferenceIncorporationError: true -hasTypeInferenceIncorporationError: true
@@ -3,7 +3,7 @@ interface A
class B : A class B : A
fun foo1(list: List<A>, arg: B?): Boolean { fun foo1(list: List<A>, arg: B?): Boolean {
// Type mismatch // Type mismatch
return <!TYPE_MISMATCH!>arg<!> in list return arg <!TYPE_INFERENCE_ONLY_INPUT_TYPES!>in<!> list // resolved to extension
} }
fun foo2(list: List<A>, arg: B?): Boolean { fun foo2(list: List<A>, arg: B?): Boolean {
// FAKE: no cast needed // FAKE: no cast needed
@@ -10,6 +10,6 @@ public fun <T> Iterable<T>.contains1(element: @kotlin.internal.NoInfer T): Boole
fun test() { fun test() {
val a: Int = listOf(1).contains1("") val a: Boolean = listOf(1).<!TYPE_INFERENCE_INCORPORATION_ERROR!>contains1<!>(<!TYPE_MISMATCH!>""<!>)
val b: Boolean = listOf(1).contains1(1) val b: Boolean = listOf(1).contains1(1)
} }
@@ -17,9 +17,9 @@ public fun <K, V> Map<K, V>.get1(key: Any?): Int = null!!
public fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.get1(key: K): V? = null!! public fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.get1(key: K): V? = null!!
fun test(map: Map<Int, String>) { fun test(map: Map<Int, String>) {
val a: Int = listOf(1).contains1("") val a: Int = listOf(1).<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>contains1("")<!>
val b: Boolean = listOf(1).contains1(1) val b: Boolean = listOf(1).contains1(1)
val c: Int = map.get1("") val c: String? = map.<!TYPE_INFERENCE_ONLY_INPUT_TYPES!>get1<!>("")
val d: String? = map.get1(1) val d: String? = map.get1(1)
} }