[NI] Don't skip constraints with projections during variable fixation
Those constraints are only restored for variable fixation stage because of the influence on pefrormance. ^KT-37650 Fixed ^KT-37380 Fixed
This commit is contained in:
+5
@@ -11473,6 +11473,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt37043_2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt37650.kt")
|
||||
public void testKt37650() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt37650.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4420.kt")
|
||||
public void testKt4420() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt");
|
||||
|
||||
+7
-1
@@ -209,8 +209,14 @@ class ConstraintIncorporator(
|
||||
|
||||
val isUsefulForNullabilityConstraint =
|
||||
isPotentialUsefulNullabilityConstraint(newConstraint, otherConstraint.type, otherConstraint.kind)
|
||||
val isFromVariableFixation = baseConstraint.position.from is FixVariableConstraintPosition
|
||||
|| otherConstraint.position.from is FixVariableConstraintPosition
|
||||
|
||||
if (!containsConstrainingTypeWithoutProjection(newConstraint, otherConstraint)
|
||||
&& !isUsefulForNullabilityConstraint
|
||||
&& !isFromVariableFixation
|
||||
) return
|
||||
|
||||
if (!isUsefulForNullabilityConstraint && !containsConstrainingTypeWithoutProjection(newConstraint, otherConstraint)) return
|
||||
if (trivialConstraintTypeInferenceOracle.isGeneratedConstraintTrivial(
|
||||
baseConstraint, otherConstraint, newConstraint, isSubtype
|
||||
)
|
||||
|
||||
Vendored
-3
@@ -52,7 +52,6 @@ fun <L> main(x: L?, y: L) {
|
||||
foo3(x, Foo(Bar()))
|
||||
foo3(y, Foo(Bar()))
|
||||
|
||||
// Change after fix KT-37380
|
||||
foo4(x, Foo(Bar()))
|
||||
foo4(y, Foo(Bar()))
|
||||
|
||||
@@ -124,11 +123,9 @@ fun <L> main(x: L?, y: L) {
|
||||
foo22(x, Foo(Foo(InBar())))
|
||||
foo22(y, Foo(Foo(InBar())))
|
||||
|
||||
// Change after fix KT-37380
|
||||
foo23(x, Foo(Foo(Bar())))
|
||||
foo23(y, Foo(Foo(Bar())))
|
||||
|
||||
// Change after fix KT-37380
|
||||
foo24(x, Foo(Foo(Bar())))
|
||||
foo24(y, Foo(Foo(Bar())))
|
||||
}
|
||||
|
||||
Vendored
+6
-9
@@ -52,9 +52,8 @@ fun <L> main(x: L?, y: L) {
|
||||
foo3(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>)
|
||||
foo3(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>)
|
||||
|
||||
// Change after fix KT-37380
|
||||
foo4(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>"), TYPE_MISMATCH!>Foo(Bar())<!>)
|
||||
foo4(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>"), TYPE_MISMATCH!>Foo(Bar())<!>)
|
||||
foo4(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<out L!!>>")!>Foo(Bar())<!>)
|
||||
foo4(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<out L!!>>")!>Foo(Bar())<!>)
|
||||
|
||||
foo5(x, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
|
||||
foo5(y, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
|
||||
@@ -124,11 +123,9 @@ fun <L> main(x: L?, y: L) {
|
||||
foo22(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<InBar<L!!>>>")!>Foo(Foo(InBar()))<!>)
|
||||
foo22(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<InBar<L!!>>>")!>Foo(Foo(InBar()))<!>)
|
||||
|
||||
// Change after fix KT-37380
|
||||
foo23(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<Bar<L!!>>>"), TYPE_MISMATCH!>Foo(Foo(Bar()))<!>)
|
||||
foo23(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<Bar<L!!>>>"), TYPE_MISMATCH!>Foo(Foo(Bar()))<!>)
|
||||
foo23(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<Bar<out L!!>>>")!>Foo(Foo(Bar()))<!>)
|
||||
foo23(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<Bar<out L!!>>>")!>Foo(Foo(Bar()))<!>)
|
||||
|
||||
// Change after fix KT-37380
|
||||
foo24(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<Bar<L!!>>>"), TYPE_MISMATCH!>Foo(Foo(Bar()))<!>)
|
||||
foo24(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<Bar<L!!>>>"), TYPE_MISMATCH!>Foo(Foo(Bar()))<!>)
|
||||
foo24(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<Bar<in L!!>>>")!>Foo(Foo(Bar()))<!>)
|
||||
foo24(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<Bar<in L!!>>>")!>Foo(Foo(Bar()))<!>)
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -245,8 +245,8 @@ class Main<L>(x: L?, y: L) {
|
||||
val x420 = <!DEBUG_INFO_EXPRESSION_TYPE("IFoo<L>")!>foo42(x)<!>
|
||||
val x421 = <!DEBUG_INFO_EXPRESSION_TYPE("IFoo<L>")!>foo42(y)<!>
|
||||
|
||||
val x430 = <!DEBUG_INFO_EXPRESSION_TYPE("{IBar<L> & IFoo<L>}")!>foo43(x)<!>
|
||||
val x431 = <!DEBUG_INFO_EXPRESSION_TYPE("{IBar<L> & IFoo<L>}")!>foo43(y)<!>
|
||||
val x430 = <!DEBUG_INFO_EXPRESSION_TYPE("{IBar<L> & IBar<out L> & IFoo<L> & IFoo<out L>}")!>foo43(x)<!>
|
||||
val x431 = <!DEBUG_INFO_EXPRESSION_TYPE("{IBar<L> & IBar<out L> & IFoo<L> & IFoo<out L>}")!>foo43(y)<!>
|
||||
|
||||
// Change after fix KT-37380
|
||||
val x440 = <!DEBUG_INFO_EXPRESSION_TYPE("{IBar<L> & IFoo<String>}")!>foo44(x)<!>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
class Inv<T>
|
||||
|
||||
fun <T> materialize(): T = TODO()
|
||||
|
||||
fun <A> foo(x: Inv<A>) {}
|
||||
fun <B> bar(y: Inv<out B>): Inv<Inv<out B>> = materialize()
|
||||
|
||||
fun <K> test(plant: Inv<out K>) {
|
||||
val x = foo(bar(plant)) // OK in OI, NI: "Not enough information to infer type variable A"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ B> bar(/*0*/ y: Inv<out B>): Inv<Inv<out B>>
|
||||
public fun </*0*/ A> foo(/*0*/ x: Inv<A>): kotlin.Unit
|
||||
public fun </*0*/ T> materialize(): T
|
||||
public fun </*0*/ K> test(/*0*/ plant: Inv<out K>): kotlin.Unit
|
||||
|
||||
public final class Inv</*0*/ T> {
|
||||
public constructor Inv</*0*/ T>()
|
||||
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,4 +1,4 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// NI_EXPECTED_FILE
|
||||
|
||||
fun foo(first: Array<Any?>, second: Array<Any?>) = <!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Pair<!>(first.<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>toCollection<!>(<!NO_VALUE_FOR_PARAMETER!>)<!>, second.<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>toCollection<!>(<!NO_VALUE_FOR_PARAMETER!>)<!>)
|
||||
fun foo(first: Array<Any?>, second: Array<Any?>) = Pair(first.toCollection(<!NO_VALUE_FOR_PARAMETER!>)<!>, second.toCollection(<!NO_VALUE_FOR_PARAMETER!>)<!>)
|
||||
@@ -1,3 +1,3 @@
|
||||
package
|
||||
|
||||
public fun foo(/*0*/ first: kotlin.Array<kotlin.Any?>, /*1*/ second: kotlin.Array<kotlin.Any?>): [ERROR : Error function type]
|
||||
public fun foo(/*0*/ first: kotlin.Array<kotlin.Any?>, /*1*/ second: kotlin.Array<kotlin.Any?>): kotlin.Pair<kotlin.collections.MutableCollection<in kotlin.Any?>, kotlin.collections.MutableCollection<in kotlin.Any?>>
|
||||
|
||||
@@ -11480,6 +11480,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt37043_2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt37650.kt")
|
||||
public void testKt37650() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt37650.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4420.kt")
|
||||
public void testKt4420() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt");
|
||||
|
||||
Generated
+5
@@ -11475,6 +11475,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt37043_2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt37650.kt")
|
||||
public void testKt37650() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt37650.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4420.kt")
|
||||
public void testKt4420() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt");
|
||||
|
||||
Reference in New Issue
Block a user