Add warnings at declaration and call sites of operator 'mod'
This commit is contained in:
@@ -629,6 +629,9 @@ public interface Errors {
|
|||||||
|
|
||||||
// Conventions
|
// Conventions
|
||||||
|
|
||||||
|
DiagnosticFactory2<PsiElement, FunctionDescriptor, String> DEPRECATED_BINARY_MOD = DiagnosticFactory2.create(WARNING);
|
||||||
|
DiagnosticFactory2<PsiElement, FunctionDescriptor, String> DEPRECATED_BINARY_MOD_AS_REM = DiagnosticFactory2.create(WARNING);
|
||||||
|
|
||||||
DiagnosticFactory0<KtArrayAccessExpression> NO_GET_METHOD = DiagnosticFactory0.create(ERROR, ARRAY_ACCESS);
|
DiagnosticFactory0<KtArrayAccessExpression> NO_GET_METHOD = DiagnosticFactory0.create(ERROR, ARRAY_ACCESS);
|
||||||
DiagnosticFactory0<KtArrayAccessExpression> NO_SET_METHOD = DiagnosticFactory0.create(ERROR, ARRAY_ACCESS);
|
DiagnosticFactory0<KtArrayAccessExpression> NO_SET_METHOD = DiagnosticFactory0.create(ERROR, ARRAY_ACCESS);
|
||||||
|
|
||||||
|
|||||||
+3
@@ -354,6 +354,9 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(LOCAL_VARIABLE_WITH_SETTER, "Local variables are not allowed to have setters");
|
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(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_GET_METHOD, "No get method providing array access");
|
||||||
MAP.put(NO_SET_METHOD, "No set method providing array access");
|
MAP.put(NO_SET_METHOD, "No set method providing array access");
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ object OperatorModifierChecker {
|
|||||||
|
|
||||||
val checkResult = OperatorChecks.check(functionDescriptor)
|
val checkResult = OperatorChecks.check(functionDescriptor)
|
||||||
if (checkResult.isSuccess) {
|
if (checkResult.isSuccess) {
|
||||||
|
val shouldUseOperatorRem = languageVersionSettings.supportsFeature(LanguageFeature.OperatorRem)
|
||||||
when (functionDescriptor.name) {
|
when (functionDescriptor.name) {
|
||||||
in COROUTINE_OPERATOR_NAMES -> {
|
in COROUTINE_OPERATOR_NAMES -> {
|
||||||
if (!languageVersionSettings.supportsFeature(LanguageFeature.Coroutines)) {
|
if (!languageVersionSettings.supportsFeature(LanguageFeature.Coroutines)) {
|
||||||
@@ -50,12 +51,17 @@ object OperatorModifierChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
in REM_TO_MOD_OPERATION_NAMES.keys -> {
|
in REM_TO_MOD_OPERATION_NAMES.keys -> {
|
||||||
if (!languageVersionSettings.supportsFeature(LanguageFeature.OperatorRem)) {
|
if (!shouldUseOperatorRem) {
|
||||||
diagnosticHolder.report(Errors.UNSUPPORTED_FEATURE.on(modifier, LanguageFeature.OperatorRem))
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.resolve.calls.checkers
|
package org.jetbrains.kotlin.resolve.calls.checkers
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors
|
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.calls.tasks.isDynamic
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils
|
import org.jetbrains.kotlin.types.ErrorUtils
|
||||||
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
|
|
||||||
class OperatorCallChecker : CallChecker {
|
class OperatorCallChecker : CallChecker {
|
||||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||||
@@ -58,6 +60,15 @@ class OperatorCallChecker : CallChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val isConventionOperator = element is KtOperationReferenceExpression && element.isConventionOperator()
|
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 (isConventionOperator || element is KtArrayAccessExpression) {
|
||||||
if (!functionDescriptor.isOperator) {
|
if (!functionDescriptor.isOperator) {
|
||||||
report(reportOn, functionDescriptor, context.trace)
|
report(reportOn, functionDescriptor, context.trace)
|
||||||
|
|||||||
+5
-5
@@ -1,12 +1,12 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
class OldAndNew {
|
class OldAndNew {
|
||||||
operator fun modAssign(x: Int) {}
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun modAssign(x: Int) {}
|
||||||
operator fun remAssign(x: Int) {}
|
operator fun remAssign(x: Int) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OnlyOld {
|
class OnlyOld {
|
||||||
operator fun modAssign(x: Int) {}
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun modAssign(x: Int) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OnlyNew {
|
class OnlyNew {
|
||||||
@@ -15,11 +15,11 @@ class OnlyNew {
|
|||||||
|
|
||||||
class Sample
|
class Sample
|
||||||
|
|
||||||
operator fun Sample.modAssign(x: Int) {}
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun Sample.modAssign(x: Int) {}
|
||||||
operator fun Sample.remAssign(x: Int) {}
|
operator fun Sample.remAssign(x: Int) {}
|
||||||
|
|
||||||
class ModAndRemAssign {
|
class ModAndRemAssign {
|
||||||
operator fun mod(x: Int): ModAndRemAssign = ModAndRemAssign()
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(x: Int): ModAndRemAssign = ModAndRemAssign()
|
||||||
operator fun remAssign(x: Int) {}
|
operator fun remAssign(x: Int) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ fun test() {
|
|||||||
oldAndNew %= 1
|
oldAndNew %= 1
|
||||||
|
|
||||||
val onlyOld = OnlyOld()
|
val onlyOld = OnlyOld()
|
||||||
onlyOld %= 1
|
onlyOld <!DEPRECATED_BINARY_MOD_AS_REM!>%=<!> 1
|
||||||
|
|
||||||
val onlyNew = OnlyNew()
|
val onlyNew = OnlyNew()
|
||||||
onlyNew %= 1
|
onlyNew %= 1
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
class OldAndNew {
|
class OldAndNew {
|
||||||
operator fun mod(x: Int) {}
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(x: Int) {}
|
||||||
operator fun rem(x: Int) {}
|
operator fun rem(x: Int) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OnlyOld {
|
class OnlyOld {
|
||||||
operator fun mod(x: Int) {}
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(x: Int) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OnlyNew {
|
class OnlyNew {
|
||||||
@@ -15,17 +15,17 @@ class OnlyNew {
|
|||||||
|
|
||||||
class Sample
|
class Sample
|
||||||
|
|
||||||
operator fun Sample.mod(x: Int) {}
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun Sample.mod(x: Int) {}
|
||||||
operator fun Sample.rem(x: Int) {}
|
operator fun Sample.rem(x: Int) {}
|
||||||
|
|
||||||
class IntAndUnit {
|
class IntAndUnit {
|
||||||
operator fun mod(x: Int): Int = 0
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(x: Int): Int = 0
|
||||||
operator fun rem(x: Int) {}
|
operator fun rem(x: Int) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
OldAndNew() % 1
|
OldAndNew() % 1
|
||||||
OnlyOld() % 1
|
OnlyOld() <!DEPRECATED_BINARY_MOD_AS_REM!>%<!> 1
|
||||||
OnlyNew() % 1
|
OnlyNew() % 1
|
||||||
Sample() % 1
|
Sample() % 1
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
object ModAndRem {
|
||||||
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(x: Int) {}
|
||||||
|
operator fun rem(x: Int) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
object OldMod {
|
||||||
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(x: Int) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
object ModAndRemExtension
|
||||||
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun ModAndRemExtension.mod(x: Int) {}
|
||||||
|
operator fun ModAndRemExtension.rem(x: Int) {}
|
||||||
|
|
||||||
|
object ModExtension
|
||||||
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun ModExtension.mod(x: Int) {}
|
||||||
|
|
||||||
|
object ModMemberAndRemExtension {
|
||||||
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(x: Int) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun ModMemberAndRemExtension.rem(x: Int) {}
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
ModAndRem % 1
|
||||||
|
OldMod <!DEPRECATED_BINARY_MOD_AS_REM!>%<!> 1
|
||||||
|
|
||||||
|
ModAndRemExtension % 1
|
||||||
|
|
||||||
|
ModExtension <!DEPRECATED_BINARY_MOD_AS_REM!>%<!> 1
|
||||||
|
|
||||||
|
ModMemberAndRemExtension % 1
|
||||||
|
|
||||||
|
OldMod.mod(1)
|
||||||
|
ModExtension.mod(1)
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
// !LANGUAGE: -OperatorRem
|
||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
object ModAndRem {
|
||||||
|
operator fun mod(x: Int) {}
|
||||||
|
<!UNSUPPORTED_FEATURE!>operator<!> fun rem(x: Int) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
object OldMod {
|
||||||
|
operator fun mod(x: Int) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
object ModAndRemExtension
|
||||||
|
operator fun ModAndRemExtension.mod(x: Int) {}
|
||||||
|
<!UNSUPPORTED_FEATURE!>operator<!> fun ModAndRemExtension.rem(x: Int) {}
|
||||||
|
|
||||||
|
object ModExtension
|
||||||
|
operator fun ModExtension.mod(x: Int) {}
|
||||||
|
|
||||||
|
object ModMemberAndRemExtension {
|
||||||
|
operator fun mod(x: Int) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
<!UNSUPPORTED_FEATURE!>operator<!> fun ModMemberAndRemExtension.rem(x: Int) {}
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
ModAndRem % 1
|
||||||
|
OldMod % 1
|
||||||
|
|
||||||
|
ModAndRemExtension % 1
|
||||||
|
|
||||||
|
ModExtension % 1
|
||||||
|
|
||||||
|
ModMemberAndRemExtension % 1
|
||||||
|
|
||||||
|
OldMod.mod(1)
|
||||||
|
ModExtension.mod(1)
|
||||||
|
}
|
||||||
Vendored
+46
@@ -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
|
||||||
|
}
|
||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
class Foo {
|
class Foo {
|
||||||
}
|
}
|
||||||
operator fun Foo.mod(x: Int): Foo = Foo()
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun Foo.mod(x: Int): Foo = Foo()
|
||||||
operator fun Foo.rem(x: Int): Int = 0
|
operator fun Foo.rem(x: Int): Int = 0
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
class Foo {
|
class Foo {
|
||||||
operator fun mod(x: Int): Foo = Foo()
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(x: Int): Foo = Foo()
|
||||||
operator fun rem(x: Int): Int = 0
|
operator fun rem(x: Int): Int = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
class Foo {
|
class Foo {
|
||||||
operator fun mod(x: Int): Foo = Foo()
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(x: Int): Foo = Foo()
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun Foo.rem(x: Int): Int = 0
|
operator fun Foo.rem(x: Int): Int = 0
|
||||||
|
|||||||
+2
-2
@@ -3,7 +3,7 @@ class A {
|
|||||||
operator fun minusAssign(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
operator fun minusAssign(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||||
operator fun timesAssign(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
operator fun timesAssign(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||||
operator fun divAssign(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
operator fun divAssign(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||||
operator fun modAssign(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
operator fun remAssign(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testVal() {
|
fun testVal() {
|
||||||
@@ -28,7 +28,7 @@ class B {
|
|||||||
operator fun minus(<!UNUSED_PARAMETER!>x<!>: Int): B = B()
|
operator fun minus(<!UNUSED_PARAMETER!>x<!>: Int): B = B()
|
||||||
operator fun times(<!UNUSED_PARAMETER!>x<!>: Int): B = B()
|
operator fun times(<!UNUSED_PARAMETER!>x<!>: Int): B = B()
|
||||||
operator fun div(<!UNUSED_PARAMETER!>x<!>: Int): B = B()
|
operator fun div(<!UNUSED_PARAMETER!>x<!>: Int): B = B()
|
||||||
operator fun mod(<!UNUSED_PARAMETER!>x<!>: Int): B = B()
|
operator fun rem(<!UNUSED_PARAMETER!>x<!>: Int): B = B()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testWrong() {
|
fun testWrong() {
|
||||||
|
|||||||
+2
-2
@@ -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 equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
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 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 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 final operator fun timesAssign(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
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 equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public final operator fun minus(/*0*/ x: kotlin.Int): B
|
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 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 final operator fun times(/*0*/ x: kotlin.Int): B
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ package kt629
|
|||||||
|
|
||||||
class A() {
|
class A() {
|
||||||
var p = "yeah"
|
var p = "yeah"
|
||||||
operator fun mod(<!UNUSED_PARAMETER!>other<!> : A) : A {
|
operator fun rem(<!UNUSED_PARAMETER!>other<!> : A) : A {
|
||||||
return A();
|
return A();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ package kt629 {
|
|||||||
public final var p: kotlin.String
|
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 equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
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
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
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")
|
@TestMetadata("noOperatorRemFeature.kt")
|
||||||
public void testNoOperatorRemFeature() throws Exception {
|
public void testNoOperatorRemFeature() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/noOperatorRemFeature.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/noOperatorRemFeature.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user