Extract SyntheticScopes to injection component
This commit is contained in:
+2
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.load.kotlin.nativeDeclarations.NativeFunChecker
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmOverloadFilter
|
||||
import org.jetbrains.kotlin.resolve.jvm.checkers.*
|
||||
import org.jetbrains.kotlin.synthetic.JavaSyntheticScopes
|
||||
import org.jetbrains.kotlin.types.DynamicTypesSettings
|
||||
|
||||
|
||||
@@ -72,5 +73,6 @@ public object JvmPlatformConfigurator : PlatformConfigurator(
|
||||
super.configure(container)
|
||||
|
||||
container.useImpl<ReflectionAPICallChecker>()
|
||||
container.useImpl<JavaSyntheticScopes>()
|
||||
}
|
||||
}
|
||||
|
||||
+9
-7
@@ -29,10 +29,7 @@ import org.jetbrains.kotlin.incremental.record
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.scopes.BaseImportingScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.HierarchicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.collectSyntheticExtensionProperties
|
||||
import org.jetbrains.kotlin.resolve.scopes.*
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
||||
@@ -49,7 +46,7 @@ interface SyntheticJavaPropertyDescriptor : PropertyDescriptor {
|
||||
val setMethod: FunctionDescriptor?
|
||||
|
||||
companion object {
|
||||
fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, resolutionScope: HierarchicalScope): SyntheticJavaPropertyDescriptor? {
|
||||
fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, syntheticScopes: SyntheticScopes): SyntheticJavaPropertyDescriptor? {
|
||||
val name = getterOrSetter.getName()
|
||||
if (name.isSpecial()) return null
|
||||
val identifier = name.getIdentifier()
|
||||
@@ -58,11 +55,16 @@ interface SyntheticJavaPropertyDescriptor : PropertyDescriptor {
|
||||
val owner = getterOrSetter.getContainingDeclaration() as? ClassDescriptor ?: return null
|
||||
|
||||
val originalGetterOrSetter = getterOrSetter.original
|
||||
return resolutionScope.collectSyntheticExtensionProperties(listOf(owner.defaultType))
|
||||
return syntheticScopes.collectSyntheticExtensionProperties(listOf(owner.defaultType))
|
||||
.filterIsInstance<SyntheticJavaPropertyDescriptor>()
|
||||
.firstOrNull { originalGetterOrSetter == it.getMethod || originalGetterOrSetter == it.setMethod }
|
||||
}
|
||||
|
||||
fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, syntheticScope: SyntheticScope)
|
||||
= findByGetterOrSetter(getterOrSetter, object : SyntheticScopes {
|
||||
override val scopes: Collection<SyntheticScope> = listOf(syntheticScope)
|
||||
})
|
||||
|
||||
fun propertyNameByGetMethodName(methodName: Name): Name?
|
||||
= org.jetbrains.kotlin.load.java.propertyNameByGetMethodName(methodName)
|
||||
|
||||
@@ -71,7 +73,7 @@ interface SyntheticJavaPropertyDescriptor : PropertyDescriptor {
|
||||
}
|
||||
}
|
||||
|
||||
class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val lookupTracker: LookupTracker) : BaseImportingScope(null) {
|
||||
class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val lookupTracker: LookupTracker) : BaseImportingScope(null), SyntheticScope {
|
||||
private val syntheticPropertyInClass = storageManager.createMemoizedFunction<Pair<ClassDescriptor, Name>, SyntheticPropertyHolder> { pair ->
|
||||
syntheticPropertyInClassNotCached(pair.first, pair.second)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.synthetic
|
||||
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
|
||||
public class JavaSyntheticScopes(storageManager: StorageManager, lookupTracker: LookupTracker): SyntheticScopes {
|
||||
|
||||
override val scopes = listOf(JavaSyntheticPropertiesScope(storageManager, lookupTracker), SamAdapterFunctionsScope(storageManager))
|
||||
}
|
||||
+2
-1
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf
|
||||
import org.jetbrains.kotlin.resolve.scopes.BaseImportingScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScope
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
@@ -38,7 +39,7 @@ interface SamAdapterExtensionFunctionDescriptor : FunctionDescriptor {
|
||||
val sourceFunction: FunctionDescriptor
|
||||
}
|
||||
|
||||
class SamAdapterFunctionsScope(storageManager: StorageManager) : BaseImportingScope(null) {
|
||||
class SamAdapterFunctionsScope(storageManager: StorageManager) : BaseImportingScope(null), SyntheticScope {
|
||||
private val extensionForFunction = storageManager.createMemoizedFunctionWithNullableValues<FunctionDescriptor, FunctionDescriptor> { function ->
|
||||
extensionForFunctionNotCached(function)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.frontend.di
|
||||
import org.jetbrains.kotlin.container.*
|
||||
import org.jetbrains.kotlin.context.LazyResolveToken
|
||||
import org.jetbrains.kotlin.context.ModuleContext
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
@@ -28,7 +27,10 @@ import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer
|
||||
import org.jetbrains.kotlin.resolve.lazy.NoTopLevelDescriptorProvider
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
||||
import org.jetbrains.kotlin.types.expressions.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.types.expressions.DeclarationScopeProviderForLocalClassifierAnalyzer
|
||||
import org.jetbrains.kotlin.types.expressions.LocalClassDescriptorHolder
|
||||
import org.jetbrains.kotlin.types.expressions.LocalLazyDeclarationResolver
|
||||
|
||||
public fun StorageComponentContainer.configureModule(
|
||||
moduleContext: ModuleContext, platform: TargetPlatform
|
||||
@@ -70,6 +72,7 @@ public fun createContainerForBodyResolve(
|
||||
|
||||
useInstance(statementFilter)
|
||||
|
||||
useInstance(LookupTracker.DO_NOTHING)
|
||||
useInstance(BodyResolveCache.ThrowException)
|
||||
|
||||
useImpl<BodyResolver>()
|
||||
@@ -82,6 +85,7 @@ public fun createContainerForLazyBodyResolve(
|
||||
): StorageComponentContainer = createContainer("LazyBodyResolve") {
|
||||
configureModule(moduleContext, platform, bindingTrace)
|
||||
|
||||
useInstance(LookupTracker.DO_NOTHING)
|
||||
useInstance(kotlinCodeAnalyzer)
|
||||
useInstance(kotlinCodeAnalyzer.getFileScopeProvider())
|
||||
useInstance(bodyResolveCache)
|
||||
@@ -92,11 +96,13 @@ public fun createContainerForLazyLocalClassifierAnalyzer(
|
||||
moduleContext: ModuleContext,
|
||||
bindingTrace: BindingTrace,
|
||||
platform: TargetPlatform,
|
||||
lookupTracker: LookupTracker,
|
||||
localClassDescriptorHolder: LocalClassDescriptorHolder
|
||||
): StorageComponentContainer = createContainer("LocalClassifierAnalyzer") {
|
||||
configureModule(moduleContext, platform, bindingTrace)
|
||||
|
||||
useInstance(localClassDescriptorHolder)
|
||||
useInstance(lookupTracker)
|
||||
|
||||
useImpl<LazyTopDownAnalyzer>()
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.descriptors.ModuleParameters
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.resolve.validation.DeprecatedSymbolValidator
|
||||
import org.jetbrains.kotlin.resolve.validation.InfixValidator
|
||||
import org.jetbrains.kotlin.resolve.validation.OperatorValidator
|
||||
@@ -47,8 +48,14 @@ abstract class TargetPlatform(
|
||||
override val builtIns: KotlinBuiltIns
|
||||
get() = DefaultBuiltIns.Instance
|
||||
override val defaultModuleParameters = ModuleParameters.Empty
|
||||
override val platformConfigurator = PlatformConfigurator(DynamicTypesSettings(), listOf(), listOf(), listOf(), listOf(), listOf(),
|
||||
IdentifierChecker.DEFAULT, OverloadFilter.DEFAULT)
|
||||
override val platformConfigurator =
|
||||
object : PlatformConfigurator(DynamicTypesSettings(), listOf(), listOf(), listOf(), listOf(), listOf(),
|
||||
IdentifierChecker.DEFAULT, OverloadFilter.DEFAULT) {
|
||||
override fun configure(container: StorageComponentContainer) {
|
||||
super.configure(container)
|
||||
container.useInstance(SyntheticScopes.Empty)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +74,7 @@ private val DEFAULT_TYPE_CHECKERS = emptyList<AdditionalTypeChecker>()
|
||||
private val DEFAULT_VALIDATORS = listOf(DeprecatedSymbolValidator(), OperatorValidator(), InfixValidator())
|
||||
|
||||
|
||||
open class PlatformConfigurator(
|
||||
abstract class PlatformConfigurator(
|
||||
private val dynamicTypesSettings: DynamicTypesSettings,
|
||||
additionalDeclarationCheckers: List<DeclarationChecker>,
|
||||
additionalCallCheckers: List<CallChecker>,
|
||||
|
||||
+8
-10
@@ -27,9 +27,7 @@ import org.jetbrains.kotlin.resolve.LibrarySourceHacks
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.createSynthesizedInvokes
|
||||
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasClassValueDescriptor
|
||||
import org.jetbrains.kotlin.resolve.scopes.HierarchicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalChainedScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.*
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
@@ -49,7 +47,7 @@ public interface CallableDescriptorCollector<D : CallableDescriptor> {
|
||||
|
||||
public fun getStaticMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<D>
|
||||
|
||||
public fun getExtensionsByName(scope: HierarchicalScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<D>
|
||||
public fun getExtensionsByName(scope: HierarchicalScope, syntheticScopes: SyntheticScopes, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<D>
|
||||
}
|
||||
|
||||
private fun <D : CallableDescriptor> CallableDescriptorCollector<D>.withDefaultFilter() = filtered { !LibrarySourceHacks.shouldSkip(it) }
|
||||
@@ -127,10 +125,10 @@ private object FunctionCollector : CallableDescriptorCollector<FunctionDescripto
|
||||
return getConstructors(receiver.memberScope.memberScopeAsImportingScope(), name, location, { isStaticNestedClass(it) })
|
||||
}
|
||||
|
||||
override fun getExtensionsByName(scope: HierarchicalScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
override fun getExtensionsByName(scope: HierarchicalScope, syntheticScopes: SyntheticScopes, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
val functions = scope.collectFunctions(name, location)
|
||||
val (extensions, nonExtensions) = functions.partition { it.extensionReceiverParameter != null }
|
||||
val syntheticExtensions = scope.collectSyntheticExtensionFunctions(receiverTypes, name, location)
|
||||
val syntheticExtensions = syntheticScopes.collectSyntheticExtensionFunctions(receiverTypes, name, location)
|
||||
|
||||
if (name == OperatorNameConventions.INVOKE) {
|
||||
// Create synthesized "invoke" extensions for each non-extension "invoke" found in the scope
|
||||
@@ -215,10 +213,10 @@ private object VariableCollector : CallableDescriptorCollector<VariableDescripto
|
||||
return listOf()
|
||||
}
|
||||
|
||||
override fun getExtensionsByName(scope: HierarchicalScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
override fun getExtensionsByName(scope: HierarchicalScope, syntheticScopes: SyntheticScopes, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
// property may have an extension function type, we check the applicability later to avoid an early computing of deferred types
|
||||
return scope.collectVariables(name, location) +
|
||||
scope.collectSyntheticExtensionProperties(receiverTypes, name, location)
|
||||
syntheticScopes.collectSyntheticExtensionProperties(receiverTypes, name, location)
|
||||
}
|
||||
|
||||
override fun toString() = "VARIABLES"
|
||||
@@ -247,8 +245,8 @@ private fun <D : CallableDescriptor> CallableDescriptorCollector<D>.filtered(fil
|
||||
return delegate.getStaticMembersByName(receiver, name, location).filter(filter)
|
||||
}
|
||||
|
||||
override fun getExtensionsByName(scope: HierarchicalScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<D> {
|
||||
return delegate.getExtensionsByName(scope, name, receiverTypes, location).filter(filter)
|
||||
override fun getExtensionsByName(scope: HierarchicalScope, syntheticScopes: SyntheticScopes, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<D> {
|
||||
return delegate.getExtensionsByName(scope, syntheticScopes, name, receiverTypes, location).filter(filter)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasLowPriorityInOverloadResolution
|
||||
import org.jetbrains.kotlin.resolve.scopes.ImportingScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.getImplicitReceiversHierarchy
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
|
||||
@@ -53,7 +54,8 @@ import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
public class TaskPrioritizer(
|
||||
private val storageManager: StorageManager,
|
||||
private val smartCastManager: SmartCastManager,
|
||||
private val dynamicCallableDescriptors: DynamicCallableDescriptors
|
||||
private val dynamicCallableDescriptors: DynamicCallableDescriptors,
|
||||
private val syntheticScopes: SyntheticScopes
|
||||
) {
|
||||
|
||||
public fun <D : CallableDescriptor, F : D> computePrioritizedTasks(
|
||||
@@ -201,7 +203,7 @@ public class TaskPrioritizer(
|
||||
//extensions
|
||||
c.result.addCandidates {
|
||||
val extensions = callableDescriptorCollector.getExtensionsByName(
|
||||
c.scope, c.name, explicitReceiver.types, createLookupLocation(c))
|
||||
c.scope, syntheticScopes, c.name, explicitReceiver.types, createLookupLocation(c))
|
||||
val filteredExtensions = if (filter == null) extensions else extensions.filter(filter)
|
||||
|
||||
convertWithImpliedThis(
|
||||
@@ -294,7 +296,7 @@ public class TaskPrioritizer(
|
||||
) {
|
||||
c.result.addCandidates {
|
||||
val memberExtensions =
|
||||
callableDescriptorCollector.getExtensionsByName(dispatchReceiver.type.memberScope.memberScopeAsImportingScope(), c.name, receiverParameter.types, createLookupLocation(c))
|
||||
callableDescriptorCollector.getExtensionsByName(dispatchReceiver.type.memberScope.memberScopeAsImportingScope(), syntheticScopes, c.name, receiverParameter.types, createLookupLocation(c))
|
||||
convertWithReceivers(memberExtensions, dispatchReceiver, receiverParameter.value, receiverKind, c.context.call)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.collectors.CallableDescriptorCol
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.scopes.HierarchicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScopeImpl
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
@@ -228,8 +228,8 @@ public fun DeclarationDescriptor.isDynamic(): Boolean {
|
||||
}
|
||||
|
||||
class CollectorForDynamicReceivers<D: CallableDescriptor>(val delegate: CallableDescriptorCollector<D>) : CallableDescriptorCollector<D> by delegate {
|
||||
override fun getExtensionsByName(scope: HierarchicalScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<D> {
|
||||
return delegate.getExtensionsByName(scope, name, receiverTypes, location).filter {
|
||||
override fun getExtensionsByName(scope: HierarchicalScope, syntheticScopes: SyntheticScopes, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<D> {
|
||||
return delegate.getExtensionsByName(scope, syntheticScopes, name, receiverTypes, location).filter {
|
||||
it.getExtensionReceiverParameter()?.getType()?.isDynamic() ?: false
|
||||
}
|
||||
}
|
||||
|
||||
+7
-5
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategyForInvoke
|
||||
import org.jetbrains.kotlin.resolve.isHiddenInResolution
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.*
|
||||
import org.jetbrains.kotlin.types.DeferredType
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
@@ -53,10 +54,11 @@ import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
|
||||
class NewResolveOldInference(
|
||||
val candidateResolver: CandidateResolver,
|
||||
val towerResolver: TowerResolver,
|
||||
val resolutionResultsHandler: ResolutionResultsHandler,
|
||||
val dynamicCallableDescriptors: DynamicCallableDescriptors
|
||||
private val candidateResolver: CandidateResolver,
|
||||
private val towerResolver: TowerResolver,
|
||||
private val resolutionResultsHandler: ResolutionResultsHandler,
|
||||
private val dynamicCallableDescriptors: DynamicCallableDescriptors,
|
||||
private val syntheticScopes: SyntheticScopes
|
||||
) {
|
||||
|
||||
fun runResolve(
|
||||
@@ -68,7 +70,7 @@ class NewResolveOldInference(
|
||||
val explicitReceiver = context.call.explicitReceiver
|
||||
|
||||
val dynamicScope = dynamicCallableDescriptors.createDynamicDescriptorScope(context.call, context.scope.ownerDescriptor)
|
||||
val scopeTower = ScopeTowerImpl(context, dynamicScope, context.call.createLookupLocation())
|
||||
val scopeTower = ScopeTowerImpl(context, dynamicScope, syntheticScopes, context.call.createLookupLocation())
|
||||
|
||||
val baseContext = Context(scopeTower, name, context, tracing)
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
@@ -36,6 +37,8 @@ interface ScopeTower {
|
||||
|
||||
val dynamicScope: MemberScope
|
||||
|
||||
val syntheticScopes: SyntheticScopes
|
||||
|
||||
val location: LookupLocation
|
||||
|
||||
val dataFlowInfo: DataFlowDecorator
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.scopes.ImportingScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.getImplicitReceiversHierarchy
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.parentsWithSelf
|
||||
@@ -42,6 +43,7 @@ internal class CandidateWithBoundDispatchReceiverImpl<D : CallableDescriptor>(
|
||||
internal class ScopeTowerImpl(
|
||||
resolutionContext: ResolutionContext<*>,
|
||||
override val dynamicScope: MemberScope,
|
||||
override val syntheticScopes: SyntheticScopes,
|
||||
override val location: LookupLocation
|
||||
): ScopeTower {
|
||||
override val dataFlowInfo: DataFlowDecorator = DataFlowDecoratorImpl(resolutionContext)
|
||||
@@ -71,6 +73,7 @@ internal class ScopeTowerImpl(
|
||||
result.add(ImportingScopeBasedTowerLevel(this, scope as ImportingScope))
|
||||
}
|
||||
}
|
||||
result.add(SyntheticScopeBasedTowerLevel(this, syntheticScopes))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -23,9 +23,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasClassValueDescriptor
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasLowPriorityInOverloadResolution
|
||||
import org.jetbrains.kotlin.resolve.scopes.ImportingScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.ResolutionScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.CastImplicitClassReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitClassReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.QualifierReceiver
|
||||
@@ -157,30 +155,32 @@ internal open class ScopeBasedTowerLevel protected constructor(
|
||||
createCandidateDescriptor(it, dispatchReceiver = null)
|
||||
}
|
||||
}
|
||||
|
||||
internal class ImportingScopeBasedTowerLevel(
|
||||
scopeTower: ScopeTower,
|
||||
private val importingScope: ImportingScope
|
||||
): ScopeBasedTowerLevel(scopeTower, importingScope) {
|
||||
): ScopeBasedTowerLevel(scopeTower, importingScope)
|
||||
|
||||
internal class SyntheticScopeBasedTowerLevel(
|
||||
scopeTower: ScopeTower,
|
||||
private val syntheticScopes: SyntheticScopes
|
||||
): AbstractScopeTowerLevel(scopeTower) {
|
||||
|
||||
override fun getVariables(name: Name, extensionReceiver: ReceiverValue?): Collection<CandidateWithBoundDispatchReceiver<VariableDescriptor>> {
|
||||
if (extensionReceiver == null) return super.getVariables(name, null)
|
||||
if (extensionReceiver == null) return emptyList()
|
||||
|
||||
val extensionReceiverTypes = scopeTower.dataFlowInfo.getAllPossibleTypes(extensionReceiver)
|
||||
val synthetic = importingScope.getContributedSyntheticExtensionProperties(extensionReceiverTypes, name, location).map {
|
||||
return syntheticScopes.collectSyntheticExtensionProperties(extensionReceiverTypes, name, location).map {
|
||||
createCandidateDescriptor(it, dispatchReceiver = null)
|
||||
}
|
||||
return super.getVariables(name, null) + synthetic
|
||||
}
|
||||
|
||||
override fun getFunctions(name: Name, extensionReceiver: ReceiverValue?): Collection<CandidateWithBoundDispatchReceiver<FunctionDescriptor>> {
|
||||
if (extensionReceiver == null) return super.getFunctions(name, null)
|
||||
if (extensionReceiver == null) return emptyList()
|
||||
|
||||
val extensionReceiverTypes = scopeTower.dataFlowInfo.getAllPossibleTypes(extensionReceiver)
|
||||
val synthetic = importingScope.getContributedSyntheticExtensionFunctions(extensionReceiverTypes, name, location).map {
|
||||
return syntheticScopes.collectSyntheticExtensionFunctions(extensionReceiverTypes, name, location).map {
|
||||
createCandidateDescriptor(it, dispatchReceiver = null)
|
||||
}
|
||||
return super.getFunctions(name, null) + synthetic
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ abstract class BaseLexicalScope(
|
||||
get() = null
|
||||
}
|
||||
|
||||
abstract class BaseImportingScope(parent: ImportingScope?) : BaseHierarchicalScope(parent), ImportingScope {
|
||||
abstract class BaseImportingScope(parent: ImportingScope?) : BaseHierarchicalScope(parent), ImportingScope, SyntheticScope {
|
||||
override val parent: ImportingScope?
|
||||
get() = super.parent as ImportingScope?
|
||||
|
||||
@@ -148,4 +148,17 @@ abstract class BaseImportingScope(parent: ImportingScope?) : BaseHierarchicalSco
|
||||
override fun getContributedSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor> = emptyList()
|
||||
|
||||
override fun getContributedSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor> = emptyList()
|
||||
|
||||
// temporary
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation)
|
||||
= getContributedSyntheticExtensionProperties(receiverTypes, name, location)
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation)
|
||||
= getContributedSyntheticExtensionFunctions(receiverTypes, name, location)
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>)
|
||||
= getContributedSyntheticExtensionProperties(receiverTypes)
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>)
|
||||
= getContributedSyntheticExtensionFunctions(receiverTypes)
|
||||
}
|
||||
|
||||
@@ -98,18 +98,6 @@ public fun HierarchicalScope.findFunction(name: Name, location: LookupLocation,
|
||||
return null
|
||||
}
|
||||
|
||||
public fun HierarchicalScope.collectSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation)
|
||||
= collectAllFromImportingScopes { it.getContributedSyntheticExtensionProperties(receiverTypes, name, location) }
|
||||
|
||||
public fun HierarchicalScope.collectSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation)
|
||||
= collectAllFromImportingScopes { it.getContributedSyntheticExtensionFunctions(receiverTypes, name, location) }
|
||||
|
||||
public fun HierarchicalScope.collectSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>)
|
||||
= collectAllFromImportingScopes { it.getContributedSyntheticExtensionProperties(receiverTypes) }
|
||||
|
||||
public fun HierarchicalScope.collectSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>)
|
||||
= collectAllFromImportingScopes { it.getContributedSyntheticExtensionFunctions(receiverTypes) }
|
||||
|
||||
public fun HierarchicalScope.takeSnapshot(): HierarchicalScope = if (this is LexicalWritableScope) takeSnapshot() else this
|
||||
|
||||
@JvmOverloads
|
||||
|
||||
+3
@@ -45,6 +45,7 @@ import org.jetbrains.kotlin.resolve.lazy.declarations.PsiBasedClassMemberDeclara
|
||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.DynamicTypesSettings
|
||||
|
||||
@@ -57,6 +58,7 @@ public class LocalClassifierAnalyzer(
|
||||
private val annotationResolver: AnnotationResolver,
|
||||
private val platform: TargetPlatform,
|
||||
private val dynamicTypesSettings: DynamicTypesSettings,
|
||||
private val lookupTracker: LookupTracker,
|
||||
private val supertypeLoopChecker: SupertypeLoopChecker
|
||||
) {
|
||||
fun processClassOrObject(
|
||||
@@ -71,6 +73,7 @@ public class LocalClassifierAnalyzer(
|
||||
moduleContext,
|
||||
context.trace,
|
||||
platform,
|
||||
lookupTracker,
|
||||
LocalClassDescriptorHolder(
|
||||
scope,
|
||||
classOrObject,
|
||||
|
||||
@@ -17,13 +17,11 @@
|
||||
package org.jetbrains.kotlin.tests.di
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.container.StorageComponentContainer
|
||||
import org.jetbrains.kotlin.container.createContainer
|
||||
import org.jetbrains.kotlin.container.getValue
|
||||
import org.jetbrains.kotlin.container.useImpl
|
||||
import org.jetbrains.kotlin.container.*
|
||||
import org.jetbrains.kotlin.context.ModuleContext
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.frontend.di.configureModule
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.resolve.DescriptorResolver
|
||||
import org.jetbrains.kotlin.resolve.FunctionDescriptorResolver
|
||||
import org.jetbrains.kotlin.resolve.TypeResolver
|
||||
@@ -34,6 +32,7 @@ import org.jetbrains.kotlin.types.expressions.FakeCallResolver
|
||||
public fun createContainerForTests(project: Project, module: ModuleDescriptor): ContainerForTests {
|
||||
return ContainerForTests(createContainer("Tests") {
|
||||
configureModule(ModuleContext(module, project), JvmPlatform)
|
||||
useInstance(LookupTracker.DO_NOTHING)
|
||||
useImpl<ExpressionTypingServices>()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.scopes
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
|
||||
interface SyntheticScope {
|
||||
fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
|
||||
fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor>
|
||||
fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor>
|
||||
}
|
||||
|
||||
interface SyntheticScopes {
|
||||
val scopes: Collection<SyntheticScope>
|
||||
|
||||
object Empty : SyntheticScopes {
|
||||
override val scopes: Collection<SyntheticScope> = emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun SyntheticScopes.collectSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation)
|
||||
= scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes, name, location) }
|
||||
|
||||
fun SyntheticScopes.collectSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation)
|
||||
= scopes.flatMap { it.getSyntheticExtensionFunctions(receiverTypes, name, location) }
|
||||
|
||||
fun SyntheticScopes.collectSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>)
|
||||
= scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes) }
|
||||
|
||||
fun SyntheticScopes.collectSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>)
|
||||
= scopes.flatMap { it.getSyntheticExtensionFunctions(receiverTypes) }
|
||||
+3
-5
@@ -31,10 +31,7 @@ import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastManager
|
||||
import org.jetbrains.kotlin.resolve.isHiddenInResolution
|
||||
import org.jetbrains.kotlin.resolve.scopes.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.collectDescriptorsFiltered
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.collectSyntheticExtensionFunctions
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.collectSyntheticExtensionProperties
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
@@ -341,14 +338,15 @@ class ReferenceVariantsHelper(
|
||||
process(descriptor as CallableDescriptor)
|
||||
}
|
||||
|
||||
val syntheticScopes = resolutionFacade.getFrontendService(SyntheticScopes::class.java)
|
||||
if (kindFilter.acceptsKinds(DescriptorKindFilter.VARIABLES_MASK)) {
|
||||
for (extension in scope.collectSyntheticExtensionProperties(receiverTypes)) {
|
||||
for (extension in syntheticScopes.collectSyntheticExtensionProperties(receiverTypes)) {
|
||||
process(extension)
|
||||
}
|
||||
}
|
||||
|
||||
if (kindFilter.acceptsKinds(DescriptorKindFilter.FUNCTIONS_MASK)) {
|
||||
for (extension in scope.collectSyntheticExtensionFunctions(receiverTypes)) {
|
||||
for (extension in syntheticScopes.collectSyntheticExtensionFunctions(receiverTypes)) {
|
||||
process(extension)
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -40,7 +40,6 @@ import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
|
||||
import org.jetbrains.kotlin.idea.stubindex.KotlinSourceFilterScope
|
||||
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
|
||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||
import org.jetbrains.kotlin.idea.util.getFileResolutionScope
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -49,15 +48,15 @@ import org.jetbrains.kotlin.renderer.render
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.isReallySuccess
|
||||
import org.jetbrains.kotlin.resolve.isHiddenInResolution
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.collectSyntheticExtensionProperties
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.resolve.scopes.collectSyntheticExtensionProperties
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
|
||||
public class ConflictingExtensionPropertyInspection : AbstractKotlinInspection(), CleanupLocalInspectionTool {
|
||||
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor {
|
||||
val file = session.file as? KtFile ?: return PsiElementVisitor.EMPTY_VISITOR
|
||||
val fileScope = file.getResolutionFacade().getFileResolutionScope(file)
|
||||
val resolutionFacade = file.getResolutionFacade()
|
||||
|
||||
return object : KtVisitorVoid() {
|
||||
override fun visitProperty(property: KtProperty) {
|
||||
@@ -67,7 +66,8 @@ public class ConflictingExtensionPropertyInspection : AbstractKotlinInspection()
|
||||
val nameElement = property.nameIdentifier ?: return
|
||||
val propertyDescriptor = property.resolveToDescriptor() as? PropertyDescriptor ?: return
|
||||
|
||||
val conflictingExtension = conflictingSyntheticExtension(propertyDescriptor, fileScope) ?: return
|
||||
val syntheticScopes = resolutionFacade.getFrontendService(SyntheticScopes::class.java)
|
||||
val conflictingExtension = conflictingSyntheticExtension(propertyDescriptor, syntheticScopes) ?: return
|
||||
|
||||
// don't report on hidden declarations
|
||||
if (propertyDescriptor.isHiddenInResolution()) return
|
||||
@@ -87,9 +87,9 @@ public class ConflictingExtensionPropertyInspection : AbstractKotlinInspection()
|
||||
}
|
||||
}
|
||||
|
||||
private fun conflictingSyntheticExtension(descriptor: PropertyDescriptor, scope: LexicalScope): SyntheticJavaPropertyDescriptor? {
|
||||
private fun conflictingSyntheticExtension(descriptor: PropertyDescriptor, scopes: SyntheticScopes): SyntheticJavaPropertyDescriptor? {
|
||||
val extensionReceiverType = descriptor.extensionReceiverParameter?.type ?: return null
|
||||
return scope.collectSyntheticExtensionProperties(listOf(extensionReceiverType), descriptor.name, NoLookupLocation.FROM_IDE)
|
||||
return scopes.collectSyntheticExtensionProperties(listOf(extensionReceiverType), descriptor.name, NoLookupLocation.FROM_IDE)
|
||||
.firstIsInstanceOrNull<SyntheticJavaPropertyDescriptor>()
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,8 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.isReallySuccess
|
||||
import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.collectAllFromImportingScopes
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.resolve.scopes.collectSyntheticExtensionFunctions
|
||||
import org.jetbrains.kotlin.synthetic.SamAdapterExtensionFunctionDescriptor
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||
@@ -183,13 +184,11 @@ public class RedundantSamConstructorInspection : AbstractKotlinInspection() {
|
||||
}
|
||||
|
||||
// SAM adapters for member functions
|
||||
val resolutionScope = functionCall.getResolutionScope(bindingContext, functionCall.getResolutionFacade())
|
||||
val syntheticExtensions = resolutionScope.collectAllFromImportingScopes {
|
||||
it.getContributedSyntheticExtensionFunctions(
|
||||
val syntheticScopes = functionCall.getResolutionFacade().getFrontendService(SyntheticScopes::class.java)
|
||||
val syntheticExtensions = syntheticScopes.collectSyntheticExtensionFunctions(
|
||||
containingClass.defaultType.singletonList(),
|
||||
functionResolvedCall.resultingDescriptor.name,
|
||||
NoLookupLocation.FROM_IDE)
|
||||
}
|
||||
for (syntheticExtension in syntheticExtensions) {
|
||||
val samAdapter = syntheticExtension as? SamAdapterExtensionFunctionDescriptor ?: continue
|
||||
if (isSamAdapterSuitableForCall(samAdapter, originalFunctionDescriptor, samConstructorCallArguments.size())) {
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
@@ -85,7 +86,7 @@ class UsePropertyAccessSyntaxIntention : SelfTargetingOffsetIndependentIntention
|
||||
|
||||
val function = resolvedCall.resultingDescriptor as? FunctionDescriptor ?: return null
|
||||
val resolutionScope = callExpression.getResolutionScope(bindingContext, resolutionFacade)
|
||||
val property = findSyntheticProperty(function, resolutionScope) ?: return null
|
||||
val property = findSyntheticProperty(function, resolutionFacade.getFrontendService(SyntheticScopes::class.java)) ?: return null
|
||||
|
||||
val dataFlowInfo = bindingContext.getDataFlowInfo(callee)
|
||||
val qualifiedExpression = callExpression.getQualifiedExpressionForSelectorOrThis()
|
||||
@@ -141,11 +142,11 @@ class UsePropertyAccessSyntaxIntention : SelfTargetingOffsetIndependentIntention
|
||||
return result.isSuccess && result.resultingDescriptor.original == property
|
||||
}
|
||||
|
||||
private fun findSyntheticProperty(function: FunctionDescriptor, resolutionScope: LexicalScope): SyntheticJavaPropertyDescriptor? {
|
||||
SyntheticJavaPropertyDescriptor.findByGetterOrSetter(function, resolutionScope)?.let { return it }
|
||||
private fun findSyntheticProperty(function: FunctionDescriptor, syntheticScopes: SyntheticScopes): SyntheticJavaPropertyDescriptor? {
|
||||
SyntheticJavaPropertyDescriptor.findByGetterOrSetter(function, syntheticScopes)?.let { return it }
|
||||
|
||||
for (overridden in function.overriddenDescriptors) {
|
||||
findSyntheticProperty(overridden, resolutionScope)?.let { return it }
|
||||
findSyntheticProperty(overridden, syntheticScopes)?.let { return it }
|
||||
}
|
||||
|
||||
return null
|
||||
|
||||
@@ -18,10 +18,12 @@ package org.jetbrains.kotlin.js.resolve
|
||||
|
||||
import org.jetbrains.kotlin.container.StorageComponentContainer
|
||||
import org.jetbrains.kotlin.container.useImpl
|
||||
import org.jetbrains.kotlin.container.useInstance
|
||||
import org.jetbrains.kotlin.js.resolve.diagnostics.JsCallChecker
|
||||
import org.jetbrains.kotlin.resolve.IdentifierChecker
|
||||
import org.jetbrains.kotlin.resolve.OverloadFilter
|
||||
import org.jetbrains.kotlin.resolve.PlatformConfigurator
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.types.DynamicTypesAllowed
|
||||
|
||||
public object JsPlatformConfigurator : PlatformConfigurator(
|
||||
@@ -38,5 +40,6 @@ public object JsPlatformConfigurator : PlatformConfigurator(
|
||||
super.configure(container)
|
||||
|
||||
container.useImpl<JsCallChecker>()
|
||||
container.useInstance(SyntheticScopes.Empty)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user