Revert "Don't stop constraints processing if all type variables have proper equality constraints"

This reverts commit b87c2a15
This commit is contained in:
Victor Petukhov
2021-04-26 09:17:27 +03:00
parent 287ff3ed55
commit e110b49cab
13 changed files with 19 additions and 61 deletions
@@ -29189,12 +29189,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/typeParameters/implicitNothingOnDelegates.kt");
}
@Test
@TestMetadata("kt42042.kt")
public void testKt42042() throws Exception {
runTest("compiler/testData/diagnostics/tests/typeParameters/kt42042.kt");
}
@Test
@TestMetadata("kt42396.kt")
public void testKt42396() throws Exception {
@@ -122,6 +122,17 @@ class ConstraintInjector(
constraintIncorporator.incorporate(typeCheckerContext, typeVariable, constraintToIncorporate)
}
}
val contextOps = c as? ConstraintSystemOperation
if (!typeCheckerContext.hasConstraintsToProcess() ||
(contextOps != null && c.notFixedTypeVariables.all { typeVariable ->
typeVariable.value.constraints.any { constraint ->
constraint.kind == EQUALITY && contextOps.isProperType(constraint.type)
}
})
) {
break
}
}
}
+2 -2
View File
@@ -7,12 +7,12 @@ package boundsWithSubstitutors
class C : A<C>()
val a = B<C>()
val a1 = B<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Int<!>>()
val a1 = B<<!UPPER_BOUND_VIOLATED!>Int<!>>()
class X<A, B : A>()
val b = X<Any, X<A<C>, C>>()
val b0 = X<Any, <!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any?<!>>()
val b0 = X<Any, <!UPPER_BOUND_VIOLATED!>Any?<!>>()
val b1 = X<Any, X<A<C>, <!UPPER_BOUND_VIOLATED!>String<!>>>()
// FILE: b.kt
@@ -32,7 +32,7 @@ fun main() {
checkSubtype<Outer<*>.Inner<*>>(outer.Inner<Int>())
checkSubtype<Outer<CharSequence>.Inner<CharSequence>>(<!TYPE_MISMATCH!>outer.bar()<!>)
checkSubtype<Outer<CharSequence>.Inner<CharSequence>>(<!TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!>outer.<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH{OI}!>Inner()<!><!>)
checkSubtype<Outer<CharSequence>.Inner<CharSequence>>(<!TYPE_MISMATCH{NI}!>outer.<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH{OI}!>Inner()<!><!>)
outer.set(outer.bar())
outer.set(outer.Inner())
@@ -5,5 +5,5 @@ fun <E : Enum<E>> createMap(enumClass: Class<E>) {}
fun reproduce() {
val enumClass: Class<Enum<*>> = "any" as Class<Enum<*>>
createMap(<!TYPE_MISMATCH, TYPE_MISMATCH!>enumClass<!>)
createMap(enumClass)
}
@@ -12,6 +12,6 @@ fun test(x: List<Int>, y: List<String>) {
A("", x) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER{NI}!>_<!><A<Any?>>() }
A("", y) checkType { _<A<String?>>() }
A<CharSequence, String>("", <!TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH!>x<!>)
A<CharSequence, String>("", <!TYPE_MISMATCH, TYPE_MISMATCH!>x<!>)
A<CharSequence, String>("", y)
}
@@ -14,5 +14,5 @@ fun test(x: List<Int>, y: List<String>) {
Outer<Int>().Inner<CharSequence, String, Int>("", y, 1) checkType { _<Outer<Int>.Inner<CharSequence>>() }
Outer<Int>().Inner("", x, 1) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER{NI}!>_<!><Outer<Int>.Inner<Any>>() }
Outer<Int>().Inner<CharSequence, String, Int>("", <!TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH!>x<!>, 1)
Outer<Int>().Inner<CharSequence, String, Int>("", <!TYPE_MISMATCH, TYPE_MISMATCH!>x<!>, 1)
}
@@ -1,11 +0,0 @@
sealed class Subtype<A1, B1> {
abstract fun cast(value: A1): B1
class Trivial<A2 : B2, B2> : Subtype<A2, B2>() {
override fun cast(value: A2): B2 = value
}
}
fun <A, B> unsafeCast(value: A): B {
val proof: Subtype<A, B> = <!UPPER_BOUND_VIOLATED!>Subtype.Trivial()<!>
return proof.cast(value)
}
@@ -1,11 +0,0 @@
sealed class Subtype<A1, B1> {
abstract fun cast(value: A1): B1
class Trivial<A2 : B2, B2> : Subtype<A2, B2>() {
override fun cast(value: A2): B2 = value
}
}
fun <A, B> unsafeCast(value: A): B {
val proof: Subtype<A, B> = Subtype.<!TYPE_MISMATCH, TYPE_MISMATCH!>Trivial()<!>
return proof.cast(value)
}
@@ -1,19 +0,0 @@
package
public fun </*0*/ A, /*1*/ B> unsafeCast(/*0*/ value: A): B
public sealed class Subtype</*0*/ A1, /*1*/ B1> {
protected constructor Subtype</*0*/ A1, /*1*/ B1>()
public abstract fun cast(/*0*/ value: A1): B1
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final class Trivial</*0*/ A2 : B2, /*1*/ B2> : Subtype<A2, B2> {
public constructor Trivial</*0*/ A2 : B2, /*1*/ B2>()
public open override /*1*/ fun cast(/*0*/ value: A2): B2
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -14,4 +14,4 @@ fun test4(x: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>TC2<Number, List<Any
val test5 = TC2<Number, Collection<Number>>()
val test6 = TC2<Number, Collection<Int>>()
val test7 = TC2<Number, List<Int>>()
val test8 = TC2<Number, <!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>List<Any><!>>()
val test8 = TC2<Number, <!UPPER_BOUND_VIOLATED!>List<Any><!>>()
@@ -29,4 +29,4 @@ fun test12(x: TC<Number, <!UPPER_BOUND_VIOLATED!>List<Any><!>>) {}
val test13 = TC<Number, Collection<Number>>()
val test14 = TC<Number, Collection<Int>>()
val test15 = TC<Number, List<Int>>()
val test16 = TC<Number, <!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>List<Any><!>>()
val test16 = TC<Number, <!UPPER_BOUND_VIOLATED!>List<Any><!>>()
@@ -29285,12 +29285,6 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/typeParameters/implicitNothingOnDelegates.kt");
}
@Test
@TestMetadata("kt42042.kt")
public void testKt42042() throws Exception {
runTest("compiler/testData/diagnostics/tests/typeParameters/kt42042.kt");
}
@Test
@TestMetadata("kt42396.kt")
public void testKt42396() throws Exception {