[NI] Prioritize type variables related to output type for fixation
This commit is contained in:
+2
-2
@@ -44,8 +44,8 @@ class VariableFixationFinder {
|
|||||||
private enum class TypeVariableFixationReadiness {
|
private enum class TypeVariableFixationReadiness {
|
||||||
FORBIDDEN,
|
FORBIDDEN,
|
||||||
WITHOUT_PROPER_ARGUMENT_CONSTRAINT, // proper constraint from arguments -- not from upper bound for type parameters
|
WITHOUT_PROPER_ARGUMENT_CONSTRAINT, // proper constraint from arguments -- not from upper bound for type parameters
|
||||||
RELATED_TO_ANY_OUTPUT_TYPE,
|
|
||||||
WITH_COMPLEX_DEPENDENCY, // if type variable T has constraint with non fixed type variable inside (non-top-level): T <: Foo<S>
|
WITH_COMPLEX_DEPENDENCY, // if type variable T has constraint with non fixed type variable inside (non-top-level): T <: Foo<S>
|
||||||
|
RELATED_TO_ANY_OUTPUT_TYPE,
|
||||||
READY_FOR_FIXATION,
|
READY_FOR_FIXATION,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,8 +56,8 @@ class VariableFixationFinder {
|
|||||||
!notFixedTypeVariables.contains(variable) ||
|
!notFixedTypeVariables.contains(variable) ||
|
||||||
dependencyProvider.isVariableRelatedToTopLevelType(variable) -> TypeVariableFixationReadiness.FORBIDDEN
|
dependencyProvider.isVariableRelatedToTopLevelType(variable) -> TypeVariableFixationReadiness.FORBIDDEN
|
||||||
!variableHasProperArgumentConstraints(variable) -> TypeVariableFixationReadiness.WITHOUT_PROPER_ARGUMENT_CONSTRAINT
|
!variableHasProperArgumentConstraints(variable) -> TypeVariableFixationReadiness.WITHOUT_PROPER_ARGUMENT_CONSTRAINT
|
||||||
dependencyProvider.isVariableRelatedToAnyOutputType(variable) -> TypeVariableFixationReadiness.RELATED_TO_ANY_OUTPUT_TYPE
|
|
||||||
hasDependencyToOtherTypeVariables(variable) -> TypeVariableFixationReadiness.WITH_COMPLEX_DEPENDENCY
|
hasDependencyToOtherTypeVariables(variable) -> TypeVariableFixationReadiness.WITH_COMPLEX_DEPENDENCY
|
||||||
|
dependencyProvider.isVariableRelatedToAnyOutputType(variable) -> TypeVariableFixationReadiness.RELATED_TO_ANY_OUTPUT_TYPE
|
||||||
else -> TypeVariableFixationReadiness.READY_FOR_FIXATION
|
else -> TypeVariableFixationReadiness.READY_FOR_FIXATION
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
generateException(Data(1), { Data(it.x + 2) })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> generateException(a: T, next: (T) -> T) {}
|
||||||
|
|
||||||
|
class Data<out K>(val x: K)
|
||||||
Vendored
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun </*0*/ T> generateException(/*0*/ a: T, /*1*/ next: (T) -> T): kotlin.Unit
|
||||||
|
public fun test(): kotlin.Unit
|
||||||
|
|
||||||
|
public final class Data</*0*/ out K> {
|
||||||
|
public constructor Data</*0*/ out K>(/*0*/ x: K)
|
||||||
|
public final val x: K
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -10827,6 +10827,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("operationsOnIntegerValueTypes.kt")
|
||||||
|
public void testOperationsOnIntegerValueTypes() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/constraints/operationsOnIntegerValueTypes.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("subtypeConstraintOnNullableType.kt")
|
@TestMetadata("subtypeConstraintOnNullableType.kt")
|
||||||
public void testSubtypeConstraintOnNullableType() throws Exception {
|
public void testSubtypeConstraintOnNullableType() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/constraints/subtypeConstraintOnNullableType.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/constraints/subtypeConstraintOnNullableType.kt");
|
||||||
|
|||||||
+6
@@ -10827,6 +10827,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("operationsOnIntegerValueTypes.kt")
|
||||||
|
public void testOperationsOnIntegerValueTypes() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/constraints/operationsOnIntegerValueTypes.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("subtypeConstraintOnNullableType.kt")
|
@TestMetadata("subtypeConstraintOnNullableType.kt")
|
||||||
public void testSubtypeConstraintOnNullableType() throws Exception {
|
public void testSubtypeConstraintOnNullableType() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/constraints/subtypeConstraintOnNullableType.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/constraints/subtypeConstraintOnNullableType.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user