Don't stop constraints processing if all type variables have proper equality constraints
Those type variable may have other constraints after incorporation into which, the constraint error may appear ^KT-42042 Fixed
This commit is contained in:
+6
@@ -28773,6 +28773,12 @@ 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 {
|
||||
|
||||
-11
@@ -122,17 +122,6 @@ 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
@@ -7,12 +7,12 @@ package boundsWithSubstitutors
|
||||
class C : A<C>()
|
||||
|
||||
val a = B<C>()
|
||||
val a1 = B<<!UPPER_BOUND_VIOLATED!>Int<!>>()
|
||||
val a1 = B<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Int<!>>()
|
||||
|
||||
class X<A, B : A>()
|
||||
|
||||
val b = X<Any, X<A<C>, C>>()
|
||||
val b0 = X<Any, <!UPPER_BOUND_VIOLATED!>Any?<!>>()
|
||||
val b0 = X<Any, <!UPPER_BOUND_VIOLATED, 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}!>outer.<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH{OI}!>Inner()<!><!>)
|
||||
checkSubtype<Outer<CharSequence>.Inner<CharSequence>>(<!TYPE_MISMATCH{NI}, TYPE_MISMATCH!>outer.<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH{OI}!>Inner()<!><!>)
|
||||
|
||||
outer.set(outer.bar())
|
||||
outer.set(outer.Inner())
|
||||
|
||||
Vendored
+1
-1
@@ -28,5 +28,5 @@ abstract class MySettingsListener<S extends MyComparableSettings> {}
|
||||
fun test() {
|
||||
val a = MySettings.getSettings()
|
||||
a.getLinkedProjectsSettings()
|
||||
a.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE{OI}, TYPE_INFERENCE_UPPER_BOUND_VIOLATED{OI}!>linkedProjectsSettings<!>
|
||||
a.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE{OI}, TYPE_INFERENCE_UPPER_BOUND_VIOLATED{OI}, UNRESOLVED_REFERENCE_WRONG_RECEIVER!>linkedProjectsSettings<!>
|
||||
}
|
||||
|
||||
compiler/testData/diagnostics/tests/j+k/genericConstructor/classTypeParameterInferredFromArgument.kt
Vendored
+1
-1
@@ -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{NI}, TYPE_MISMATCH!>x<!>)
|
||||
A<CharSequence, String>("", <!TYPE_MISMATCH{NI}, 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{NI}, TYPE_MISMATCH!>x<!>, 1)
|
||||
Outer<Int>().Inner<CharSequence, String, Int>("", <!TYPE_MISMATCH{NI}, TYPE_MISMATCH, TYPE_MISMATCH!>x<!>, 1)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
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.Trivial()
|
||||
return proof.cast(value)
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
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)
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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!>List<Any><!>>()
|
||||
val test8 = TC2<Number, <!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>List<Any><!>>()
|
||||
|
||||
+1
-1
@@ -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!>List<Any><!>>()
|
||||
val test16 = TC<Number, <!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>List<Any><!>>()
|
||||
|
||||
Generated
+6
@@ -28869,6 +28869,12 @@ 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 {
|
||||
|
||||
Reference in New Issue
Block a user