Protected / final are deprecated in interfaces: scopes and call translator
This commit is contained in:
committed by
Mikhail Glukhikh
parent
49a420e3f9
commit
67755d7dca
+8
-8
@@ -153,17 +153,17 @@ fun computeExplicitReceiversForInvoke(
|
||||
}
|
||||
}
|
||||
|
||||
interface CallCase<I : CallInfo> {
|
||||
abstract class CallCase<I : CallInfo> {
|
||||
|
||||
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<I : CallInfo> {
|
||||
}
|
||||
}
|
||||
|
||||
interface FunctionCallCase : CallCase<FunctionCallInfo>
|
||||
abstract class FunctionCallCase : CallCase<FunctionCallInfo>()
|
||||
|
||||
interface VariableAccessCase : CallCase<VariableAccessInfo>
|
||||
abstract class VariableAccessCase : CallCase<VariableAccessInfo>()
|
||||
|
||||
interface DelegateIntrinsic<I : CallInfo> {
|
||||
fun I.canBeApply(): Boolean = true
|
||||
|
||||
+7
-7
@@ -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<FunctionCallInfo> {
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
+3
-3
@@ -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<VariableAccessInfo> {
|
||||
}
|
||||
}
|
||||
|
||||
object SuperPropertyAccessCase : VariableAccessCase {
|
||||
object SuperPropertyAccessCase : VariableAccessCase() {
|
||||
override fun VariableAccessInfo.dispatchReceiver(): JsExpression {
|
||||
val variableName = context.program().getStringLiteral(this.variableName.getIdent())
|
||||
return if (isGetAccess())
|
||||
|
||||
Reference in New Issue
Block a user