diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index d68d99b4a41..9b354ef86ba 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -518,6 +518,8 @@ public interface Errors { DiagnosticFactory0 NO_GET_METHOD = DiagnosticFactory0.create(ERROR, ARRAY_ACCESS); DiagnosticFactory0 NO_SET_METHOD = DiagnosticFactory0.create(ERROR, ARRAY_ACCESS); + DiagnosticFactory2 DEPRECATED_UNARY_PLUS_MINUS = DiagnosticFactory2.create(WARNING); + DiagnosticFactory0 INC_DEC_SHOULD_NOT_RETURN_UNIT = DiagnosticFactory0.create(ERROR); DiagnosticFactory2 ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT = DiagnosticFactory2.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 12ca5e43b9b..c21f5b5dace 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -310,6 +310,8 @@ public class DefaultErrorMessages { MAP.put(NO_GET_METHOD, "No get method providing array access"); MAP.put(NO_SET_METHOD, "No set method providing array access"); + MAP.put(DEPRECATED_UNARY_PLUS_MINUS, "Deprecated convention for ''{0}''. Rename to ''{1}''", NAME, STRING); + MAP.put(INC_DEC_SHOULD_NOT_RETURN_UNIT, "Functions inc(), dec() shouldn't return Unit to be used by operators ++, --"); MAP.put(ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT, "Function ''{0}'' should return Unit to be used by corresponding operator ''{1}''", NAME, ELEMENT_TEXT); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetOperationReferenceExpression.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetOperationReferenceExpression.kt index c4546d00972..bf82fe1eaca 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetOperationReferenceExpression.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetOperationReferenceExpression.kt @@ -28,9 +28,9 @@ import org.jetbrains.kotlin.types.expressions.OperatorConventions public class JetOperationReferenceExpression(node: ASTNode) : JetSimpleNameExpressionImpl(node) { override fun getReferencedNameElement() = (findChildByType(JetExpressionParsing.ALL_OPERATIONS): PsiElement?) ?: this - fun getNameForConventionalOperation(): Name? { + fun getNameForConventionalOperation(unaryOperations: Boolean = true, binaryOperations: Boolean = true): Name? { val operator = (firstChild as? TreeElement)?.elementType as? JetToken ?: return null - return OperatorConventions.getNameForOperationSymbol(operator) + return OperatorConventions.getNameForOperationSymbol(operator, unaryOperations, binaryOperations) } fun isPredefinedOperator() = (firstChild as? TreeElement)?.elementType is JetSingleValueToken diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiUtil.java index 894f94f9c09..4350983d27e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiUtil.java @@ -371,6 +371,10 @@ public class JetPsiUtil { IElementType elementType = firstChild.getNode().getElementType(); if (elementType instanceof JetToken) { JetToken jetToken = (JetToken) elementType; + boolean isPrefixExpression = simpleNameExpression.getParent() instanceof JetPrefixExpression; + if (isPrefixExpression) { + return OperatorConventions.getNameForOperationSymbol(jetToken, true, false); + } return OperatorConventions.getNameForOperationSymbol(jetToken); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt index 24835336bd0..89768a1e665 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor +import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.calls.CallTransformer import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem @@ -31,6 +32,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.Constrain import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.TypeUtils.DONT_CARE +import org.jetbrains.kotlin.util.OperatorNameConventions public enum class ResolveArgumentsMode { RESOLVE_FUNCTION_ARGUMENTS, @@ -120,6 +122,13 @@ fun isConventionCall(call: Call): Boolean { return calleeExpression.getNameForConventionalOperation() != null } +fun getUnaryPlusOrMinusOperatorFunctionName(call: Call): Name? { + if (call.callElement !is JetPrefixExpression) return null + val calleeExpression = call.calleeExpression as? JetOperationReferenceExpression ?: return null + val name = calleeExpression.getNameForConventionalOperation(unaryOperations = true, binaryOperations = false) + return if (name == OperatorNameConventions.UNARY_PLUS || name == OperatorNameConventions.UNARY_MINUS) name else null +} + public fun isInvokeCallOnVariable(call: Call): Boolean { if (call.getCallType() !== Call.CallType.INVOKE) return false val dispatchReceiver = call.getDispatchReceiver() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt index 7719b133ecf..7ebf8d08dfa 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt @@ -23,9 +23,9 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.resolve.calls.CallTransformer import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isConventionCall import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isOrOverridesSynthesized +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.getUnaryPlusOrMinusOperatorFunctionName import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastManager @@ -51,6 +51,7 @@ import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.checker.JetTypeChecker import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils import org.jetbrains.kotlin.types.isDynamic +import org.jetbrains.kotlin.util.OperatorNameConventions public class TaskPrioritizer( private val storageManager: StorageManager, @@ -76,6 +77,18 @@ public class TaskPrioritizer( } else { doComputeTasks(explicitReceiver, taskPrioritizerContext) + + // Temporary fix for code migration (unaryPlus()/unaryMinus()) + val unaryConventionName = getUnaryPlusOrMinusOperatorFunctionName(context.call) + if (unaryConventionName != null) { + val deprecatedName = if (name == OperatorNameConventions.UNARY_PLUS) + OperatorNameConventions.PLUS + else + OperatorNameConventions.MINUS + + val additionalContext = TaskPrioritizerContext(deprecatedName, result, context, context.scope, callableDescriptorCollectors) + doComputeTasks(explicitReceiver, additionalContext) + } } return result.getTasks() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/OperatorConventions.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/OperatorConventions.java index cd3ee35846b..898cbb6b73c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/OperatorConventions.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/OperatorConventions.java @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.types.expressions; import com.google.common.collect.ImmutableBiMap; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -24,6 +25,9 @@ import org.jetbrains.kotlin.lexer.JetSingleValueToken; import org.jetbrains.kotlin.lexer.JetToken; import org.jetbrains.kotlin.lexer.JetTokens; import org.jetbrains.kotlin.name.Name; + +import java.util.Map; + import static org.jetbrains.kotlin.util.OperatorNameConventions.*; public class OperatorConventions { @@ -49,11 +53,21 @@ public class OperatorConventions { public static final ImmutableBiMap UNARY_OPERATION_NAMES = ImmutableBiMap.builder() .put(JetTokens.PLUSPLUS, INC) .put(JetTokens.MINUSMINUS, DEC) - .put(JetTokens.PLUS, PLUS) - .put(JetTokens.MINUS, MINUS) + .put(JetTokens.PLUS, UNARY_PLUS) + .put(JetTokens.MINUS, UNARY_MINUS) .put(JetTokens.EXCL, NOT) .build(); + public static final ImmutableMap UNARY_OPERATION_NAMES_WITH_DEPRECATED_INVERTED = ImmutableMap.builder() + .put(INC, JetTokens.PLUSPLUS) + .put(DEC, JetTokens.MINUSMINUS) + .put(UNARY_PLUS, JetTokens.PLUS) + .put(PLUS, JetTokens.PLUS) + .put(UNARY_MINUS, JetTokens.MINUS) + .put(MINUS, JetTokens.MINUS) + .put(NOT, JetTokens.EXCL) + .build(); + public static final ImmutableBiMap BINARY_OPERATION_NAMES = ImmutableBiMap.builder() .put(JetTokens.MUL, TIMES) .put(JetTokens.PLUS, PLUS) @@ -111,10 +125,23 @@ public class OperatorConventions { @Nullable public static Name getNameForOperationSymbol(@NotNull JetToken token) { - Name name = UNARY_OPERATION_NAMES.get(token); - if (name != null) return name; - name = BINARY_OPERATION_NAMES.get(token); - if (name != null) return name; + return getNameForOperationSymbol(token, true, true); + } + + @Nullable + public static Name getNameForOperationSymbol(@NotNull JetToken token, boolean unaryOperations, boolean binaryOperations) { + Name name; + + if (binaryOperations) { + name = BINARY_OPERATION_NAMES.get(token); + if (name != null) return name; + } + + if (unaryOperations) { + name = UNARY_OPERATION_NAMES.get(token); + if (name != null) return name; + } + name = ASSIGNMENT_OPERATIONS.get(token); if (name != null) return name; if (COMPARISON_OPERATIONS.contains(token)) return COMPARE_TO; diff --git a/compiler/testData/diagnostics/tests/DeprecatedUnaryOperatorConventions.kt b/compiler/testData/diagnostics/tests/DeprecatedUnaryOperatorConventions.kt new file mode 100644 index 00000000000..b4bcafdd384 --- /dev/null +++ b/compiler/testData/diagnostics/tests/DeprecatedUnaryOperatorConventions.kt @@ -0,0 +1,22 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +class Example { + operator fun plus(): String = "" + operator fun unaryPlus(): Int = 0 +} + +class ExampleDeprecated { + operator fun plus(): String = "" +} + +operator fun String.plus(): String = this +operator fun String.unaryPlus(): Int = 0 + +fun test() { + requireInt(+ "") + requireInt(+ Example()) + requireString(+ ExampleDeprecated()) +} + +fun requireInt(n: Int) {} +fun requireString(s: String) {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/DeprecatedUnaryOperatorConventions.txt b/compiler/testData/diagnostics/tests/DeprecatedUnaryOperatorConventions.txt new file mode 100644 index 00000000000..bd8caa42d0f --- /dev/null +++ b/compiler/testData/diagnostics/tests/DeprecatedUnaryOperatorConventions.txt @@ -0,0 +1,24 @@ +package + +public fun requireInt(/*0*/ n: kotlin.Int): kotlin.Unit +public fun requireString(/*0*/ s: kotlin.String): kotlin.Unit +public fun test(): kotlin.Unit +public operator fun kotlin.String.plus(): kotlin.String +public operator fun kotlin.String.unaryPlus(): kotlin.Int + +public final class Example { + public constructor Example() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final operator fun plus(): kotlin.String + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + public final operator fun unaryPlus(): kotlin.Int +} + +public final class ExampleDeprecated { + public constructor ExampleDeprecated() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final operator fun plus(): kotlin.String + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/conventions.dynamic.txt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/conventions.dynamic.txt index 3e37e0b93c7..955f8a32fae 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/conventions.dynamic.txt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/conventions.dynamic.txt @@ -1,5 +1,5 @@ -public final fun plus(): dynamic -public final fun minus(): dynamic +public final fun unaryPlus(): dynamic +public final fun unaryMinus(): dynamic public final fun not(): dynamic public final fun plus(/*0*/ p0: dynamic): dynamic public final fun plus(/*0*/ p0: dynamic): dynamic diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index a749af0098d..2d2db52c52f 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -187,6 +187,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("DeprecatedUnaryOperatorConventions.kt") + public void testDeprecatedUnaryOperatorConventions() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/DeprecatedUnaryOperatorConventions.kt"); + doTest(fileName); + } + @TestMetadata("DiamondFunction.kt") public void testDiamondFunction() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/DiamondFunction.kt"); diff --git a/core/descriptors/src/org/jetbrains/kotlin/util/OperatorNameConventions.kt b/core/descriptors/src/org/jetbrains/kotlin/util/OperatorNameConventions.kt index 20e576fecb3..b69ec12f115 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/util/OperatorNameConventions.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/util/OperatorNameConventions.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.util import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.name.Name +import java.util.* import kotlin.text.Regex object OperatorNameConventions { @@ -44,6 +45,9 @@ object OperatorNameConventions { val MINUS = Name.identifier("minus") val NOT = Name.identifier("not") + val UNARY_MINUS = Name.identifier("unaryMinus") + val UNARY_PLUS = Name.identifier("unaryPlus") + val TIMES = Name.identifier("times") val DIV = Name.identifier("div") val MOD = Name.identifier("mod") @@ -57,7 +61,8 @@ object OperatorNameConventions { // If you add new unary, binary or assignment operators, add it to OperatorConventions as well - private val UNARY_OPERATION_NAMES = setOf(INC, DEC, PLUS, MINUS, NOT) + val UNARY_OPERATION_NAMES_WITH_DEPRECATED = Collections.unmodifiableSet(setOf(INC, DEC, UNARY_PLUS, PLUS, UNARY_MINUS, MINUS, NOT)) + private val UNARY_OPERATION_NAMES = setOf(INC, DEC, UNARY_PLUS, UNARY_MINUS, NOT) private val BINARY_OPERATION_NAMES = setOf(TIMES, PLUS, MINUS, DIV, MOD, RANGE_TO) private val ASSIGNMENT_OPERATIONS = setOf(TIMES_ASSIGN, DIV_ASSIGN, MOD_ASSIGN, PLUS_ASSIGN, MINUS_ASSIGN) @@ -76,6 +81,7 @@ object OperatorNameConventions { COMPARE_TO == name -> true UNARY_OPERATION_NAMES.any { it == name } && functionDescriptor.valueParameters.isEmpty() -> true BINARY_OPERATION_NAMES.any { it == name } && functionDescriptor.valueParameters.size() == 1 -> true + (PLUS == name) || (MINUS == name) -> true //temporary fix for deprecated unaryPlus()/unaryMinus() ASSIGNMENT_OPERATIONS.any { it == name } -> true name.asString().matches(COMPONENT_REGEX) -> true else -> false diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/conventions.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/conventions.kt index 48ef09f8fd2..daf5eb95221 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/conventions.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/conventions.kt @@ -60,7 +60,7 @@ public fun Name.getOperationSymbolsToSearch(): Set { if (isComponentLike(this)) return setOf(JetTokens.LPAR) - val unaryOp = UNARY_OPERATION_NAMES.inverse()[this] + val unaryOp = UNARY_OPERATION_NAMES_WITH_DEPRECATED_INVERTED[this] if (unaryOp != null) return setOf(unaryOp) val binaryOp = BINARY_OPERATION_NAMES.inverse()[this] diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRecursiveCallLineMarkerProvider.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRecursiveCallLineMarkerProvider.kt index e6b2d7d1410..53d02b9094b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRecursiveCallLineMarkerProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRecursiveCallLineMarkerProvider.kt @@ -143,7 +143,12 @@ private fun getCallNameFromPsi(element: JetElement): Name? { if (element == operationReference) { val node = operationReference.getReferencedNameElementType() return if (node is JetToken) { - OperatorConventions.getNameForOperationSymbol(node) ?: Name.identifierNoValidate(element.getText()) + val conventionName = if (elementParent is JetPrefixExpression) + OperatorConventions.getNameForOperationSymbol(node, true, false) + else + OperatorConventions.getNameForOperationSymbol(node) + + conventionName ?: Name.identifierNoValidate(element.getText()) } else { Name.identifierNoValidate(element.getText()) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/OperatorModifierInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/OperatorModifierInspection.kt index 333f8498e0e..fb90cae42b0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/OperatorModifierInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/OperatorModifierInspection.kt @@ -69,6 +69,7 @@ public class OperatorModifierInspection : AbstractKotlinInspection() { val arity = valueParameters.size() if (arity == 0 && (name in OperatorConventions.UNARY_OPERATION_NAMES.values() || + name == OperatorNameConventions.PLUS || name == OperatorNameConventions.MINUS || // temporary name == OperatorNameConventions.ITERATOR || isComponentLike(name) || name == OperatorNameConventions.NEXT || diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateBinaryOperationActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateBinaryOperationActionFactory.kt index 05875eb472f..4979e98da12 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateBinaryOperationActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateBinaryOperationActionFactory.kt @@ -35,7 +35,7 @@ public object CreateBinaryOperationActionFactory: CreateCallableMemberFromUsageF val token = element.operationToken as JetToken val operationName = when (token) { JetTokens.IDENTIFIER -> element.operationReference.getReferencedName() - else -> OperatorConventions.getNameForOperationSymbol(token)?.asString() + else -> OperatorConventions.getNameForOperationSymbol(token, false, true)?.asString() } ?: return null val inOperation = token in OperatorConventions.IN_OPERATIONS val comparisonOperation = token in OperatorConventions.COMPARISON_OPERATIONS diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateUnaryOperationActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateUnaryOperationActionFactory.kt index febe102e4e6..201080395a3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateUnaryOperationActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateUnaryOperationActionFactory.kt @@ -32,7 +32,7 @@ public object CreateUnaryOperationActionFactory: CreateCallableMemberFromUsageFa override fun createCallableInfo(element: JetUnaryExpression, diagnostic: Diagnostic): CallableInfo? { val token = element.operationToken as JetToken - val operationName = OperatorConventions.getNameForOperationSymbol(token) ?: return null + val operationName = OperatorConventions.getNameForOperationSymbol(token, true, false) ?: return null val incDec = token in OperatorConventions.INCREMENT_OPERATIONS val receiverExpr = element.baseExpression ?: return null diff --git a/idea/testData/codeInsight/lineMarker/recursiveCall/conventionCall.kt b/idea/testData/codeInsight/lineMarker/recursiveCall/conventionCall.kt index 7725735db81..e26b22b4601 100644 --- a/idea/testData/codeInsight/lineMarker/recursiveCall/conventionCall.kt +++ b/idea/testData/codeInsight/lineMarker/recursiveCall/conventionCall.kt @@ -22,11 +22,11 @@ class A { return 1 } - fun plus() { + fun unaryPlus() { +this } - fun minus() { + fun unaryMinus() { -this } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/acceptableVararg.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/acceptableVararg.kt index 12890d712c2..3833b3dfe46 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/acceptableVararg.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/acceptableVararg.kt @@ -1,7 +1,7 @@ fun test() { class Test { - fun plus(vararg a: Int): Test = Test() + fun unaryPlus(vararg a: Int): Test = Test() } val test = Test() - test.plus() + test.unaryPlus() } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/acceptableVararg.kt.after b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/acceptableVararg.kt.after index ebe6c099378..f5dcacfa311 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/acceptableVararg.kt.after +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/acceptableVararg.kt.after @@ -1,6 +1,6 @@ fun test() { class Test { - fun plus(vararg a: Int): Test = Test() + fun unaryPlus(vararg a: Int): Test = Test() } val test = Test() +test diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt index 48cbbaadcee..90584de7521 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt @@ -2,10 +2,10 @@ fun doSomething(a: T) {} fun test() { class Test { - fun plus(): Test = Test() + fun unaryPlus(): Test = Test() fun plus(a: Test): Test = Test() - fun minus(): Test = Test() + fun unaryMinus(): Test = Test() } val test = Test() - doSomething((-((test + test).plus())).toString()) + doSomething((-((test + test).unaryPlus())).toString()) } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt.after b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt.after index 7aa5f3e5df1..175daac3073 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt.after +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt.after @@ -2,9 +2,9 @@ fun doSomething(a: T) {} fun test() { class Test { - fun plus(): Test = Test() + fun unaryPlus(): Test = Test() fun plus(a: Test): Test = Test() - fun minus(): Test = Test() + fun unaryMinus(): Test = Test() } val test = Test() doSomething((-(+(test + test))).toString()) diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/defaultArgument.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/defaultArgument.kt index 77fe11625ab..4cb09621aff 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/defaultArgument.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/defaultArgument.kt @@ -1,7 +1,7 @@ fun test() { class Test { - fun plus(a: Int=1): Test = Test() + fun unaryPlus(a: Int=1): Test = Test() } val test = Test() - test.plus() + test.unaryPlus() } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/defaultArgument.kt.after b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/defaultArgument.kt.after index ba8be21f613..18783d6e16a 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/defaultArgument.kt.after +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/defaultArgument.kt.after @@ -1,6 +1,6 @@ fun test() { class Test { - fun plus(a: Int=1): Test = Test() + fun unaryPlus(a: Int=1): Test = Test() } val test = Test() +test diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt index f30fa09115b..8e47f5e4e55 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt @@ -1,8 +1,8 @@ fun test() { class Test() - fun Test.plus(): Test = Test() + fun Test.unaryPlus(): Test = Test() val test = Test() - test.plus() + test.unaryPlus() } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt.after b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt.after index e351cadc88d..b3efb2dbaf8 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt.after +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt.after @@ -1,7 +1,7 @@ fun test() { class Test() - fun Test.plus(): Test = Test() + fun Test.unaryPlus(): Test = Test() val test = Test() +test diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/functionLiteralArgument.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/functionLiteralArgument.kt index 7ed78bd9398..ff206b84586 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/functionLiteralArgument.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/functionLiteralArgument.kt @@ -1,8 +1,8 @@ // IS_APPLICABLE: false fun test() { class Test { - fun plus(fn: () -> Unit): Test = Test() + fun unaryPlus(fn: () -> Unit): Test = Test() } val test = Test() - test.plus {} + test.unaryPlus {} } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt index e7c688262f8..b3083f198a1 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt @@ -1,8 +1,8 @@ // INTENTION_TEXT: Replace with '-' operator fun test() { class Test { - fun minus(): Test = Test() + fun unaryMinus(): Test = Test() } val test = Test() - test.minus() + test.unaryMinus() } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt.after b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt.after index 65d3c74b0d9..ccc39653c56 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt.after +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt.after @@ -1,7 +1,7 @@ // INTENTION_TEXT: Replace with '-' operator fun test() { class Test { - fun minus(): Test = Test() + fun unaryMinus(): Test = Test() } val test = Test() -test diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/namedValueArgument.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/namedValueArgument.kt index dcff041a47d..4d4f39aa16a 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/namedValueArgument.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/namedValueArgument.kt @@ -1,8 +1,8 @@ // IS_APPLICABLE: false fun test() { class Test { - fun plus(a: Int): Test = Test() + fun unaryPlus(a: Int): Test = Test() } val test = Test() - test.plus(a=1) + test.unaryPlus(a=1) } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt index 6e5de0567e6..1b5a568f726 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt @@ -1,7 +1,7 @@ fun test() { class Test { - fun plus(): Test = Test() + fun unaryPlus(): Test = Test() } val test = Test() - +test.plus() + +test.unaryPlus() } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt.after b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt.after index de09519575a..c4213b3430f 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt.after +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt.after @@ -1,6 +1,6 @@ fun test() { class Test { - fun plus(): Test = Test() + fun unaryPlus(): Test = Test() } val test = Test() +(+test) diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt index 5d3c231b2b2..3cc07d9d70c 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt @@ -1,8 +1,8 @@ // INTENTION_TEXT: Replace with '+' operator fun test() { class Test { - fun plus(): Test = Test() + fun unaryPlus(): Test = Test() } val test = Test() - test.plus() + test.unaryPlus() } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt.after b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt.after index 84088da876c..87046c7f5e3 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt.after +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt.after @@ -1,7 +1,7 @@ // INTENTION_TEXT: Replace with '+' operator fun test() { class Test { - fun plus(): Test = Test() + fun unaryPlus(): Test = Test() } val test = Test() +test diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt index 9ee010e0687..49b99081d5b 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt @@ -1,9 +1,9 @@ class C { companion object { - fun minus(): C = C() + fun unaryMinus(): C = C() } } fun foo() { - C.minus() + C.unaryMinus() } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt.after b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt.after index 8eb489b730c..63a45078ab6 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt.after +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt.after @@ -1,6 +1,6 @@ class C { companion object { - fun minus(): C = C() + fun unaryMinus(): C = C() } } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/super.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/super.kt index 2b0476ccd54..90f14507191 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/super.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/super.kt @@ -1,11 +1,11 @@ // IS_APPLICABLE: false open class Base { - open fun minus() = this + open fun unaryMinus() = this } class C : Base() { - override fun minus(): Base { - return super.minus() + override fun unaryMinus(): Base { + return super.unaryMinus() } } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/typeArguments.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/typeArguments.kt index 3c62355df69..bb92785b513 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/typeArguments.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/typeArguments.kt @@ -1,8 +1,8 @@ // IS_APPLICABLE: false fun test() { class Test { - fun plus(): T? = this as? T + fun unaryPlus(): T? = this as? T } val test = Test() - test.plus() + test.unaryPlus() } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/unacceptableVararg.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/unacceptableVararg.kt index b89a096aebe..02fc3cad061 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/unacceptableVararg.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/unacceptableVararg.kt @@ -1,8 +1,8 @@ // IS_APPLICABLE: false fun test() { class Test { - fun plus(vararg a: Int): Test = Test() + fun unaryPlus(vararg a: Int): Test = Test() } val test = Test() - test.plus(0) + test.unaryPlus(0) } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/valueArgument.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/valueArgument.kt index 7d4336574b6..d481d683ebe 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/valueArgument.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/valueArgument.kt @@ -1,8 +1,8 @@ // IS_APPLICABLE: false fun test() { class Test { - fun plus(a: Int): Test = Test() + fun unaryPlus(a: Int): Test = Test() } val test = Test() - test.plus(1) + test.unaryPlus(1) } diff --git a/idea/testData/intentions/convertFunctionToProperty/unaryOp.kt b/idea/testData/intentions/convertFunctionToProperty/unaryOp.kt index 90a3c694538..b058aaa31cb 100644 --- a/idea/testData/intentions/convertFunctionToProperty/unaryOp.kt +++ b/idea/testData/intentions/convertFunctionToProperty/unaryOp.kt @@ -1,7 +1,7 @@ // WITH_RUNTIME // IS_APPLICABLE: false class A(val n: Int) { - fun minus(): A = A(-n) + fun unaryMinus(): A = A(-n) } fun test() { diff --git a/idea/testData/quickfix/autoImports/unaryMinusOperator.after.kt b/idea/testData/quickfix/autoImports/unaryMinusOperator.after.kt index 36ce590e8d0..402228bd0f9 100644 --- a/idea/testData/quickfix/autoImports/unaryMinusOperator.after.kt +++ b/idea/testData/quickfix/autoImports/unaryMinusOperator.after.kt @@ -3,7 +3,7 @@ package h -import util.minus +import util.unaryMinus interface H diff --git a/idea/testData/quickfix/autoImports/unaryMinusOperator.before.Dependency.kt b/idea/testData/quickfix/autoImports/unaryMinusOperator.before.Dependency.kt index 0a543bc5b03..5150a02746a 100644 --- a/idea/testData/quickfix/autoImports/unaryMinusOperator.before.Dependency.kt +++ b/idea/testData/quickfix/autoImports/unaryMinusOperator.before.Dependency.kt @@ -1,3 +1,3 @@ package util -operator fun h.H?.minus() = "" \ No newline at end of file +operator fun h.H?.unaryMinus() = "" \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/unaryPlusOperator.after.kt b/idea/testData/quickfix/autoImports/unaryPlusOperator.after.kt index ae4c44c89e1..437fd4d0e50 100644 --- a/idea/testData/quickfix/autoImports/unaryPlusOperator.after.kt +++ b/idea/testData/quickfix/autoImports/unaryPlusOperator.after.kt @@ -1,9 +1,9 @@ // "Import" "true" -// ERROR: Unresolved reference.
None of the following candidates is applicable because of receiver type mismatch:
  • public operator fun h.A.plus(): kotlin.Int defined in h
  • public operator fun kotlin.String?.plus(other: kotlin.Any?): kotlin.String defined in kotlin
+// ERROR: Unresolved reference.
None of the following candidates is applicable because of receiver type mismatch:
  • public operator fun h.A.unaryPlus(): kotlin.Int defined in h
package h -import util.plus +import util.unaryPlus interface H @@ -13,4 +13,4 @@ fun f(h: H?) { class A() -operator fun A.plus(): Int = 3 \ No newline at end of file +operator fun A.unaryPlus(): Int = 3 \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/unaryPlusOperator.before.Dependency.kt b/idea/testData/quickfix/autoImports/unaryPlusOperator.before.Dependency.kt index fb64b4a74d8..6ac81de3c74 100644 --- a/idea/testData/quickfix/autoImports/unaryPlusOperator.before.Dependency.kt +++ b/idea/testData/quickfix/autoImports/unaryPlusOperator.before.Dependency.kt @@ -1,3 +1,3 @@ package util -operator fun h.H.plus() = "" \ No newline at end of file +operator fun h.H.unaryPlus() = "" \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/unaryPlusOperator.before.Main.kt b/idea/testData/quickfix/autoImports/unaryPlusOperator.before.Main.kt index 94d474eb74d..db9b7d69be2 100644 --- a/idea/testData/quickfix/autoImports/unaryPlusOperator.before.Main.kt +++ b/idea/testData/quickfix/autoImports/unaryPlusOperator.before.Main.kt @@ -1,5 +1,5 @@ // "Import" "true" -// ERROR: Unresolved reference.
None of the following candidates is applicable because of receiver type mismatch:
  • public operator fun h.A.plus(): kotlin.Int defined in h
  • public operator fun kotlin.String?.plus(other: kotlin.Any?): kotlin.String defined in kotlin
+// ERROR: Unresolved reference.
None of the following candidates is applicable because of receiver type mismatch:
  • public operator fun h.A.unaryPlus(): kotlin.Int defined in h
package h @@ -11,4 +11,4 @@ fun f(h: H?) { class A() -operator fun A.plus(): Int = 3 \ No newline at end of file +operator fun A.unaryPlus(): Int = 3 \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusExtraArgs.kt b/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusExtraArgs.kt index e71b6d28e8e..c43c5aa59dd 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusExtraArgs.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusExtraArgs.kt @@ -1,9 +1,9 @@ // "Create member function 'plus'" "true" class A(val n: T) { - fun plus(): A = throw Exception() + operator fun unaryPlus(): A = throw Exception() } fun test() { - val a: A = A(1) + 2 + val a: A = A(1) + 2 } \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusExtraArgs.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusExtraArgs.kt.after index c9c1d52a8ca..fea4dc07535 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusExtraArgs.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusExtraArgs.kt.after @@ -1,7 +1,7 @@ // "Create member function 'plus'" "true" class A(val n: T) { - fun plus(): A = throw Exception() + operator fun unaryPlus(): A = throw Exception() operator fun plus(t: T): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. diff --git a/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/var.kt b/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/var.kt index 964ff7116fa..c152b01e5e6 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/var.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/var.kt @@ -1,4 +1,4 @@ -// "Create member function 'getValue', function 'set'" "true" +// "Create member function 'getValue', function 'setValue'" "true" class F { } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingSet.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingSet.kt.after index 7d4020e6a45..142f0dfc9b4 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingSet.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingSet.kt.after @@ -1,8 +1,8 @@ // "Create member function 'setValue'" "true" class F { - fun get(x: X, propertyMetadata: PropertyMetadata): Int = 1 + fun getValue(x: X, propertyMetadata: PropertyMetadata): Int = 1 - fun set(x: X, propertyMetadata: PropertyMetadata, i: Int) { + fun setValue(x: X, propertyMetadata: PropertyMetadata, i: Int) { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusMissingArgs.kt b/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusMissingArgs.kt index 8cfb663dc85..614972a27cd 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusMissingArgs.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusMissingArgs.kt @@ -1,7 +1,7 @@ -// "Create member function 'minus'" "true" +// "Create member function 'unaryMinus'" "true" class A(val n: T) { - fun minus(n: Int): A = throw Exception() + operator fun minus(n: Int): A = throw Exception() } fun test() { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusMissingArgs.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusMissingArgs.kt.after index 56839f80ed1..835a899f8e7 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusMissingArgs.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusMissingArgs.kt.after @@ -1,9 +1,9 @@ -// "Create member function 'minus'" "true" +// "Create member function 'unaryMinus'" "true" class A(val n: T) { - fun minus(n: Int): A = throw Exception() + operator fun minus(n: Int): A = throw Exception() - operator fun minus(): A { + operator fun unaryMinus(): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnLibType.kt b/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnLibType.kt index 9a3bc997ba7..d5549371ec8 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnLibType.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnLibType.kt @@ -1,4 +1,4 @@ -// "Create extension function 'minus'" "true" +// "Create extension function 'unaryMinus'" "true" fun test() { val a = -false diff --git a/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnLibType.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnLibType.kt.after index ef9f3ab7ea6..473b11230e6 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnLibType.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnLibType.kt.after @@ -1,9 +1,9 @@ -// "Create extension function 'minus'" "true" +// "Create extension function 'unaryMinus'" "true" fun test() { val a = -false } -operator fun Boolean.minus(): Any { +operator fun Boolean.unaryMinus(): Any { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserType.kt b/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserType.kt index 142735ba94c..eb7f03fe386 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserType.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserType.kt @@ -1,4 +1,4 @@ -// "Create member function 'minus'" "true" +// "Create member function 'unaryMinus'" "true" class A(val n: T) diff --git a/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserType.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserType.kt.after index 6c45679ef95..12aaa39a31e 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserType.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserType.kt.after @@ -1,7 +1,7 @@ -// "Create member function 'minus'" "true" +// "Create member function 'unaryMinus'" "true" class A(val n: T) { - operator fun minus(): Any { + operator fun unaryMinus(): Any { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserTypeWithTypeParams.kt b/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserTypeWithTypeParams.kt index 4677bf22527..fec12102f47 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserTypeWithTypeParams.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserTypeWithTypeParams.kt @@ -1,4 +1,4 @@ -// "Create member function 'minus'" "true" +// "Create member function 'unaryMinus'" "true" class A(val n: T) diff --git a/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserTypeWithTypeParams.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserTypeWithTypeParams.kt.after index 7058a7c8731..1c737b4a635 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserTypeWithTypeParams.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserTypeWithTypeParams.kt.after @@ -1,7 +1,7 @@ -// "Create member function 'minus'" "true" +// "Create member function 'unaryMinus'" "true" class A(val n: T) { - operator fun minus(): A { + operator fun unaryMinus(): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/PrimitiveUnaryOperationFIF.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/PrimitiveUnaryOperationFIF.java index 676458fedcb..bd861357a13 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/PrimitiveUnaryOperationFIF.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/PrimitiveUnaryOperationFIF.java @@ -32,6 +32,7 @@ import org.jetbrains.kotlin.js.translate.utils.JsDescriptorUtils; import org.jetbrains.kotlin.lexer.JetToken; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.types.expressions.OperatorConventions; +import org.jetbrains.kotlin.util.OperatorNameConventions; import java.util.List; @@ -42,7 +43,7 @@ public enum PrimitiveUnaryOperationFIF implements FunctionIntrinsicFactory { INSTANCE; - private static final NamePredicate UNARY_OPERATIONS = new NamePredicate(OperatorConventions.UNARY_OPERATION_NAMES.values()); + private static final NamePredicate UNARY_OPERATIONS = new NamePredicate(OperatorNameConventions.UNARY_OPERATION_NAMES_WITH_DEPRECATED); @NotNull private static final DescriptorPredicate UNARY_OPERATION_FOR_PRIMITIVE_NUMBER = pattern(NamePredicate.PRIMITIVE_NUMBERS_MAPPED_TO_PRIMITIVE_JS, UNARY_OPERATIONS); @@ -192,7 +193,7 @@ public enum PrimitiveUnaryOperationFIF implements FunctionIntrinsicFactory { jsOperator = JsUnaryOperator.BIT_NOT; } else { - JetToken jetToken = OperatorConventions.UNARY_OPERATION_NAMES.inverse().get(name); + JetToken jetToken = OperatorConventions.UNARY_OPERATION_NAMES_WITH_DEPRECATED_INVERTED.get(name); jsOperator = OperatorTable.getUnaryOperator(jetToken); }