diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 336d05ac1dd..a0c05bd1045 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -94,6 +94,7 @@ import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import org.jetbrains.kotlin.types.expressions.DoubleColonLHS; import org.jetbrains.kotlin.types.typesApproximation.CapturedTypeApproximationKt; +import org.jetbrains.kotlin.util.OperatorNameConventions; import org.jetbrains.org.objectweb.asm.Label; import org.jetbrains.org.objectweb.asm.MethodVisitor; import org.jetbrains.org.objectweb.asm.Opcodes; @@ -4152,7 +4153,7 @@ public class ExpressionCodegen extends KtVisitor impleme ResolvedCall resolvedSetCall = bindingContext.get(INDEXED_LVALUE_SET, expression); ResolvedCall resolvedGetCall = bindingContext.get(INDEXED_LVALUE_GET, expression); - boolean isGetter = "get".equals(operationDescriptor.getName().asString()); + boolean isGetter = OperatorNameConventions.GET.equals(operationDescriptor.getName()); Callable callable = resolveToCallable(operationDescriptor, false, isGetter ? resolvedGetCall : resolvedSetCall); Callable callableMethod = resolveToCallableMethod(operationDescriptor, false); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt index fc73c7bc6b8..d56e34db891 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt @@ -57,6 +57,7 @@ import org.jetbrains.kotlin.resolve.calls.util.isSingleUnderscore import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils.* import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils +import org.jetbrains.kotlin.util.OperatorNameConventions import java.util.* class ControlFlowInformationProvider private constructor( @@ -647,13 +648,13 @@ class ControlFlowInformationProvider private constructor( val functionDescriptor = trace.get(DECLARATION_TO_DESCRIPTOR, owner) as? FunctionDescriptor ?: throw AssertionError(owner.text) - val functionName = functionDescriptor.name.asString() + val functionName = functionDescriptor.name if (isMain || functionDescriptor.isOverridableOrOverrides || owner.hasModifier(KtTokens.OVERRIDE_KEYWORD) - || "getValue" == functionName - || "setValue" == functionName - || "propertyDelegated" == functionName) { + || OperatorNameConventions.GET_VALUE == functionName + || OperatorNameConventions.SET_VALUE == functionName + || OperatorNameConventions.PROPERTY_DELEGATED == functionName) { return } report(UNUSED_PARAMETER.on(element, variableDescriptor), ctxt) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java index bab6fffad62..5bef9ee775b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java @@ -257,7 +257,7 @@ public class CallResolver { Call.CallType callType = context.call.getCallType(); if (callType == Call.CallType.ARRAY_GET_METHOD || callType == Call.CallType.ARRAY_SET_METHOD) { - Name name = Name.identifier(callType == Call.CallType.ARRAY_GET_METHOD ? "get" : "set"); + Name name = callType == Call.CallType.ARRAY_GET_METHOD ? OperatorNameConventions.GET : OperatorNameConventions.SET; KtArrayAccessExpression arrayAccessExpression = (KtArrayAccessExpression) context.call.getCallElement(); return computeTasksAndResolveCall( context, name, arrayAccessExpression, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index f71fd916075..4759d7f08d4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -1691,7 +1691,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { ? CallMaker.makeArrayGetCall(receiver, arrayAccessExpression, Call.CallType.ARRAY_GET_METHOD) : CallMaker.makeArraySetCall(receiver, arrayAccessExpression, rightHandSide, Call.CallType.ARRAY_SET_METHOD); OverloadResolutionResults functionResults = components.callResolver.resolveCallWithGivenName( - context, call, arrayAccessExpression, Name.identifier(isGet ? "get" : "set")); + context, call, arrayAccessExpression, isGet ? OperatorNameConventions.GET : OperatorNameConventions.SET); List indices = arrayAccessExpression.getIndexExpressions(); // The accumulated data flow info of all index expressions is saved on the last index diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRecursiveCallLineMarkerProvider.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRecursiveCallLineMarkerProvider.kt index 2a255a7fa44..5d22ef8625f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRecursiveCallLineMarkerProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRecursiveCallLineMarkerProvider.kt @@ -33,13 +33,12 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.parents import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension import org.jetbrains.kotlin.resolve.inline.InlineUtil import org.jetbrains.kotlin.resolve.scopes.receivers.Receiver import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.types.expressions.OperatorConventions import org.jetbrains.kotlin.util.OperatorNameConventions -import java.util.HashSet +import java.util.* class KotlinRecursiveCallLineMarkerProvider() : LineMarkerProvider { override fun getLineMarkerInfo(element: PsiElement) = null @@ -159,7 +158,7 @@ private fun getCallNameFromPsi(element: KtElement): Name? { } } is KtArrayAccessExpression -> - return Name.identifier("get") + return OperatorNameConventions.GET is KtThisExpression -> if (element.getParent() is KtCallExpression) { return OperatorNameConventions.INVOKE @@ -167,4 +166,4 @@ private fun getCallNameFromPsi(element: KtElement): Name? { } return null -} \ No newline at end of file +} diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateGetFunctionActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateGetFunctionActionFactory.kt index 93d0f9ee239..e3d66dd7d1b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateGetFunctionActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateGetFunctionActionFactory.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.Parame import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.TypeInfo import org.jetbrains.kotlin.psi.KtArrayAccessExpression import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.util.OperatorNameConventions import java.util.* object CreateGetFunctionActionFactory : CreateGetSetFunctionActionFactory(isGet = true) { @@ -32,6 +33,8 @@ object CreateGetFunctionActionFactory : CreateGetSetFunctionActionFactory(isGet val arrayType = TypeInfo(arrayExpr, Variance.IN_VARIANCE) val parameters = element.indexExpressions.map { ParameterInfo(TypeInfo(it, Variance.IN_VARIANCE)) } val returnType = TypeInfo(element, Variance.OUT_VARIANCE) - return FunctionInfo("get", arrayType, returnType, Collections.emptyList(), parameters, isOperator = true) + return FunctionInfo( + OperatorNameConventions.GET.asString(), arrayType, returnType, Collections.emptyList(), parameters, isOperator = true + ) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreatePropertyDelegateAccessorsActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreatePropertyDelegateAccessorsActionFactory.kt index 12cdf1ec5c1..170cc9fe43c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreatePropertyDelegateAccessorsActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreatePropertyDelegateAccessorsActionFactory.kt @@ -33,6 +33,7 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.resolve.descriptorUtil.module import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.util.OperatorNameConventions object CreatePropertyDelegateAccessorsActionFactory : CreateCallableMemberFromUsageFactory() { override fun getElementOfInterest(diagnostic: Diagnostic): KtExpression? { @@ -62,7 +63,7 @@ object CreatePropertyDelegateAccessorsActionFactory : CreateCallableMemberFromUs if (isApplicableForAccessor(propertyDescriptor.getter)) { val getterInfo = FunctionInfo( - name = "getValue", + name = OperatorNameConventions.GET_VALUE.asString(), receiverTypeInfo = accessorReceiverType, returnTypeInfo = TypeInfo(propertyType, Variance.OUT_VARIANCE), parameterInfos = listOf(thisRefParam, metadataParam), @@ -74,7 +75,7 @@ object CreatePropertyDelegateAccessorsActionFactory : CreateCallableMemberFromUs if (propertyDescriptor.isVar && isApplicableForAccessor(propertyDescriptor.setter)) { val newValueParam = ParameterInfo(TypeInfo(propertyType, Variance.IN_VARIANCE)) val setterInfo = FunctionInfo( - name = "setValue", + name = OperatorNameConventions.SET_VALUE.asString(), receiverTypeInfo = accessorReceiverType, returnTypeInfo = TypeInfo(builtIns.unitType, Variance.OUT_VARIANCE), parameterInfos = listOf(thisRefParam, metadataParam, newValueParam), diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateSetFunctionActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateSetFunctionActionFactory.kt index 80d43b3c4b7..6fdcf1f3c2b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateSetFunctionActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateSetFunctionActionFactory.kt @@ -32,6 +32,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.types.ErrorUtils import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.expressions.OperatorConventions +import org.jetbrains.kotlin.util.OperatorNameConventions import java.util.* object CreateSetFunctionActionFactory : CreateGetSetFunctionActionFactory(isGet = false) { @@ -61,6 +62,8 @@ object CreateSetFunctionActionFactory : CreateGetSetFunctionActionFactory(isGet parameters.add(ParameterInfo(valType, "value")) val returnType = TypeInfo(builtIns.unitType, Variance.OUT_VARIANCE) - return FunctionInfo("set", arrayType, returnType, Collections.emptyList(), parameters, isOperator = true) + return FunctionInfo( + OperatorNameConventions.SET.asString(), arrayType, returnType, Collections.emptyList(), parameters, isOperator = true + ) } }