diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/WritableScopeStorage.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/WritableScopeStorage.kt index 225206bf565..de4fa7b0d1b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/WritableScopeStorage.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/WritableScopeStorage.kt @@ -34,7 +34,8 @@ public interface WritableScopeStorage { var functionsByName: MutableMap? // = null var variablesAndClassifiersByName: MutableMap? // = null - protected fun addVariableOrClassDescriptor(descriptor: DeclarationDescriptor) { + // Effectively protected: not to be used outside subclasses + fun addVariableOrClassDescriptor(descriptor: DeclarationDescriptor) { val name = descriptor.getName() val originalDescriptor = variableOrClassDescriptorByName(name) @@ -52,7 +53,8 @@ public interface WritableScopeStorage { } - protected fun addFunctionDescriptor(functionDescriptor: FunctionDescriptor) { + // Effectively protected: not to be used outside subclasses + fun addFunctionDescriptor(functionDescriptor: FunctionDescriptor) { val descriptorIndex = addDescriptor(functionDescriptor) if (functionsByName == null) { @@ -63,7 +65,8 @@ public interface WritableScopeStorage { functionsByName!![name] = functionsByName!![name] + descriptorIndex } - protected fun variableOrClassDescriptorByName(name: Name, descriptorLimit: Int = addedDescriptors.size()): DeclarationDescriptor? { + // Effectively protected: not to be used outside subclasses + fun variableOrClassDescriptorByName(name: Name, descriptorLimit: Int = addedDescriptors.size()): DeclarationDescriptor? { if (descriptorLimit == 0) return null var list = variablesAndClassifiersByName?.get(name) @@ -77,7 +80,8 @@ public interface WritableScopeStorage { return null } - protected fun functionsByName(name: Name, descriptorLimit: Int = addedDescriptors.size()): List? { + // Effectively protected: not to be used outside subclasses + fun functionsByName(name: Name, descriptorLimit: Int = addedDescriptors.size()): List? { if (descriptorLimit == 0) return null var list = functionsByName?.get(name) @@ -95,7 +99,8 @@ public interface WritableScopeStorage { return addedDescriptors.size() - 1 } - protected class IntList(val last: Int, val prev: IntList?) + // Effectively protected: not to be used outside subclasses + class IntList(val last: Int, val prev: IntList?) private fun Int.descriptorByIndex() = addedDescriptors[this] 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 92a30b0922f..82d19b45566 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt @@ -49,14 +49,14 @@ public interface JetScope { // Temporary overloads which will be dropped when all usages will be processed @Deprecated("Provide `location` explicitly", replaceWith = ReplaceWith("getClassifier(name, NoLookupLocation.UNSORTED)")) - public final fun getClassifier(name: Name): ClassifierDescriptor? = getClassifier(name, NoLookupLocation.UNSORTED) + public fun getClassifier(name: Name): ClassifierDescriptor? = getClassifier(name, NoLookupLocation.UNSORTED) /** * All visible descriptors from current scope. * * @return All visible descriptors from current scope. */ - public final fun getAllDescriptors(): Collection = getDescriptors() + public fun getAllDescriptors(): Collection = getDescriptors() /** * All visible descriptors from current scope possibly filtered by the given name and kind filters diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/declarationSearchUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/declarationSearchUtil.kt index 89ca829738d..fe428d3c8fe 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/declarationSearchUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/declarationSearchUtil.kt @@ -66,8 +66,8 @@ public class HierarchySearchRequest ( } interface HierarchyTraverser { - protected fun nextElements(current: T): Iterable - protected fun shouldDescend(element: T): Boolean + fun nextElements(current: T): Iterable + fun shouldDescend(element: T): Boolean fun forEach(initialElement: T, body: (T) -> Unit) { val stack = Stack() diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallTranslator.kt index cabeba496c5..e532f7e1e72 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallTranslator.kt @@ -153,17 +153,17 @@ fun computeExplicitReceiversForInvoke( } } -interface CallCase { +abstract class CallCase { - protected fun I.unsupported(message: String = "") : Nothing = throw IllegalStateException("this case unsupported. $this") + protected open fun I.unsupported(message: String = "") : Nothing = throw IllegalStateException("this case unsupported. $this") - protected fun I.noReceivers(): JsExpression = unsupported() + protected open fun I.noReceivers(): JsExpression = unsupported() - protected fun I.dispatchReceiver(): JsExpression = unsupported() + protected open fun I.dispatchReceiver(): JsExpression = unsupported() - protected fun I.extensionReceiver(): JsExpression = unsupported() + protected open fun I.extensionReceiver(): JsExpression = unsupported() - protected fun I.bothReceivers(): JsExpression = unsupported() + protected open fun I.bothReceivers(): JsExpression = unsupported() final fun translate(callInfo: I): JsExpression { val result = if (callInfo.dispatchReceiver == null) { @@ -182,9 +182,9 @@ interface CallCase { } } -interface FunctionCallCase : CallCase +abstract class FunctionCallCase : CallCase() -interface VariableAccessCase : CallCase +abstract class VariableAccessCase : CallCase() interface DelegateIntrinsic { fun I.canBeApply(): Boolean = true diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/FunctionCallCases.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/FunctionCallCases.kt index 0261621774c..f75fd86f52f 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/FunctionCallCases.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/FunctionCallCases.kt @@ -44,7 +44,7 @@ public fun CallArgumentTranslator.ArgumentsInfo.argsWithReceiver(receiver: JsExp } // call may be native and|or with spreadOperator -object DefaultFunctionCallCase : FunctionCallCase { +object DefaultFunctionCallCase : FunctionCallCase() { // TODO: refactor after fix ArgumentsInfo - duplicate code private fun nativeSpreadFunWithDispatchOrExtensionReceiver(argumentsInfo: CallArgumentTranslator.ArgumentsInfo, functionName: JsName): JsExpression { val cachedReceiver = argumentsInfo.cachedReceiver!! @@ -134,7 +134,7 @@ object DelegateFunctionIntrinsic : DelegateIntrinsic { } } -abstract class AnnotatedAsNativeXCallCase(val annotation: PredefinedAnnotation) : FunctionCallCase { +abstract class AnnotatedAsNativeXCallCase(val annotation: PredefinedAnnotation) : FunctionCallCase() { abstract fun translateCall(receiver: JsExpression, argumentsInfo: CallArgumentTranslator.ArgumentsInfo): JsExpression fun canApply(callInfo: FunctionCallInfo): Boolean = AnnotationsUtils.hasAnnotation(callInfo.callableDescriptor, annotation) @@ -160,7 +160,7 @@ object NativeSetterCallCase : AnnotatedAsNativeXCallCase(PredefinedAnnotation.NA } } -object InvokeIntrinsic : FunctionCallCase { +object InvokeIntrinsic : FunctionCallCase() { fun canApply(callInfo: FunctionCallInfo): Boolean { val callableDescriptor = callInfo.callableDescriptor if (callableDescriptor.getName() != OperatorConventions.INVOKE) @@ -198,7 +198,7 @@ object InvokeIntrinsic : FunctionCallCase { } } -object ConstructorCallCase : FunctionCallCase { +object ConstructorCallCase : FunctionCallCase() { fun canApply(callInfo: FunctionCallInfo): Boolean { return callInfo.callableDescriptor is ConstructorDescriptor } @@ -218,7 +218,7 @@ object ConstructorCallCase : FunctionCallCase { } } -object SuperCallCase : FunctionCallCase { +object SuperCallCase : FunctionCallCase() { fun canApply(callInfo: FunctionCallInfo): Boolean { return callInfo.isSuperInvocation() } @@ -231,7 +231,7 @@ object SuperCallCase : FunctionCallCase { } } -object DynamicInvokeAndBracketAccessCallCase : FunctionCallCase { +object DynamicInvokeAndBracketAccessCallCase : FunctionCallCase() { fun canApply(callInfo: FunctionCallInfo): Boolean = callInfo.resolvedCall.getCall().getCallType() != Call.CallType.DEFAULT && callInfo.callableDescriptor.isDynamic() @@ -252,7 +252,7 @@ object DynamicInvokeAndBracketAccessCallCase : FunctionCallCase { } } -object DynamicOperatorCallCase : FunctionCallCase { +object DynamicOperatorCallCase : FunctionCallCase() { fun canApply(callInfo: FunctionCallInfo): Boolean = callInfo.callableDescriptor.isDynamic() && callInfo.resolvedCall.getCall().getCallElement() let { diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/VarialbeCallCases.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/VarialbeCallCases.kt index 9d135df51cc..aa6f96a03a2 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/VarialbeCallCases.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/VarialbeCallCases.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.resolve.BindingContextUtils.isVarCapturedInClosure import org.jetbrains.kotlin.js.translate.context.Namer.getCapturedVarAccessor -object NativeVariableAccessCase : VariableAccessCase { +object NativeVariableAccessCase : VariableAccessCase() { override fun VariableAccessInfo.extensionReceiver(): JsExpression { return constructAccessExpression(JsNameRef(variableName, extensionReceiver!!)) } @@ -41,7 +41,7 @@ object NativeVariableAccessCase : VariableAccessCase { } } -object DefaultVariableAccessCase : VariableAccessCase { +object DefaultVariableAccessCase : VariableAccessCase() { override fun VariableAccessInfo.noReceivers(): JsExpression { val functionRef = context.aliasOrValue(callableDescriptor) { context.getQualifiedReference(variableDescriptor) @@ -107,7 +107,7 @@ object DelegatePropertyAccessIntrinsic : DelegateIntrinsic { } } -object SuperPropertyAccessCase : VariableAccessCase { +object SuperPropertyAccessCase : VariableAccessCase() { override fun VariableAccessInfo.dispatchReceiver(): JsExpression { val variableName = context.program().getStringLiteral(this.variableName.getIdent()) return if (isGetAccess())