[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:
Mikhail Zarechenskiy
2019-06-25 20:01:36 +03:00
parent 4d82b02f83
commit c2cf4aa2b5
34 changed files with 151 additions and 34 deletions
@@ -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,
@@ -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
}