[NI] Move ability to convert standalone SAM-argument under the feature
If new inference is enabled only for IDE analysis, then this feature will be disabled to reduce difference between new and old inference, but if new inference is enabled in the compiler, then this feature will be enabled too to preserve behavior of new inference for compilation #KT-32175 Fixed #KT-32143 Fixed #KT-32123 Fixed #KT-32230 Fixed
This commit is contained in:
@@ -45,7 +45,8 @@ class JavaSyntheticScopes(
|
||||
val scopesWithForceEnabledSamAdapters: Collection<SyntheticScope>
|
||||
|
||||
init {
|
||||
val newInferenceEnabled = languageVersionSettings.supportsFeature(LanguageFeature.NewInference)
|
||||
val samConversionPerArgumentIsEnabled =
|
||||
languageVersionSettings.supportsFeature(LanguageFeature.SamConversionPerArgument)
|
||||
|
||||
val javaSyntheticPropertiesScope = JavaSyntheticPropertiesScope(storageManager, lookupTracker)
|
||||
val scopesFromExtensions = SyntheticScopeProviderExtension
|
||||
@@ -58,12 +59,12 @@ class JavaSyntheticScopes(
|
||||
samConventionResolver,
|
||||
deprecationResolver,
|
||||
lookupTracker,
|
||||
samViaSyntheticScopeDisabled = newInferenceEnabled
|
||||
samViaSyntheticScopeDisabled = samConversionPerArgumentIsEnabled
|
||||
)
|
||||
|
||||
scopes = listOf(javaSyntheticPropertiesScope, samAdapterFunctionsScope) + scopesFromExtensions
|
||||
|
||||
if (newInferenceEnabled) {
|
||||
if (samConversionPerArgumentIsEnabled) {
|
||||
val forceEnabledSamAdapterFunctionsScope = SamAdapterFunctionsScope(
|
||||
storageManager,
|
||||
samConventionResolver,
|
||||
|
||||
+7
-10
@@ -17,13 +17,11 @@
|
||||
package org.jetbrains.kotlin.synthetic
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
||||
import org.jetbrains.kotlin.load.java.sam.SamAdapterDescriptor
|
||||
import org.jetbrains.kotlin.load.java.sam.SamConstructorDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCallImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.NewResolvedCallImpl
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
|
||||
@@ -63,13 +61,12 @@ fun syntheticVisibility(originalDescriptor: DeclarationDescriptorWithVisibility,
|
||||
}
|
||||
|
||||
fun <D : CallableDescriptor> ResolvedCall<D>.isResolvedWithSamConversions(): Boolean {
|
||||
return if (this is NewResolvedCallImpl<D>) {
|
||||
// New inference
|
||||
this.resolvedCallAtom.argumentsWithConversion.isNotEmpty()
|
||||
} else {
|
||||
// Old Inference
|
||||
this.resultingDescriptor is SamAdapterDescriptor<*> ||
|
||||
this.resultingDescriptor is SamConstructorDescriptor ||
|
||||
this.resultingDescriptor is SamAdapterExtensionFunctionDescriptor
|
||||
if (this is NewResolvedCallImpl<D> && resolvedCallAtom.argumentsWithConversion.isNotEmpty()) {
|
||||
return true
|
||||
}
|
||||
|
||||
// Feature SamConversionPerArgument is disabled
|
||||
return this.resultingDescriptor is SamAdapterDescriptor<*> ||
|
||||
this.resultingDescriptor is SamConstructorDescriptor ||
|
||||
this.resultingDescriptor is SamAdapterExtensionFunctionDescriptor
|
||||
}
|
||||
Reference in New Issue
Block a user