[NI] Introduce flag to change constraint system for overload resolution
This commit doesn't change behaviour of any inference algorithm, it introduces opportunity to switch constraint system that is used for overload resolution and fix problematic cases by changing one enum entry. Due to fundamental changes, there are cases where a new inference algorithm reports overload resolution ambiguity errors (#KT-31670, #KT-31758), which is correct from its point of view. However, this is a breaking change and to really make it, we should be very confident and have enough motivation for it, therefore, we don't change behavior now in order to collect more examples (if there are any). And if we find a lot of erroneous examples, we'll be able to change the behavior quite simply
This commit is contained in:
@@ -29,4 +29,7 @@ object AnalysisFlags {
|
||||
|
||||
@JvmStatic
|
||||
val allowResultReturnType by AnalysisFlag.Delegates.Boolean
|
||||
|
||||
@JvmStatic
|
||||
val constraintSystemForOverloadResolution by AnalysisFlag.Delegates.ConstraintSystemForOverloadResolution
|
||||
}
|
||||
|
||||
+6
-1
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.tower
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.config.AnalysisFlags
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
@@ -28,6 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isInfixCall
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isSuperOrDelegatingConstructorCall
|
||||
import org.jetbrains.kotlin.resolve.calls.components.KotlinResolutionCallbacks
|
||||
import org.jetbrains.kotlin.resolve.calls.components.KotlinResolutionStatelessCallbacks
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilderImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintInjector
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.SimpleConstraintSystemImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.isCoroutineCallWithAdditionalInference
|
||||
@@ -88,6 +90,9 @@ class KotlinResolutionStatelessCallbacksImpl(
|
||||
override fun createConstraintSystemForOverloadResolution(
|
||||
constraintInjector: ConstraintInjector, builtIns: KotlinBuiltIns
|
||||
): SimpleConstraintSystem {
|
||||
return SimpleConstraintSystemImpl(constraintInjector, builtIns)
|
||||
return if (languageVersionSettings.getFlag(AnalysisFlags.constraintSystemForOverloadResolution).forNewInference())
|
||||
SimpleConstraintSystemImpl(constraintInjector, builtIns)
|
||||
else
|
||||
ConstraintSystemBuilderImpl.forSpecificity()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user