[FE 1.0] Set a fixation priority for self type variables less than any of ready for fixation kinds
^KT-51040 Fixed ^KT-49838
This commit is contained in:
+6
@@ -19039,6 +19039,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/inference/kt49838.kt");
|
runTest("compiler/testData/codegen/box/inference/kt49838.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt51040.kt")
|
||||||
|
public void testKt51040() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/kt51040.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lambdaWithStarReturn.kt")
|
@TestMetadata("lambdaWithStarReturn.kt")
|
||||||
public void testLambdaWithStarReturn() throws Exception {
|
public void testLambdaWithStarReturn() throws Exception {
|
||||||
|
|||||||
+2
-2
@@ -44,13 +44,13 @@ class VariableFixationFinder(
|
|||||||
enum class TypeVariableFixationReadiness {
|
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
|
||||||
|
READY_FOR_FIXATION_DECLARED_UPPER_BOUND_WITH_SELF_TYPES,
|
||||||
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>
|
||||||
WITH_TRIVIAL_OR_NON_PROPER_CONSTRAINTS, // proper trivial constraint from arguments, Nothing <: T
|
WITH_TRIVIAL_OR_NON_PROPER_CONSTRAINTS, // proper trivial constraint from arguments, Nothing <: T
|
||||||
RELATED_TO_ANY_OUTPUT_TYPE,
|
RELATED_TO_ANY_OUTPUT_TYPE,
|
||||||
FROM_INCORPORATION_OF_DECLARED_UPPER_BOUND,
|
FROM_INCORPORATION_OF_DECLARED_UPPER_BOUND,
|
||||||
READY_FOR_FIXATION_UPPER,
|
READY_FOR_FIXATION_UPPER,
|
||||||
READY_FOR_FIXATION_LOWER,
|
READY_FOR_FIXATION_LOWER,
|
||||||
READY_FOR_FIXATION_DECLARED_UPPER_BOUND_WITH_SELF_TYPES,
|
|
||||||
READY_FOR_FIXATION,
|
READY_FOR_FIXATION,
|
||||||
READY_FOR_FIXATION_REIFIED,
|
READY_FOR_FIXATION_REIFIED,
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ class VariableFixationFinder(
|
|||||||
): TypeVariableFixationReadiness = when {
|
): TypeVariableFixationReadiness = when {
|
||||||
!notFixedTypeVariables.contains(variable) ||
|
!notFixedTypeVariables.contains(variable) ||
|
||||||
dependencyProvider.isVariableRelatedToTopLevelType(variable) -> TypeVariableFixationReadiness.FORBIDDEN
|
dependencyProvider.isVariableRelatedToTopLevelType(variable) -> TypeVariableFixationReadiness.FORBIDDEN
|
||||||
isTypeInferenceForSelfTypesSupported && hasOnlyDeclaredUpperBoundSelfTypes(variable) && !hasDependencyToOtherTypeVariables(variable) ->
|
isTypeInferenceForSelfTypesSupported && hasOnlyDeclaredUpperBoundSelfTypes(variable) ->
|
||||||
TypeVariableFixationReadiness.READY_FOR_FIXATION_DECLARED_UPPER_BOUND_WITH_SELF_TYPES
|
TypeVariableFixationReadiness.READY_FOR_FIXATION_DECLARED_UPPER_BOUND_WITH_SELF_TYPES
|
||||||
!variableHasProperArgumentConstraints(variable) -> TypeVariableFixationReadiness.WITHOUT_PROPER_ARGUMENT_CONSTRAINT
|
!variableHasProperArgumentConstraints(variable) -> TypeVariableFixationReadiness.WITHOUT_PROPER_ARGUMENT_CONSTRAINT
|
||||||
hasDependencyToOtherTypeVariables(variable) -> TypeVariableFixationReadiness.WITH_COMPLEX_DEPENDENCY
|
hasDependencyToOtherTypeVariables(variable) -> TypeVariableFixationReadiness.WITH_COMPLEX_DEPENDENCY
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// WITH_STDLIB
|
||||||
|
// FULL_JDK
|
||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
inline fun <reified T : Enum<T>> emptyEnumSet(): EnumSet<T> = EnumSet.noneOf(T::class.java)
|
||||||
|
fun <T : Enum<T>> enumSetOf(e: T): EnumSet<T> = EnumSet.of(e)
|
||||||
|
|
||||||
|
enum class SomeEnum { ONE }
|
||||||
|
val set = enumSetOf(SomeEnum.ONE).takeIf { it.size > 0 } ?: emptyEnumSet()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return if (set.first() == SomeEnum.ONE) "OK" else "NOK"
|
||||||
|
}
|
||||||
@@ -1,6 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// FIR status: several false UPPER_BOUND_VIOLATED are reported
|
|
||||||
|
|
||||||
abstract class Interpreter<IS, TS, SELF>
|
abstract class Interpreter<IS, TS, SELF>
|
||||||
where IS : Interpreter.Intermediary<SELF>,
|
where IS : Interpreter.Intermediary<SELF>,
|
||||||
TS : Interpreter.Terminal<SELF>,
|
TS : Interpreter.Terminal<SELF>,
|
||||||
|
|||||||
+6
@@ -18637,6 +18637,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/inference/kt49838.kt");
|
runTest("compiler/testData/codegen/box/inference/kt49838.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt51040.kt")
|
||||||
|
public void testKt51040() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/kt51040.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lambdaWithStarReturn.kt")
|
@TestMetadata("lambdaWithStarReturn.kt")
|
||||||
public void testLambdaWithStarReturn() throws Exception {
|
public void testLambdaWithStarReturn() throws Exception {
|
||||||
|
|||||||
+6
@@ -19039,6 +19039,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/inference/kt49838.kt");
|
runTest("compiler/testData/codegen/box/inference/kt49838.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt51040.kt")
|
||||||
|
public void testKt51040() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/kt51040.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lambdaWithStarReturn.kt")
|
@TestMetadata("lambdaWithStarReturn.kt")
|
||||||
public void testLambdaWithStarReturn() throws Exception {
|
public void testLambdaWithStarReturn() throws Exception {
|
||||||
|
|||||||
+5
@@ -15487,6 +15487,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/inference/kt47316.kt");
|
runTest("compiler/testData/codegen/box/inference/kt47316.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt51040.kt")
|
||||||
|
public void testKt51040() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/kt51040.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lambdaWithStarReturn.kt")
|
@TestMetadata("lambdaWithStarReturn.kt")
|
||||||
public void testLambdaWithStarReturn() throws Exception {
|
public void testLambdaWithStarReturn() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inference/lambdaWithStarReturn.kt");
|
runTest("compiler/testData/codegen/box/inference/lambdaWithStarReturn.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user