From e692b7b9c4167d1f3da14ad9e413f8b511c6a27a Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Mon, 17 Aug 2015 19:17:14 +0300 Subject: [PATCH] Minor: no more use default value for location parameter in JetScope members Temporary introduced overloads which emulated default value behavior --- .../tasks/CallableDescriptorCollectors.kt | 7 ++++-- .../kotlin/resolve/scopes/JetScope.kt | 18 +++++++++++---- .../jetbrains/kotlin/types/ErrorUtils.java | 23 +++++++++++++++++-- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt index 2a722dea7cf..b1fb056d06a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.tasks.collectors import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.BindingTrace import org.jetbrains.kotlin.resolve.DescriptorUtils.isStaticNestedClass @@ -101,7 +102,7 @@ private object FunctionCollector : CallableDescriptorCollector, bindingTrace: BindingTrace): Collection { val functions = scope.getFunctions(name) val (extensions, nonExtensions) = functions.partition { it.extensionReceiverParameter != null } - val syntheticExtensions = scope.getSyntheticExtensionFunctions(receiverTypes, name) + val syntheticExtensions = scope.getSyntheticExtensionFunctions(receiverTypes, name, LookupLocation.NO_LOCATION) if (name == OperatorConventions.INVOKE) { // Create synthesized "invoke" extensions for each non-extension "invoke" found in the scope @@ -158,7 +159,9 @@ private object VariableCollector : CallableDescriptorCollector, bindingTrace: BindingTrace): Collection { // property may have an extension function type, we check the applicability later to avoid an early computing of deferred types - return scope.getLocalVariable(name).singletonOrEmptyList() + scope.getProperties(name) + scope.getSyntheticExtensionProperties(receiverTypes, name) + return scope.getLocalVariable(name).singletonOrEmptyList() + + scope.getProperties(name) + + scope.getSyntheticExtensionProperties(receiverTypes, name, LookupLocation.NO_LOCATION) } override fun toString() = "VARIABLES" diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt index 1b891ca1d1a..f446de1871b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt @@ -26,18 +26,18 @@ import java.lang.reflect.Modifier public interface JetScope { - public fun getClassifier(name: Name, location: LookupLocation = LookupLocation.NO_LOCATION): ClassifierDescriptor? + public fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? public fun getPackage(name: Name): PackageViewDescriptor? - public fun getProperties(name: Name, location: LookupLocation = LookupLocation.NO_LOCATION): Collection + public fun getProperties(name: Name, location: LookupLocation): Collection public fun getLocalVariable(name: Name): VariableDescriptor? - public fun getFunctions(name: Name, location: LookupLocation = LookupLocation.NO_LOCATION): Collection + public fun getFunctions(name: Name, location: LookupLocation): Collection - public fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation = LookupLocation.NO_LOCATION): Collection - public fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation = LookupLocation.NO_LOCATION): Collection + public fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection + public fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection public fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection public fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection @@ -46,6 +46,14 @@ public interface JetScope { public fun getDeclarationsByLabel(labelName: Name): Collection + // Temporary overloads which will be dropped when all usages will be processed + @deprecated("Provide `location` explicitly", replaceWith = ReplaceWith("getClassifier(name, LookupLocation.NO_LOCATION)")) + public final fun getClassifier(name: Name): ClassifierDescriptor? = getClassifier(name, LookupLocation.NO_LOCATION) + @deprecated("Provide `location` explicitly", replaceWith = ReplaceWith("getClassifier(name, LookupLocation.NO_LOCATION)")) + public final fun getProperties(name: Name): Collection = getProperties(name, LookupLocation.NO_LOCATION) + @deprecated("Provide `location` explicitly", replaceWith = ReplaceWith("getClassifier(name, LookupLocation.NO_LOCATION)")) + public final fun getFunctions(name: Name): Collection = getFunctions(name, LookupLocation.NO_LOCATION) + /** * All visible descriptors from current scope. * diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java index c65103deefe..d59fec0f0df 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java @@ -73,8 +73,27 @@ public class ErrorUtils { return false; } + private static abstract class AbstractErrorScope implements JetScope { + @Nullable + @Override + public ClassifierDescriptor getClassifier(@NotNull Name name) { + return getClassifier(name, LookupLocation.NO_LOCATION); + } - public static class ErrorScope implements JetScope { + @NotNull + @Override + public Collection getProperties(@NotNull Name name) { + return getProperties(name, LookupLocation.NO_LOCATION); + } + + @NotNull + @Override + public Collection getFunctions(@NotNull Name name) { + return getFunctions(name, LookupLocation.NO_LOCATION); + } + } + + public static class ErrorScope extends AbstractErrorScope { private final String debugMessage; private ErrorScope(@NotNull String debugMessage) { @@ -190,7 +209,7 @@ public class ErrorUtils { } } - private static class ThrowingScope implements JetScope { + private static class ThrowingScope extends AbstractErrorScope { private final String debugMessage; private ThrowingScope(@NotNull String message) {