[NI] Implement various optimizations for incorporation algorithm
Mostly, these optimisations are picked from the old inference. Also, remove exponential complexity for flexible types in approximation, note that more correct fix for this would be to introduce new types that corresponds just to platform types to avoid nullability problems, but due to complexity it will be done later #KT-31415 Fixed
This commit is contained in:
+2
-3
@@ -158,9 +158,8 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext,
|
||||
}
|
||||
*/
|
||||
|
||||
val simpleType = this.asSimpleType() ?: return false
|
||||
repeat(simpleType.argumentsCount()) { index ->
|
||||
val argument = simpleType.getArgument(index)
|
||||
repeat(argumentsCount()) { index ->
|
||||
val argument = getArgument(index)
|
||||
if (!argument.isStarProjection() && argument.getType().containsInternal(predicate, visited)) return true
|
||||
}
|
||||
|
||||
|
||||
@@ -144,13 +144,13 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext {
|
||||
return typeConstructor
|
||||
}
|
||||
|
||||
override fun SimpleTypeMarker.argumentsCount(): Int {
|
||||
override fun KotlinTypeMarker.argumentsCount(): Int {
|
||||
require(this is ConeKotlinType)
|
||||
|
||||
return this.typeArguments.size
|
||||
}
|
||||
|
||||
override fun SimpleTypeMarker.getArgument(index: Int): TypeArgumentMarker {
|
||||
override fun KotlinTypeMarker.getArgument(index: Int): TypeArgumentMarker {
|
||||
require(this is ConeKotlinType)
|
||||
|
||||
return this.typeArguments.getOrNull(index)
|
||||
|
||||
+10
@@ -10059,6 +10059,16 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
|
||||
runTest("compiler/testData/diagnostics/tests/inference/constraints/kt8879.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("manyConstraintsDueToFlexibleRawTypes.kt")
|
||||
public void testManyConstraintsDueToFlexibleRawTypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/constraints/manyConstraintsDueToFlexibleRawTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("manyConstraintsDueToRecursiveFlexibleTypesWithWildcards.kt")
|
||||
public void testManyConstraintsDueToRecursiveFlexibleTypesWithWildcards() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/constraints/manyConstraintsDueToRecursiveFlexibleTypesWithWildcards.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notNullConstraintOnNullableType.kt")
|
||||
public void testNotNullConstraintOnNullableType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/constraints/notNullConstraintOnNullableType.kt");
|
||||
|
||||
Reference in New Issue
Block a user