Introduce compiler key to disable compatibility resolution mechanism
Enable it if one was using new inferene before 1.4 #KT-40128 Fixed #KT-40112 Fixed #KT-40113 Fixed
This commit is contained in:
+1
-1
@@ -213,7 +213,7 @@ class CallableReferencesCandidateFactory(
|
||||
)
|
||||
|
||||
if (needCompatibilityResolveForCallableReference(callableReferenceAdaptation, candidateDescriptor)) {
|
||||
diagnostics.add(LowerPriorityToPreserveCompatibility)
|
||||
markCandidateForCompatibilityResolve(diagnostics)
|
||||
}
|
||||
|
||||
if (callableReferenceAdaptation != null &&
|
||||
|
||||
+1
-1
@@ -261,7 +261,7 @@ internal object CompatibilityOfTypeVariableAsIntersectionTypePart : ResolutionPa
|
||||
|
||||
// See TypeBoundsImpl.computeValues(). It returns several values for such situation which means an error in OI
|
||||
if (callComponents.statelessCallbacks.isOldIntersectionIsEmpty(constraints.map { it.type }.cast())) {
|
||||
addDiagnostic(LowerPriorityToPreserveCompatibility)
|
||||
markCandidateForCompatibilityResolve()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ object SamTypeConversions : ParameterTypeConversion {
|
||||
)
|
||||
|
||||
if (needCompatibilityResolveForSAM(candidate, expectedParameterType)) {
|
||||
candidate.addDiagnostic(LowerPriorityToPreserveCompatibility)
|
||||
candidate.markCandidateForCompatibilityResolve()
|
||||
}
|
||||
|
||||
val samDescriptor = originalExpectedType.constructor.declarationDescriptor
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ object SuspendTypeConversions : ParameterTypeConversion {
|
||||
|
||||
candidate.resolvedCall.registerArgumentWithSuspendConversion(argument, nonSuspendParameterType)
|
||||
|
||||
candidate.addDiagnostic(LowerPriorityToPreserveCompatibility)
|
||||
candidate.markCandidateForCompatibilityResolve()
|
||||
|
||||
return nonSuspendParameterType
|
||||
}
|
||||
|
||||
+2
-1
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.model.LowerPriorityToPreserv
|
||||
import org.jetbrains.kotlin.resolve.calls.model.KotlinCallArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.KotlinResolutionCandidate
|
||||
import org.jetbrains.kotlin.resolve.calls.model.SimpleKotlinCallArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.markCandidateForCompatibilityResolve
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.types.isDynamic
|
||||
@@ -78,7 +79,7 @@ object UnitTypeConversions : ParameterTypeConversion {
|
||||
|
||||
candidate.resolvedCall.registerArgumentWithUnitConversion(argument, nonUnitReturnedParameterType)
|
||||
|
||||
candidate.addDiagnostic(LowerPriorityToPreserveCompatibility)
|
||||
candidate.markCandidateForCompatibilityResolve()
|
||||
|
||||
return nonUnitReturnedParameterType
|
||||
}
|
||||
|
||||
+13
-4
@@ -16,22 +16,22 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.model
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.resolve.calls.components.CallableReferenceResolver
|
||||
import org.jetbrains.kotlin.resolve.calls.components.KotlinResolutionCallbacks
|
||||
import org.jetbrains.kotlin.resolve.calls.components.NewConstraintSystemImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.components.TypeArgumentsToParametersMapper
|
||||
import org.jetbrains.kotlin.resolve.calls.components.*
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.NewConstraintSystem
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.FreshVariableNewTypeSubstitutor
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.LowerPriorityToPreserveCompatibility
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.NewConstraintSystemImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.*
|
||||
import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
|
||||
|
||||
abstract class ResolutionPart {
|
||||
@@ -250,3 +250,12 @@ class MutableResolvedCallAtom(
|
||||
override fun toString(): String = "$atom, candidate = $candidateDescriptor"
|
||||
}
|
||||
|
||||
fun KotlinResolutionCandidate.markCandidateForCompatibilityResolve() {
|
||||
if (callComponents.languageVersionSettings.supportsFeature(LanguageFeature.DisableCompatibilityModeForNewInference)) return
|
||||
addDiagnostic(LowerPriorityToPreserveCompatibility)
|
||||
}
|
||||
|
||||
fun CallableReferencesCandidateFactory.markCandidateForCompatibilityResolve(diagnostics: SmartList<KotlinCallDiagnostic>) {
|
||||
if (callComponents.languageVersionSettings.supportsFeature(LanguageFeature.DisableCompatibilityModeForNewInference)) return
|
||||
diagnostics.add(LowerPriorityToPreserveCompatibility)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user