Move sources to resolution module
This commit is contained in:
+14
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCallImpl
|
|||||||
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCallImpl
|
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCallImpl
|
||||||
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsImpl
|
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsImpl
|
||||||
import org.jetbrains.kotlin.resolve.calls.results.ResolutionResultsHandler
|
import org.jetbrains.kotlin.resolve.calls.results.ResolutionResultsHandler
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.*
|
import org.jetbrains.kotlin.resolve.calls.tasks.*
|
||||||
import org.jetbrains.kotlin.resolve.isHiddenInResolution
|
import org.jetbrains.kotlin.resolve.isHiddenInResolution
|
||||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||||
@@ -340,3 +341,16 @@ class NewResolveOldInference(
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated("Temporary error")
|
||||||
|
internal class PreviousResolutionError(candidateLevel: ResolutionCandidateApplicability): ResolutionDiagnostic(candidateLevel)
|
||||||
|
|
||||||
|
@Deprecated("Temporary error")
|
||||||
|
internal fun createPreviousResolveError(status: ResolutionStatus): PreviousResolutionError? {
|
||||||
|
val level = when (status) {
|
||||||
|
ResolutionStatus.SUCCESS, ResolutionStatus.INCOMPLETE_TYPE_INFERENCE -> return null
|
||||||
|
ResolutionStatus.UNSAFE_CALL_ERROR -> ResolutionCandidateApplicability.MAY_THROW_RUNTIME_ERROR
|
||||||
|
else -> ResolutionCandidateApplicability.INAPPLICABLE
|
||||||
|
}
|
||||||
|
return PreviousResolutionError(level)
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.resolve.calls.tower
|
package org.jetbrains.kotlin.resolve.calls.tower
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue
|
||||||
@@ -32,12 +31,6 @@ import org.jetbrains.kotlin.utils.addToStdlib.check
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
internal class CandidateWithBoundDispatchReceiverImpl<D : CallableDescriptor>(
|
|
||||||
override val dispatchReceiver: ReceiverValue?,
|
|
||||||
override val descriptor: D,
|
|
||||||
override val diagnostics: List<ResolutionDiagnostic>
|
|
||||||
) : CandidateWithBoundDispatchReceiver<D>
|
|
||||||
|
|
||||||
internal class ScopeTowerImpl(
|
internal class ScopeTowerImpl(
|
||||||
resolutionContext: ResolutionContext<*>,
|
resolutionContext: ResolutionContext<*>,
|
||||||
override val dynamicScope: MemberScope,
|
override val dynamicScope: MemberScope,
|
||||||
@@ -50,7 +43,7 @@ internal class ScopeTowerImpl(
|
|||||||
override val implicitReceivers = resolutionContext.scope.getImplicitReceiversHierarchy().
|
override val implicitReceivers = resolutionContext.scope.getImplicitReceiversHierarchy().
|
||||||
mapNotNull { it.value.check { !it.type.containsError() } }
|
mapNotNull { it.value.check { !it.type.containsError() } }
|
||||||
|
|
||||||
val isDebuggerContext = resolutionContext.isDebuggerContext
|
override val isDebuggerContext = resolutionContext.isDebuggerContext
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DataFlowDecoratorImpl(private val resolutionContext: ResolutionContext<*>): DataFlowDecorator {
|
private class DataFlowDecoratorImpl(private val resolutionContext: ResolutionContext<*>): DataFlowDecorator {
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.calls.tower
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isOrOverridesSynthesized
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
|
||||||
|
|
||||||
@Deprecated("Temporary error")
|
|
||||||
internal class PreviousResolutionError(candidateLevel: ResolutionCandidateApplicability): ResolutionDiagnostic(candidateLevel)
|
|
||||||
|
|
||||||
@Deprecated("Temporary error")
|
|
||||||
internal fun createPreviousResolveError(status: ResolutionStatus): PreviousResolutionError? {
|
|
||||||
val level = when (status) {
|
|
||||||
ResolutionStatus.SUCCESS, ResolutionStatus.INCOMPLETE_TYPE_INFERENCE -> return null
|
|
||||||
ResolutionStatus.UNSAFE_CALL_ERROR -> ResolutionCandidateApplicability.MAY_THROW_RUNTIME_ERROR
|
|
||||||
else -> ResolutionCandidateApplicability.INAPPLICABLE
|
|
||||||
}
|
|
||||||
return PreviousResolutionError(level)
|
|
||||||
}
|
|
||||||
|
|
||||||
internal val ResolutionCandidateApplicability.isSuccess: Boolean
|
|
||||||
get() = this <= ResolutionCandidateApplicability.RESOLVED_LOW_PRIORITY
|
|
||||||
|
|
||||||
internal val CallableDescriptor.isSynthesized: Boolean
|
|
||||||
get() = (this is CallableMemberDescriptor && kind == CallableMemberDescriptor.Kind.SYNTHESIZED)
|
|
||||||
|
|
||||||
internal val CandidateWithBoundDispatchReceiver<*>.requiresExtensionReceiver: Boolean
|
|
||||||
get() = descriptor.extensionReceiverParameter != null
|
|
||||||
|
|
||||||
internal fun DataFlowDecorator.getAllPossibleTypes(receiver: ReceiverValue) = getSmartCastTypes(receiver) + receiver.type
|
|
||||||
@@ -24,13 +24,6 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.OverloadUtil
|
import org.jetbrains.kotlin.resolve.OverloadUtil
|
||||||
|
|
||||||
interface LocalRedeclarationChecker {
|
|
||||||
fun checkBeforeAddingToScope(scope: LexicalScope, newDescriptor: DeclarationDescriptor)
|
|
||||||
|
|
||||||
object DO_NOTHING : LocalRedeclarationChecker {
|
|
||||||
override fun checkBeforeAddingToScope(scope: LexicalScope, newDescriptor: DeclarationDescriptor) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class AbstractLocalRedeclarationChecker : LocalRedeclarationChecker {
|
abstract class AbstractLocalRedeclarationChecker : LocalRedeclarationChecker {
|
||||||
override fun checkBeforeAddingToScope(scope: LexicalScope, newDescriptor: DeclarationDescriptor) {
|
override fun checkBeforeAddingToScope(scope: LexicalScope, newDescriptor: DeclarationDescriptor) {
|
||||||
|
|||||||
@@ -16,7 +16,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.resolve.scopes.receivers
|
package org.jetbrains.kotlin.resolve.scopes.receivers
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
|
import org.jetbrains.kotlin.descriptors.PackageViewDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.psi.KtExpression
|
import org.jetbrains.kotlin.psi.KtExpression
|
||||||
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getTopmostParentQualifiedExpressionForSelector
|
import org.jetbrains.kotlin.psi.psiUtil.getTopmostParentQualifiedExpressionForSelector
|
||||||
@@ -26,14 +29,6 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
|||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
interface QualifierReceiver : Receiver {
|
|
||||||
val descriptor: DeclarationDescriptor
|
|
||||||
|
|
||||||
val staticScope: MemberScope
|
|
||||||
|
|
||||||
val classValueReceiver: ReceiverValue?
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Qualifier : QualifierReceiver {
|
interface Qualifier : QualifierReceiver {
|
||||||
val referenceExpression: KtSimpleNameExpression
|
val referenceExpression: KtSimpleNameExpression
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
+5
-5
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.util.OperatorNameConventions
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
internal abstract class AbstractInvokeTowerProcessor<C>(
|
abstract class AbstractInvokeTowerProcessor<C>(
|
||||||
protected val functionContext: TowerContext<C>,
|
protected val functionContext: TowerContext<C>,
|
||||||
private val variableProcessor: ScopeTowerProcessor<C>
|
private val variableProcessor: ScopeTowerProcessor<C>
|
||||||
) : ScopeTowerProcessor<C> {
|
) : ScopeTowerProcessor<C> {
|
||||||
@@ -85,7 +85,7 @@ internal abstract class AbstractInvokeTowerProcessor<C>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// todo KT-9522 Allow invoke convention for synthetic property
|
// todo KT-9522 Allow invoke convention for synthetic property
|
||||||
internal class InvokeTowerProcessor<C>(
|
class InvokeTowerProcessor<C>(
|
||||||
functionContext: TowerContext<C>,
|
functionContext: TowerContext<C>,
|
||||||
private val explicitReceiver: Receiver?
|
private val explicitReceiver: Receiver?
|
||||||
) : AbstractInvokeTowerProcessor<C>(
|
) : AbstractInvokeTowerProcessor<C>(
|
||||||
@@ -101,7 +101,7 @@ internal class InvokeTowerProcessor<C>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class InvokeExtensionTowerProcessor<C>(
|
class InvokeExtensionTowerProcessor<C>(
|
||||||
functionContext: TowerContext<C>,
|
functionContext: TowerContext<C>,
|
||||||
private val explicitReceiver: ReceiverValue?
|
private val explicitReceiver: ReceiverValue?
|
||||||
) : AbstractInvokeTowerProcessor<C>(
|
) : AbstractInvokeTowerProcessor<C>(
|
||||||
@@ -151,7 +151,7 @@ private fun ScopeTower.getExtensionInvokeCandidateDescriptor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// case 1.(foo())() or (foo())()
|
// case 1.(foo())() or (foo())()
|
||||||
internal fun <C> createCallTowerProcessorForExplicitInvoke(
|
fun <C> createCallTowerProcessorForExplicitInvoke(
|
||||||
contextForInvoke: TowerContext<C>,
|
contextForInvoke: TowerContext<C>,
|
||||||
expressionForInvoke: ReceiverValue,
|
expressionForInvoke: ReceiverValue,
|
||||||
explicitReceiver: ReceiverValue?
|
explicitReceiver: ReceiverValue?
|
||||||
+3
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -42,6 +42,8 @@ interface ScopeTower {
|
|||||||
val location: LookupLocation
|
val location: LookupLocation
|
||||||
|
|
||||||
val dataFlowInfo: DataFlowDecorator
|
val dataFlowInfo: DataFlowDecorator
|
||||||
|
|
||||||
|
val isDebuggerContext: Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DataFlowDecorator {
|
interface DataFlowDecorator {
|
||||||
+4
-4
@@ -24,14 +24,14 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
|||||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||||
|
|
||||||
|
|
||||||
internal class KnownResultProcessor<C>(
|
class KnownResultProcessor<C>(
|
||||||
val result: Collection<C>
|
val result: Collection<C>
|
||||||
): ScopeTowerProcessor<C> {
|
): ScopeTowerProcessor<C> {
|
||||||
override fun process(data: TowerData)
|
override fun process(data: TowerData)
|
||||||
= if (data == TowerData.Empty) listOfNotNull(result.check { it.isNotEmpty() }) else emptyList()
|
= if (data == TowerData.Empty) listOfNotNull(result.check { it.isNotEmpty() }) else emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class CompositeScopeTowerProcessor<C>(
|
class CompositeScopeTowerProcessor<C>(
|
||||||
vararg val processors: ScopeTowerProcessor<C>
|
vararg val processors: ScopeTowerProcessor<C>
|
||||||
) : ScopeTowerProcessor<C> {
|
) : ScopeTowerProcessor<C> {
|
||||||
override fun process(data: TowerData): List<Collection<C>> = processors.flatMap { it.process(data) }
|
override fun process(data: TowerData): List<Collection<C>> = processors.flatMap { it.process(data) }
|
||||||
@@ -133,8 +133,8 @@ private fun <C> createSimpleProcessor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun <C> createVariableProcessor(context: TowerContext<C>, explicitReceiver: Receiver?)
|
fun <C> createVariableProcessor(context: TowerContext<C>, explicitReceiver: Receiver?)
|
||||||
= createSimpleProcessor(context, explicitReceiver, ScopeTowerLevel::getVariables)
|
= createSimpleProcessor(context, explicitReceiver, ScopeTowerLevel::getVariables)
|
||||||
|
|
||||||
internal fun <C> createFunctionProcessor(context: TowerContext<C>, explicitReceiver: Receiver?)
|
fun <C> createFunctionProcessor(context: TowerContext<C>, explicitReceiver: Receiver?)
|
||||||
= createSimpleProcessor(context, explicitReceiver, ScopeTowerLevel::getFunctions)
|
= createSimpleProcessor(context, explicitReceiver, ScopeTowerLevel::getFunctions)
|
||||||
+1
-1
@@ -62,7 +62,7 @@ internal abstract class AbstractScopeTowerLevel(
|
|||||||
if (descriptor.isSynthesized) diagnostics.add(SynthesizedDescriptorDiagnostic)
|
if (descriptor.isSynthesized) diagnostics.add(SynthesizedDescriptorDiagnostic)
|
||||||
if (dispatchReceiverSmartCastType != null) diagnostics.add(UsedSmartCastForDispatchReceiver(dispatchReceiverSmartCastType))
|
if (dispatchReceiverSmartCastType != null) diagnostics.add(UsedSmartCastForDispatchReceiver(dispatchReceiverSmartCastType))
|
||||||
|
|
||||||
val shouldSkipVisibilityCheck = scopeTower is ScopeTowerImpl && scopeTower.isDebuggerContext
|
val shouldSkipVisibilityCheck = scopeTower.isDebuggerContext
|
||||||
if (!shouldSkipVisibilityCheck) {
|
if (!shouldSkipVisibilityCheck) {
|
||||||
Visibilities.findInvisibleMember(
|
Visibilities.findInvisibleMember(
|
||||||
dispatchReceiver, descriptor,
|
dispatchReceiver, descriptor,
|
||||||
+8
-8
@@ -47,27 +47,27 @@ interface TowerContext<C> {
|
|||||||
fun contextForInvoke(variable: C, useExplicitReceiver: Boolean): Pair<ReceiverValue, TowerContext<C>>?
|
fun contextForInvoke(variable: C, useExplicitReceiver: Boolean): Pair<ReceiverValue, TowerContext<C>>?
|
||||||
}
|
}
|
||||||
|
|
||||||
internal sealed class TowerData {
|
sealed class TowerData {
|
||||||
object Empty : TowerData()
|
object Empty : TowerData()
|
||||||
class OnlyImplicitReceiver(val implicitReceiver: ReceiverValue): TowerData()
|
class OnlyImplicitReceiver(val implicitReceiver: ReceiverValue): TowerData()
|
||||||
class TowerLevel(val level: ScopeTowerLevel) : TowerData()
|
class TowerLevel(val level: ScopeTowerLevel) : TowerData()
|
||||||
class BothTowerLevelAndImplicitReceiver(val level: ScopeTowerLevel, val implicitReceiver: ReceiverValue) : TowerData()
|
class BothTowerLevelAndImplicitReceiver(val level: ScopeTowerLevel, val implicitReceiver: ReceiverValue) : TowerData()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal interface ScopeTowerProcessor<C> {
|
interface ScopeTowerProcessor<C> {
|
||||||
// Candidates with matched receivers (dispatch receiver was already matched in ScopeTowerLevel)
|
// Candidates with matched receivers (dispatch receiver was already matched in ScopeTowerLevel)
|
||||||
// Candidates in one groups have same priority, first group has highest priority.
|
// Candidates in one groups have same priority, first group has highest priority.
|
||||||
fun process(data: TowerData): List<Collection<C>>
|
fun process(data: TowerData): List<Collection<C>>
|
||||||
}
|
}
|
||||||
|
|
||||||
class TowerResolver {
|
class TowerResolver {
|
||||||
internal fun <C> runResolve(
|
fun <C> runResolve(
|
||||||
context: TowerContext<C>,
|
context: TowerContext<C>,
|
||||||
processor: ScopeTowerProcessor<C>,
|
processor: ScopeTowerProcessor<C>,
|
||||||
useOrder: Boolean
|
useOrder: Boolean
|
||||||
): Collection<C> = run(context.scopeTower.createTowerDataList(), processor, SuccessfulResultCollector { context.getStatus(it) }, useOrder)
|
): Collection<C> = run(context.scopeTower.createTowerDataList(), processor, SuccessfulResultCollector { context.getStatus(it) }, useOrder)
|
||||||
|
|
||||||
internal fun <C> collectAllCandidates(context: TowerContext<C>, processor: ScopeTowerProcessor<C>): Collection<C>
|
fun <C> collectAllCandidates(context: TowerContext<C>, processor: ScopeTowerProcessor<C>): Collection<C>
|
||||||
= run(context.scopeTower.createTowerDataList(), processor, AllCandidatesCollector { context.getStatus(it) }, false)
|
= run(context.scopeTower.createTowerDataList(), processor, AllCandidatesCollector { context.getStatus(it) }, false)
|
||||||
|
|
||||||
private fun ScopeTower.createNonLocalLevels(): List<ScopeTowerLevel> {
|
private fun ScopeTower.createNonLocalLevels(): List<ScopeTowerLevel> {
|
||||||
@@ -153,7 +153,7 @@ class TowerResolver {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun <C> run(
|
fun <C> run(
|
||||||
towerDataList: List<TowerData>,
|
towerDataList: List<TowerData>,
|
||||||
processor: ScopeTowerProcessor<C>,
|
processor: ScopeTowerProcessor<C>,
|
||||||
resultCollector: ResultCollector<C>,
|
resultCollector: ResultCollector<C>,
|
||||||
@@ -180,7 +180,7 @@ class TowerResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal abstract class ResultCollector<C>(protected val getStatus: (C) -> ResolutionCandidateStatus) {
|
abstract class ResultCollector<C>(protected val getStatus: (C) -> ResolutionCandidateStatus) {
|
||||||
abstract fun getSuccessfulCandidates(): Collection<C>?
|
abstract fun getSuccessfulCandidates(): Collection<C>?
|
||||||
|
|
||||||
abstract fun getFinalCandidates(): Collection<C>
|
abstract fun getFinalCandidates(): Collection<C>
|
||||||
@@ -195,7 +195,7 @@ class TowerResolver {
|
|||||||
protected abstract fun addCandidates(candidates: Collection<C>)
|
protected abstract fun addCandidates(candidates: Collection<C>)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class AllCandidatesCollector<C>(getStatus: (C) -> ResolutionCandidateStatus): ResultCollector<C>(getStatus) {
|
class AllCandidatesCollector<C>(getStatus: (C) -> ResolutionCandidateStatus): ResultCollector<C>(getStatus) {
|
||||||
private val allCandidates = ArrayList<C>()
|
private val allCandidates = ArrayList<C>()
|
||||||
|
|
||||||
override fun getSuccessfulCandidates(): Collection<C>? = null
|
override fun getSuccessfulCandidates(): Collection<C>? = null
|
||||||
@@ -207,7 +207,7 @@ class TowerResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class SuccessfulResultCollector<C>(getStatus: (C) -> ResolutionCandidateStatus): ResultCollector<C>(getStatus) {
|
class SuccessfulResultCollector<C>(getStatus: (C) -> ResolutionCandidateStatus): ResultCollector<C>(getStatus) {
|
||||||
private var currentCandidates: Collection<C> = emptyList()
|
private var currentCandidates: Collection<C> = emptyList()
|
||||||
private var currentLevel: ResolutionCandidateApplicability? = null
|
private var currentLevel: ResolutionCandidateApplicability? = null
|
||||||
|
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2016 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.calls.tower
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||||
|
|
||||||
|
val ResolutionCandidateApplicability.isSuccess: Boolean
|
||||||
|
get() = this <= ResolutionCandidateApplicability.RESOLVED_LOW_PRIORITY
|
||||||
|
|
||||||
|
val CallableDescriptor.isSynthesized: Boolean
|
||||||
|
get() = (this is CallableMemberDescriptor && kind == CallableMemberDescriptor.Kind.SYNTHESIZED)
|
||||||
|
|
||||||
|
val CandidateWithBoundDispatchReceiver<*>.requiresExtensionReceiver: Boolean
|
||||||
|
get() = descriptor.extensionReceiverParameter != null
|
||||||
|
|
||||||
|
fun DataFlowDecorator.getAllPossibleTypes(receiver: ReceiverValue) = getSmartCastTypes(receiver) + receiver.type
|
||||||
|
|
||||||
|
internal class CandidateWithBoundDispatchReceiverImpl<D : CallableDescriptor>(
|
||||||
|
override val dispatchReceiver: ReceiverValue?,
|
||||||
|
override val descriptor: D,
|
||||||
|
override val diagnostics: List<ResolutionDiagnostic>
|
||||||
|
) : CandidateWithBoundDispatchReceiver<D>
|
||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.classValueType
|
|||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getClassObjectReferenceTarget
|
import org.jetbrains.kotlin.resolve.descriptorUtil.getClassObjectReferenceTarget
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasClassValueDescriptor
|
import org.jetbrains.kotlin.resolve.descriptorUtil.hasClassValueDescriptor
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import java.util.Collections
|
import java.util.*
|
||||||
|
|
||||||
class FakeCallableDescriptorForObject(
|
class FakeCallableDescriptorForObject(
|
||||||
val classDescriptor: ClassDescriptor
|
val classDescriptor: ClassDescriptor
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
+8
@@ -26,6 +26,14 @@ import org.jetbrains.kotlin.name.Name
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.utils.takeSnapshot
|
import org.jetbrains.kotlin.resolve.scopes.utils.takeSnapshot
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
interface LocalRedeclarationChecker {
|
||||||
|
fun checkBeforeAddingToScope(scope: LexicalScope, newDescriptor: DeclarationDescriptor)
|
||||||
|
|
||||||
|
object DO_NOTHING : LocalRedeclarationChecker {
|
||||||
|
override fun checkBeforeAddingToScope(scope: LexicalScope, newDescriptor: DeclarationDescriptor) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
abstract class LexicalScopeStorage(
|
abstract class LexicalScopeStorage(
|
||||||
parent: HierarchicalScope,
|
parent: HierarchicalScope,
|
||||||
val redeclarationChecker: LocalRedeclarationChecker
|
val redeclarationChecker: LocalRedeclarationChecker
|
||||||
+1
-2
@@ -20,7 +20,6 @@ import kotlin.Unit;
|
|||||||
import kotlin.jvm.functions.Function1;
|
import kotlin.jvm.functions.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.TestOnly;
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
||||||
@@ -78,7 +77,7 @@ public final class ScopeUtils {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestOnly
|
// TestOnly
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String printStructure(@Nullable MemberScope scope) {
|
public static String printStructure(@Nullable MemberScope scope) {
|
||||||
StringBuilder out = new StringBuilder();
|
StringBuilder out = new StringBuilder();
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2016 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.receivers
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
|
|
||||||
|
interface QualifierReceiver : Receiver {
|
||||||
|
val descriptor: DeclarationDescriptor
|
||||||
|
|
||||||
|
val staticScope: MemberScope
|
||||||
|
|
||||||
|
val classValueReceiver: ReceiverValue?
|
||||||
|
}
|
||||||
+1
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation
|
|||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.scopes.*
|
import org.jetbrains.kotlin.resolve.scopes.*
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
|
||||||
import org.jetbrains.kotlin.util.collectionUtils.concat
|
import org.jetbrains.kotlin.util.collectionUtils.concat
|
||||||
import org.jetbrains.kotlin.utils.Printer
|
import org.jetbrains.kotlin.utils.Printer
|
||||||
|
|
||||||
Reference in New Issue
Block a user