From 5f71f1bcadf91e1cb9e40340bbbdf07966732bf9 Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Mon, 5 Dec 2016 22:43:07 +0300 Subject: [PATCH] Add warnings at declaration and call sites of operator 'mod' --- .../jetbrains/kotlin/diagnostics/Errors.java | 3 ++ .../rendering/DefaultErrorMessages.java | 3 ++ .../kotlin/resolve/OperatorModifierChecker.kt | 8 +++- .../calls/checkers/OperatorCallChecker.kt | 11 +++++ .../DeprecatedModAssignOperatorConventions.kt | 10 ++-- .../tests/DeprecatedModOperatorConventions.kt | 10 ++-- .../operatorRem/deprecatedModConvention.kt | 37 +++++++++++++++ .../operatorRem/deprecatedModConvention.txt | 46 +++++++++++++++++++ ...noDeprecatedModConventionWithoutFeature.kt | 38 +++++++++++++++ ...oDeprecatedModConventionWithoutFeature.txt | 46 +++++++++++++++++++ .../preferRemAsExtentionOverMod.kt | 2 +- .../operatorRem/preferRemAsMemberOverMod.kt | 2 +- .../prefereRemAsExtensionOverMemberMod.kt | 2 +- .../AssignmentOperations.kt | 4 +- .../AssignmentOperations.txt | 4 +- .../diagnostics/tests/regressions/kt629.kt | 2 +- .../diagnostics/tests/regressions/kt629.txt | 2 +- .../checkers/DiagnosticsTestGenerated.java | 12 +++++ 18 files changed, 222 insertions(+), 20 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/operatorRem/deprecatedModConvention.kt create mode 100644 compiler/testData/diagnostics/tests/operatorRem/deprecatedModConvention.txt create mode 100644 compiler/testData/diagnostics/tests/operatorRem/noDeprecatedModConventionWithoutFeature.kt create mode 100644 compiler/testData/diagnostics/tests/operatorRem/noDeprecatedModConventionWithoutFeature.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 22ab0815a55..6853074d6d0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -629,6 +629,9 @@ public interface Errors { // Conventions + DiagnosticFactory2 DEPRECATED_BINARY_MOD = DiagnosticFactory2.create(WARNING); + DiagnosticFactory2 DEPRECATED_BINARY_MOD_AS_REM = DiagnosticFactory2.create(WARNING); + DiagnosticFactory0 NO_GET_METHOD = DiagnosticFactory0.create(ERROR, ARRAY_ACCESS); DiagnosticFactory0 NO_SET_METHOD = DiagnosticFactory0.create(ERROR, ARRAY_ACCESS); 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 2958237f1bd..839ff570fd0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -354,6 +354,9 @@ public class DefaultErrorMessages { MAP.put(LOCAL_VARIABLE_WITH_SETTER, "Local variables are not allowed to have setters"); MAP.put(VAL_WITH_SETTER, "A 'val'-property cannot have a setter"); + MAP.put(DEPRECATED_BINARY_MOD, "Deprecated convention for ''{0}''. Use ''{1}''", NAME, STRING); + MAP.put(DEPRECATED_BINARY_MOD_AS_REM, "''%'' is resolved to deprecated ''{0}'' operator. Replace with ''.{0}'' or add operator ''{1}''", NAME, STRING); + MAP.put(NO_GET_METHOD, "No get method providing array access"); MAP.put(NO_SET_METHOD, "No set method providing array access"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OperatorModifierChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OperatorModifierChecker.kt index b26e04f7c6f..7596e3d5c0f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OperatorModifierChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OperatorModifierChecker.kt @@ -42,6 +42,7 @@ object OperatorModifierChecker { val checkResult = OperatorChecks.check(functionDescriptor) if (checkResult.isSuccess) { + val shouldUseOperatorRem = languageVersionSettings.supportsFeature(LanguageFeature.OperatorRem) when (functionDescriptor.name) { in COROUTINE_OPERATOR_NAMES -> { if (!languageVersionSettings.supportsFeature(LanguageFeature.Coroutines)) { @@ -50,12 +51,17 @@ object OperatorModifierChecker { } in REM_TO_MOD_OPERATION_NAMES.keys -> { - if (!languageVersionSettings.supportsFeature(LanguageFeature.OperatorRem)) { + if (!shouldUseOperatorRem) { diagnosticHolder.report(Errors.UNSUPPORTED_FEATURE.on(modifier, LanguageFeature.OperatorRem)) } } } + if (functionDescriptor.name in REM_TO_MOD_OPERATION_NAMES.values && shouldUseOperatorRem) { + val newNameConvention = REM_TO_MOD_OPERATION_NAMES.inverse()[functionDescriptor.name] + diagnosticHolder.report(Errors.DEPRECATED_BINARY_MOD.on(modifier, functionDescriptor, newNameConvention!!.asString())) + } + return } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/OperatorCallChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/OperatorCallChecker.kt index 4fb68b77f58..bdb1f32bffb 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/OperatorCallChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/OperatorCallChecker.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.resolve.calls.checkers import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.diagnostics.DiagnosticSink import org.jetbrains.kotlin.diagnostics.Errors @@ -31,6 +32,7 @@ import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe import org.jetbrains.kotlin.types.ErrorUtils +import org.jetbrains.kotlin.types.expressions.OperatorConventions class OperatorCallChecker : CallChecker { override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) { @@ -58,6 +60,15 @@ class OperatorCallChecker : CallChecker { } val isConventionOperator = element is KtOperationReferenceExpression && element.isConventionOperator() + + if (isConventionOperator) { + val shouldUseOperatorRem = context.languageVersionSettings.supportsFeature(LanguageFeature.OperatorRem) + if (functionDescriptor.name in OperatorConventions.REM_TO_MOD_OPERATION_NAMES.values && shouldUseOperatorRem) { + val newNameConvention = OperatorConventions.REM_TO_MOD_OPERATION_NAMES.inverse()[functionDescriptor.name] + context.trace.report(Errors.DEPRECATED_BINARY_MOD_AS_REM.on(reportOn, functionDescriptor, newNameConvention!!.asString())) + } + } + if (isConventionOperator || element is KtArrayAccessExpression) { if (!functionDescriptor.isOperator) { report(reportOn, functionDescriptor, context.trace) diff --git a/compiler/testData/diagnostics/tests/DeprecatedModAssignOperatorConventions.kt b/compiler/testData/diagnostics/tests/DeprecatedModAssignOperatorConventions.kt index 768c157fe3b..4fbeea957c5 100644 --- a/compiler/testData/diagnostics/tests/DeprecatedModAssignOperatorConventions.kt +++ b/compiler/testData/diagnostics/tests/DeprecatedModAssignOperatorConventions.kt @@ -1,12 +1,12 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER class OldAndNew { - operator fun modAssign(x: Int) {} + operator fun modAssign(x: Int) {} operator fun remAssign(x: Int) {} } class OnlyOld { - operator fun modAssign(x: Int) {} + operator fun modAssign(x: Int) {} } class OnlyNew { @@ -15,11 +15,11 @@ class OnlyNew { class Sample -operator fun Sample.modAssign(x: Int) {} +operator fun Sample.modAssign(x: Int) {} operator fun Sample.remAssign(x: Int) {} class ModAndRemAssign { - operator fun mod(x: Int): ModAndRemAssign = ModAndRemAssign() + operator fun mod(x: Int): ModAndRemAssign = ModAndRemAssign() operator fun remAssign(x: Int) {} } @@ -28,7 +28,7 @@ fun test() { oldAndNew %= 1 val onlyOld = OnlyOld() - onlyOld %= 1 + onlyOld %= 1 val onlyNew = OnlyNew() onlyNew %= 1 diff --git a/compiler/testData/diagnostics/tests/DeprecatedModOperatorConventions.kt b/compiler/testData/diagnostics/tests/DeprecatedModOperatorConventions.kt index dff02b88e00..f3b3db93035 100644 --- a/compiler/testData/diagnostics/tests/DeprecatedModOperatorConventions.kt +++ b/compiler/testData/diagnostics/tests/DeprecatedModOperatorConventions.kt @@ -1,12 +1,12 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER class OldAndNew { - operator fun mod(x: Int) {} + operator fun mod(x: Int) {} operator fun rem(x: Int) {} } class OnlyOld { - operator fun mod(x: Int) {} + operator fun mod(x: Int) {} } class OnlyNew { @@ -15,17 +15,17 @@ class OnlyNew { class Sample -operator fun Sample.mod(x: Int) {} +operator fun Sample.mod(x: Int) {} operator fun Sample.rem(x: Int) {} class IntAndUnit { - operator fun mod(x: Int): Int = 0 + operator fun mod(x: Int): Int = 0 operator fun rem(x: Int) {} } fun test() { OldAndNew() % 1 - OnlyOld() % 1 + OnlyOld() % 1 OnlyNew() % 1 Sample() % 1 diff --git a/compiler/testData/diagnostics/tests/operatorRem/deprecatedModConvention.kt b/compiler/testData/diagnostics/tests/operatorRem/deprecatedModConvention.kt new file mode 100644 index 00000000000..cab83732480 --- /dev/null +++ b/compiler/testData/diagnostics/tests/operatorRem/deprecatedModConvention.kt @@ -0,0 +1,37 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +object ModAndRem { + operator fun mod(x: Int) {} + operator fun rem(x: Int) {} +} + +object OldMod { + operator fun mod(x: Int) {} +} + +object ModAndRemExtension +operator fun ModAndRemExtension.mod(x: Int) {} +operator fun ModAndRemExtension.rem(x: Int) {} + +object ModExtension +operator fun ModExtension.mod(x: Int) {} + +object ModMemberAndRemExtension { + operator fun mod(x: Int) {} +} + +operator fun ModMemberAndRemExtension.rem(x: Int) {} + +fun foo() { + ModAndRem % 1 + OldMod % 1 + + ModAndRemExtension % 1 + + ModExtension % 1 + + ModMemberAndRemExtension % 1 + + OldMod.mod(1) + ModExtension.mod(1) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/operatorRem/deprecatedModConvention.txt b/compiler/testData/diagnostics/tests/operatorRem/deprecatedModConvention.txt new file mode 100644 index 00000000000..2a30499e505 --- /dev/null +++ b/compiler/testData/diagnostics/tests/operatorRem/deprecatedModConvention.txt @@ -0,0 +1,46 @@ +package + +public fun foo(): kotlin.Unit +public operator fun ModAndRemExtension.mod(/*0*/ x: kotlin.Int): kotlin.Unit +public operator fun ModExtension.mod(/*0*/ x: kotlin.Int): kotlin.Unit +public operator fun ModAndRemExtension.rem(/*0*/ x: kotlin.Int): kotlin.Unit +public operator fun ModMemberAndRemExtension.rem(/*0*/ x: kotlin.Int): kotlin.Unit + +public object ModAndRem { + private constructor ModAndRem() + 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 mod(/*0*/ x: kotlin.Int): kotlin.Unit + public final operator fun rem(/*0*/ x: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public object ModAndRemExtension { + private constructor ModAndRemExtension() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public object ModExtension { + private constructor ModExtension() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public object ModMemberAndRemExtension { + private constructor ModMemberAndRemExtension() + 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 mod(/*0*/ x: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public object OldMod { + private constructor OldMod() + 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 mod(/*0*/ x: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/operatorRem/noDeprecatedModConventionWithoutFeature.kt b/compiler/testData/diagnostics/tests/operatorRem/noDeprecatedModConventionWithoutFeature.kt new file mode 100644 index 00000000000..c8b3a80504f --- /dev/null +++ b/compiler/testData/diagnostics/tests/operatorRem/noDeprecatedModConventionWithoutFeature.kt @@ -0,0 +1,38 @@ +// !LANGUAGE: -OperatorRem +// !DIAGNOSTICS: -UNUSED_PARAMETER + +object ModAndRem { + operator fun mod(x: Int) {} + operator fun rem(x: Int) {} +} + +object OldMod { + operator fun mod(x: Int) {} +} + +object ModAndRemExtension +operator fun ModAndRemExtension.mod(x: Int) {} +operator fun ModAndRemExtension.rem(x: Int) {} + +object ModExtension +operator fun ModExtension.mod(x: Int) {} + +object ModMemberAndRemExtension { + operator fun mod(x: Int) {} +} + +operator fun ModMemberAndRemExtension.rem(x: Int) {} + +fun foo() { + ModAndRem % 1 + OldMod % 1 + + ModAndRemExtension % 1 + + ModExtension % 1 + + ModMemberAndRemExtension % 1 + + OldMod.mod(1) + ModExtension.mod(1) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/operatorRem/noDeprecatedModConventionWithoutFeature.txt b/compiler/testData/diagnostics/tests/operatorRem/noDeprecatedModConventionWithoutFeature.txt new file mode 100644 index 00000000000..2a30499e505 --- /dev/null +++ b/compiler/testData/diagnostics/tests/operatorRem/noDeprecatedModConventionWithoutFeature.txt @@ -0,0 +1,46 @@ +package + +public fun foo(): kotlin.Unit +public operator fun ModAndRemExtension.mod(/*0*/ x: kotlin.Int): kotlin.Unit +public operator fun ModExtension.mod(/*0*/ x: kotlin.Int): kotlin.Unit +public operator fun ModAndRemExtension.rem(/*0*/ x: kotlin.Int): kotlin.Unit +public operator fun ModMemberAndRemExtension.rem(/*0*/ x: kotlin.Int): kotlin.Unit + +public object ModAndRem { + private constructor ModAndRem() + 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 mod(/*0*/ x: kotlin.Int): kotlin.Unit + public final operator fun rem(/*0*/ x: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public object ModAndRemExtension { + private constructor ModAndRemExtension() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public object ModExtension { + private constructor ModExtension() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public object ModMemberAndRemExtension { + private constructor ModMemberAndRemExtension() + 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 mod(/*0*/ x: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public object OldMod { + private constructor OldMod() + 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 mod(/*0*/ x: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/operatorRem/preferRemAsExtentionOverMod.kt b/compiler/testData/diagnostics/tests/operatorRem/preferRemAsExtentionOverMod.kt index 7677efcc85d..cd52302413d 100644 --- a/compiler/testData/diagnostics/tests/operatorRem/preferRemAsExtentionOverMod.kt +++ b/compiler/testData/diagnostics/tests/operatorRem/preferRemAsExtentionOverMod.kt @@ -2,7 +2,7 @@ class Foo { } -operator fun Foo.mod(x: Int): Foo = Foo() +operator fun Foo.mod(x: Int): Foo = Foo() operator fun Foo.rem(x: Int): Int = 0 fun foo() { diff --git a/compiler/testData/diagnostics/tests/operatorRem/preferRemAsMemberOverMod.kt b/compiler/testData/diagnostics/tests/operatorRem/preferRemAsMemberOverMod.kt index 71454a2abcc..f95d48cb00c 100644 --- a/compiler/testData/diagnostics/tests/operatorRem/preferRemAsMemberOverMod.kt +++ b/compiler/testData/diagnostics/tests/operatorRem/preferRemAsMemberOverMod.kt @@ -1,7 +1,7 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER class Foo { - operator fun mod(x: Int): Foo = Foo() + operator fun mod(x: Int): Foo = Foo() operator fun rem(x: Int): Int = 0 } diff --git a/compiler/testData/diagnostics/tests/operatorRem/prefereRemAsExtensionOverMemberMod.kt b/compiler/testData/diagnostics/tests/operatorRem/prefereRemAsExtensionOverMemberMod.kt index 4f882d9216a..156e65e2e3e 100644 --- a/compiler/testData/diagnostics/tests/operatorRem/prefereRemAsExtensionOverMemberMod.kt +++ b/compiler/testData/diagnostics/tests/operatorRem/prefereRemAsExtensionOverMemberMod.kt @@ -1,7 +1,7 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER class Foo { - operator fun mod(x: Int): Foo = Foo() + operator fun mod(x: Int): Foo = Foo() } operator fun Foo.rem(x: Int): Int = 0 diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/AssignmentOperations.kt b/compiler/testData/diagnostics/tests/operatorsOverloading/AssignmentOperations.kt index 075d1b981fb..cce99f1021f 100644 --- a/compiler/testData/diagnostics/tests/operatorsOverloading/AssignmentOperations.kt +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/AssignmentOperations.kt @@ -3,7 +3,7 @@ class A { operator fun minusAssign(x: Int) {} operator fun timesAssign(x: Int) {} operator fun divAssign(x: Int) {} - operator fun modAssign(x: Int) {} + operator fun remAssign(x: Int) {} } fun testVal() { @@ -28,7 +28,7 @@ class B { operator fun minus(x: Int): B = B() operator fun times(x: Int): B = B() operator fun div(x: Int): B = B() - operator fun mod(x: Int): B = B() + operator fun rem(x: Int): B = B() } fun testWrong() { diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/AssignmentOperations.txt b/compiler/testData/diagnostics/tests/operatorsOverloading/AssignmentOperations.txt index f2a070f9cf7..03b2100e401 100644 --- a/compiler/testData/diagnostics/tests/operatorsOverloading/AssignmentOperations.txt +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/AssignmentOperations.txt @@ -10,8 +10,8 @@ public final class A { 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 minusAssign(/*0*/ x: kotlin.Int): kotlin.Unit - public final operator fun modAssign(/*0*/ x: kotlin.Int): kotlin.Unit public final operator fun plusAssign(/*0*/ x: kotlin.Int): kotlin.Unit + public final operator fun remAssign(/*0*/ x: kotlin.Int): kotlin.Unit public final operator fun timesAssign(/*0*/ x: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } @@ -22,8 +22,8 @@ public final class B { 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 minus(/*0*/ x: kotlin.Int): B - public final operator fun mod(/*0*/ x: kotlin.Int): B public final operator fun plus(/*0*/ x: kotlin.Int): B + public final operator fun rem(/*0*/ x: kotlin.Int): B public final operator fun times(/*0*/ x: kotlin.Int): B public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/regressions/kt629.kt b/compiler/testData/diagnostics/tests/regressions/kt629.kt index 188b68b2e21..57e89c2e4e4 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt629.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt629.kt @@ -4,7 +4,7 @@ package kt629 class A() { var p = "yeah" - operator fun mod(other : A) : A { + operator fun rem(other : A) : A { return A(); } } diff --git a/compiler/testData/diagnostics/tests/regressions/kt629.txt b/compiler/testData/diagnostics/tests/regressions/kt629.txt index 27a69640167..0e1020eee29 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt629.txt +++ b/compiler/testData/diagnostics/tests/regressions/kt629.txt @@ -9,7 +9,7 @@ package kt629 { public final var p: kotlin.String 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 mod(/*0*/ other: kt629.A): kt629.A + public final operator fun rem(/*0*/ other: kt629.A): kt629.A public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 524bc08dcda..6e15ae340ac 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -13336,6 +13336,18 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/operatorRem"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } + @TestMetadata("deprecatedModConvention.kt") + public void testDeprecatedModConvention() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/deprecatedModConvention.kt"); + doTest(fileName); + } + + @TestMetadata("noDeprecatedModConventionWithoutFeature.kt") + public void testNoDeprecatedModConventionWithoutFeature() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/noDeprecatedModConventionWithoutFeature.kt"); + doTest(fileName); + } + @TestMetadata("noOperatorRemFeature.kt") public void testNoOperatorRemFeature() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/noOperatorRemFeature.kt");