diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolveOldInference.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolveOldInference.kt index a769c4d5c1b..7a8514c88bf 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolveOldInference.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolveOldInference.kt @@ -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.results.OverloadResolutionResultsImpl 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.isHiddenInResolution import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes @@ -339,4 +340,17 @@ 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) } \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerImpl.kt index 86b9db7a72a..1a3af3711a2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerImpl.kt @@ -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"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.resolve.calls.tower -import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue @@ -32,12 +31,6 @@ import org.jetbrains.kotlin.utils.addToStdlib.check import java.util.* -internal class CandidateWithBoundDispatchReceiverImpl( - override val dispatchReceiver: ReceiverValue?, - override val descriptor: D, - override val diagnostics: List -) : CandidateWithBoundDispatchReceiver - internal class ScopeTowerImpl( resolutionContext: ResolutionContext<*>, override val dynamicScope: MemberScope, @@ -50,7 +43,7 @@ internal class ScopeTowerImpl( override val implicitReceivers = resolutionContext.scope.getImplicitReceiversHierarchy(). mapNotNull { it.value.check { !it.type.containsError() } } - val isDebuggerContext = resolutionContext.isDebuggerContext + override val isDebuggerContext = resolutionContext.isDebuggerContext } private class DataFlowDecoratorImpl(private val resolutionContext: ResolutionContext<*>): DataFlowDecorator { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerUtils.kt deleted file mode 100644 index 5f2227c83e4..00000000000 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerUtils.kt +++ /dev/null @@ -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 \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LocalRedeclarationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LocalRedeclarationChecker.kt index a801eb2c94c..c448cb0e7a7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LocalRedeclarationChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LocalRedeclarationChecker.kt @@ -24,13 +24,6 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.DescriptorUtils 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 { override fun checkBeforeAddingToScope(scope: LexicalScope, newDescriptor: DeclarationDescriptor) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/Qualifier.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/Qualifier.kt index bdfea8fb444..151341aaf29 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/Qualifier.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/Qualifier.kt @@ -16,7 +16,10 @@ 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.KtSimpleNameExpression 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 java.util.* -interface QualifierReceiver : Receiver { - val descriptor: DeclarationDescriptor - - val staticScope: MemberScope - - val classValueReceiver: ReceiverValue? -} - interface Qualifier : QualifierReceiver { val referenceExpression: KtSimpleNameExpression } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValue.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValue.kt similarity index 99% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValue.kt rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValue.kt index e4b5059a3cc..7b5f6a7c538 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValue.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValue.kt @@ -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"); * you may not use this file except in compliance with the License. diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/Nullability.java b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/smartcasts/Nullability.java similarity index 98% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/Nullability.java rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/smartcasts/Nullability.java index d168b32d80b..f493c25c8b4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/Nullability.java +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/smartcasts/Nullability.java @@ -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"); * you may not use this file except in compliance with the License. diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ExplicitReceiverKind.java b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tasks/ExplicitReceiverKind.java similarity index 96% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ExplicitReceiverKind.java rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tasks/ExplicitReceiverKind.java index fd91add576e..f0bf6aa0d9d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ExplicitReceiverKind.java +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tasks/ExplicitReceiverKind.java @@ -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"); * you may not use this file except in compliance with the License. diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/synthesizedInvokes.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tasks/synthesizedInvokes.kt similarity index 99% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/synthesizedInvokes.kt rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tasks/synthesizedInvokes.kt index 93ff021ac35..a89ee3c759d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/synthesizedInvokes.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tasks/synthesizedInvokes.kt @@ -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"); * you may not use this file except in compliance with the License. diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/InvokeProcessors.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/InvokeProcessors.kt similarity index 96% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/InvokeProcessors.kt rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/InvokeProcessors.kt index 957172ce2db..08aeffef970 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/InvokeProcessors.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/InvokeProcessors.kt @@ -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"); * 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.* -internal abstract class AbstractInvokeTowerProcessor( +abstract class AbstractInvokeTowerProcessor( protected val functionContext: TowerContext, private val variableProcessor: ScopeTowerProcessor ) : ScopeTowerProcessor { @@ -85,7 +85,7 @@ internal abstract class AbstractInvokeTowerProcessor( } // todo KT-9522 Allow invoke convention for synthetic property -internal class InvokeTowerProcessor( +class InvokeTowerProcessor( functionContext: TowerContext, private val explicitReceiver: Receiver? ) : AbstractInvokeTowerProcessor( @@ -101,7 +101,7 @@ internal class InvokeTowerProcessor( } } -internal class InvokeExtensionTowerProcessor( +class InvokeExtensionTowerProcessor( functionContext: TowerContext, private val explicitReceiver: ReceiverValue? ) : AbstractInvokeTowerProcessor( @@ -151,7 +151,7 @@ private fun ScopeTower.getExtensionInvokeCandidateDescriptor( } // case 1.(foo())() or (foo())() -internal fun createCallTowerProcessorForExplicitInvoke( +fun createCallTowerProcessorForExplicitInvoke( contextForInvoke: TowerContext, expressionForInvoke: ReceiverValue, explicitReceiver: ReceiverValue? diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTower.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTower.kt similarity index 98% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTower.kt rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTower.kt index e7fc218c276..4d8f99aed38 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTower.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTower.kt @@ -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"); * you may not use this file except in compliance with the License. @@ -42,6 +42,8 @@ interface ScopeTower { val location: LookupLocation val dataFlowInfo: DataFlowDecorator + + val isDebuggerContext: Boolean } interface DataFlowDecorator { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerProcessors.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerProcessors.kt similarity index 95% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerProcessors.kt rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerProcessors.kt index 61528c59154..73850780904 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerProcessors.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerProcessors.kt @@ -24,14 +24,14 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.utils.addToStdlib.check -internal class KnownResultProcessor( +class KnownResultProcessor( val result: Collection ): ScopeTowerProcessor { override fun process(data: TowerData) = if (data == TowerData.Empty) listOfNotNull(result.check { it.isNotEmpty() }) else emptyList() } -internal class CompositeScopeTowerProcessor( +class CompositeScopeTowerProcessor( vararg val processors: ScopeTowerProcessor ) : ScopeTowerProcessor { override fun process(data: TowerData): List> = processors.flatMap { it.process(data) } @@ -133,8 +133,8 @@ private fun createSimpleProcessor( } } -internal fun createVariableProcessor(context: TowerContext, explicitReceiver: Receiver?) +fun createVariableProcessor(context: TowerContext, explicitReceiver: Receiver?) = createSimpleProcessor(context, explicitReceiver, ScopeTowerLevel::getVariables) -internal fun createFunctionProcessor(context: TowerContext, explicitReceiver: Receiver?) +fun createFunctionProcessor(context: TowerContext, explicitReceiver: Receiver?) = createSimpleProcessor(context, explicitReceiver, ScopeTowerLevel::getFunctions) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt similarity index 99% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt index 87307beb699..195601bcb3e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt @@ -62,7 +62,7 @@ internal abstract class AbstractScopeTowerLevel( if (descriptor.isSynthesized) diagnostics.add(SynthesizedDescriptorDiagnostic) if (dispatchReceiverSmartCastType != null) diagnostics.add(UsedSmartCastForDispatchReceiver(dispatchReceiverSmartCastType)) - val shouldSkipVisibilityCheck = scopeTower is ScopeTowerImpl && scopeTower.isDebuggerContext + val shouldSkipVisibilityCheck = scopeTower.isDebuggerContext if (!shouldSkipVisibilityCheck) { Visibilities.findInvisibleMember( dispatchReceiver, descriptor, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerResolver.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerResolver.kt similarity index 93% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerResolver.kt rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerResolver.kt index e38c0e1d7e9..bf6238a058e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerResolver.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerResolver.kt @@ -47,27 +47,27 @@ interface TowerContext { fun contextForInvoke(variable: C, useExplicitReceiver: Boolean): Pair>? } -internal sealed class TowerData { +sealed class TowerData { object Empty : TowerData() class OnlyImplicitReceiver(val implicitReceiver: ReceiverValue): TowerData() class TowerLevel(val level: ScopeTowerLevel) : TowerData() class BothTowerLevelAndImplicitReceiver(val level: ScopeTowerLevel, val implicitReceiver: ReceiverValue) : TowerData() } -internal interface ScopeTowerProcessor { +interface ScopeTowerProcessor { // Candidates with matched receivers (dispatch receiver was already matched in ScopeTowerLevel) // Candidates in one groups have same priority, first group has highest priority. fun process(data: TowerData): List> } class TowerResolver { - internal fun runResolve( + fun runResolve( context: TowerContext, processor: ScopeTowerProcessor, useOrder: Boolean ): Collection = run(context.scopeTower.createTowerDataList(), processor, SuccessfulResultCollector { context.getStatus(it) }, useOrder) - internal fun collectAllCandidates(context: TowerContext, processor: ScopeTowerProcessor): Collection + fun collectAllCandidates(context: TowerContext, processor: ScopeTowerProcessor): Collection = run(context.scopeTower.createTowerDataList(), processor, AllCandidatesCollector { context.getStatus(it) }, false) private fun ScopeTower.createNonLocalLevels(): List { @@ -153,7 +153,7 @@ class TowerResolver { return result } - internal fun run( + fun run( towerDataList: List, processor: ScopeTowerProcessor, resultCollector: ResultCollector, @@ -180,7 +180,7 @@ class TowerResolver { } - internal abstract class ResultCollector(protected val getStatus: (C) -> ResolutionCandidateStatus) { + abstract class ResultCollector(protected val getStatus: (C) -> ResolutionCandidateStatus) { abstract fun getSuccessfulCandidates(): Collection? abstract fun getFinalCandidates(): Collection @@ -195,7 +195,7 @@ class TowerResolver { protected abstract fun addCandidates(candidates: Collection) } - internal class AllCandidatesCollector(getStatus: (C) -> ResolutionCandidateStatus): ResultCollector(getStatus) { + class AllCandidatesCollector(getStatus: (C) -> ResolutionCandidateStatus): ResultCollector(getStatus) { private val allCandidates = ArrayList() override fun getSuccessfulCandidates(): Collection? = null @@ -207,7 +207,7 @@ class TowerResolver { } } - internal class SuccessfulResultCollector(getStatus: (C) -> ResolutionCandidateStatus): ResultCollector(getStatus) { + class SuccessfulResultCollector(getStatus: (C) -> ResolutionCandidateStatus): ResultCollector(getStatus) { private var currentCandidates: Collection = emptyList() private var currentLevel: ResolutionCandidateApplicability? = null diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerUtils.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerUtils.kt new file mode 100644 index 00000000000..9fd1ede5a87 --- /dev/null +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerUtils.kt @@ -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( + override val dispatchReceiver: ReceiverValue?, + override val descriptor: D, + override val diagnostics: List +) : CandidateWithBoundDispatchReceiver diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/FakeCallableDescriptorForObject.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/util/FakeCallableDescriptorForObject.kt similarity index 97% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/FakeCallableDescriptorForObject.kt rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/util/FakeCallableDescriptorForObject.kt index 5f5d6cf35d4..321fa39b6b2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/FakeCallableDescriptorForObject.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/util/FakeCallableDescriptorForObject.kt @@ -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"); * 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.hasClassValueDescriptor import org.jetbrains.kotlin.types.KotlinType -import java.util.Collections +import java.util.* class FakeCallableDescriptorForObject( val classDescriptor: ClassDescriptor diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt similarity index 98% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt index a4bf627550e..61a432d8923 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt @@ -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"); * you may not use this file except in compliance with the License. diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalChainedScope.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalChainedScope.kt similarity index 98% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalChainedScope.kt rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalChainedScope.kt index e3ff9ffd7a1..d0b851a8631 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalChainedScope.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalChainedScope.kt @@ -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"); * you may not use this file except in compliance with the License. diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeImpl.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeImpl.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeImpl.kt rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeImpl.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeStorage.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeStorage.kt similarity index 94% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeStorage.kt rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeStorage.kt index baf207c6af7..855bec411b1 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeStorage.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeStorage.kt @@ -26,6 +26,14 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.scopes.utils.takeSnapshot 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( parent: HierarchicalScope, val redeclarationChecker: LocalRedeclarationChecker diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalWritableScope.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalWritableScope.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalWritableScope.kt rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalWritableScope.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/ScopeUtils.java b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/ScopeUtils.java similarity index 98% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/ScopeUtils.java rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/ScopeUtils.java index 596af1d35a1..ea880f7fce5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/ScopeUtils.java +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/ScopeUtils.java @@ -20,7 +20,6 @@ import kotlin.Unit; import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.TestOnly; import org.jetbrains.kotlin.descriptors.ClassDescriptor; import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; import org.jetbrains.kotlin.descriptors.PropertyDescriptor; @@ -78,7 +77,7 @@ public final class ScopeUtils { ); } - @TestOnly + // TestOnly @NotNull public static String printStructure(@Nullable MemberScope scope) { StringBuilder out = new StringBuilder(); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt similarity index 99% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt index b8922249f5d..fa2a474174d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt @@ -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"); * you may not use this file except in compliance with the License. diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/SubpackagesImportingScope.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/SubpackagesImportingScope.kt similarity index 97% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/SubpackagesImportingScope.kt rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/SubpackagesImportingScope.kt index 08dcde7f6ae..7ed65c2ce61 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/SubpackagesImportingScope.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/SubpackagesImportingScope.kt @@ -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"); * you may not use this file except in compliance with the License. diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/receivers/QualifierReceiver.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/receivers/QualifierReceiver.kt new file mode 100644 index 00000000000..61d89e51d95 --- /dev/null +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/receivers/QualifierReceiver.kt @@ -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? +} \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt similarity index 99% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt rename to compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt index 255995a7028..2b10835b60e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt @@ -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"); * 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.name.Name import org.jetbrains.kotlin.resolve.scopes.* -import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.util.collectionUtils.concat import org.jetbrains.kotlin.utils.Printer