[NI] Introduce feature for passing function references with defaults
Relates to KT-8834, we continue reducing differences between old and new inference. Note that as for `SamConversionPerArgument`, this feature is enabled in the compiler and not in the IDE to avoid breaking code for those users that already enabled new inference in the compiler
This commit is contained in:
+4
-1
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.components
|
||||
|
||||
import org.jetbrains.kotlin.builtins.*
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.resolve.calls.components.CreateFreshVariablesSubstitutor.createToFreshVariableSubstitutorAndAddInitialConstraints
|
||||
@@ -180,7 +181,9 @@ class CallableReferencesCandidateFactory(
|
||||
expectedType
|
||||
)
|
||||
|
||||
if (defaults != 0) {
|
||||
if (defaults != 0 &&
|
||||
!callComponents.languageVersionSettings.supportsFeature(LanguageFeature.FunctionReferenceWithDefaultValueAsOtherType)
|
||||
) {
|
||||
diagnostics.add(CallableReferencesDefaultArgumentUsed(argument, candidateDescriptor, defaults))
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -92,6 +92,7 @@ class CallableReferenceResolver(
|
||||
)
|
||||
}
|
||||
diagnosticsHolder.addDiagnosticIfNotNull(diagnostic)
|
||||
chosenCandidate.diagnostics.forEach { diagnosticsHolder.addDiagnostic(it) }
|
||||
chosenCandidate.freshSubstitutor = toFreshSubstitutor
|
||||
} else {
|
||||
if (candidates.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user