Don't skip constraints from equations with the kind equal
The problem was that we didn't incorporate T == Foo into K <: Inv<out T>. It happened because of optimisation that isn't applicable here as we already have projection in the initial type #KT-39777 Fixed
This commit is contained in:
+5
@@ -10006,6 +10006,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("equalitySubstitutionInsideNonInvariantType.kt")
|
||||
public void testEqualitySubstitutionInsideNonInvariantType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/equalitySubstitutionInsideNonInvariantType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectedTypeAdditionalTest.kt")
|
||||
public void testExpectedTypeAdditionalTest() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/expectedTypeAdditionalTest.kt");
|
||||
|
||||
+4
-3
@@ -221,9 +221,10 @@ class ConstraintIncorporator(
|
||||
val isFromVariableFixation = baseConstraint.position.from is FixVariableConstraintPosition
|
||||
|| otherConstraint.position.from is FixVariableConstraintPosition
|
||||
|
||||
if (!containsConstrainingTypeWithoutProjection(newConstraint, otherConstraint)
|
||||
&& !isUsefulForNullabilityConstraint
|
||||
&& !isFromVariableFixation
|
||||
if (!otherConstraint.kind.isEqual() &&
|
||||
!isUsefulForNullabilityConstraint &&
|
||||
!isFromVariableFixation &&
|
||||
!containsConstrainingTypeWithoutProjection(newConstraint, otherConstraint)
|
||||
) return
|
||||
|
||||
if (trivialConstraintTypeInferenceOracle.isGeneratedConstraintTrivial(
|
||||
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun <K> materialize(): K = TODO()
|
||||
|
||||
class Foo
|
||||
class Inv<T>
|
||||
|
||||
fun <T> test1(x: Inv<out T>) {}
|
||||
fun <T> test2(x: Inv<in T>) {}
|
||||
fun <T> test3(x: Inv<T>) {}
|
||||
|
||||
fun main() {
|
||||
test1<Foo>(materialize())
|
||||
test2<Foo>(materialize())
|
||||
test3<Foo>(materialize())
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
package
|
||||
|
||||
public fun main(): kotlin.Unit
|
||||
public fun </*0*/ K> materialize(): K
|
||||
public fun </*0*/ T> test1(/*0*/ x: Inv<out T>): kotlin.Unit
|
||||
public fun </*0*/ T> test2(/*0*/ x: Inv<in T>): kotlin.Unit
|
||||
public fun </*0*/ T> test3(/*0*/ x: Inv<T>): kotlin.Unit
|
||||
|
||||
public final class Foo {
|
||||
public constructor Foo()
|
||||
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 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
|
||||
}
|
||||
@@ -10013,6 +10013,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
|
||||
runTest("compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("equalitySubstitutionInsideNonInvariantType.kt")
|
||||
public void testEqualitySubstitutionInsideNonInvariantType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/equalitySubstitutionInsideNonInvariantType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectedTypeAdditionalTest.kt")
|
||||
public void testExpectedTypeAdditionalTest() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/expectedTypeAdditionalTest.kt");
|
||||
|
||||
Generated
+5
@@ -10008,6 +10008,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("equalitySubstitutionInsideNonInvariantType.kt")
|
||||
public void testEqualitySubstitutionInsideNonInvariantType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/equalitySubstitutionInsideNonInvariantType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectedTypeAdditionalTest.kt")
|
||||
public void testExpectedTypeAdditionalTest() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/expectedTypeAdditionalTest.kt");
|
||||
|
||||
Reference in New Issue
Block a user