Additional tests on mod/rem migration
This commit is contained in:
+1
-1
@@ -37,5 +37,5 @@ fun test() {
|
||||
sample %= 1
|
||||
|
||||
var modAndRemAssign = ModAndRemAssign()
|
||||
modAndRemAssign <!ASSIGN_OPERATOR_AMBIGUITY!>%=<!> 1
|
||||
modAndRemAssign %= 1
|
||||
}
|
||||
+3
-3
@@ -19,8 +19,8 @@ class Sample
|
||||
operator fun Sample.rem(x: Int) {}
|
||||
|
||||
class IntAndUnit {
|
||||
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(x: Int): Int = 0
|
||||
operator fun rem(x: Int) {}
|
||||
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(x: Int) = 0
|
||||
operator fun rem(x: Int): Int = 0
|
||||
}
|
||||
|
||||
fun test() {
|
||||
@@ -29,7 +29,7 @@ fun test() {
|
||||
OnlyNew() % 1
|
||||
Sample() % 1
|
||||
|
||||
takeInt(<!TYPE_MISMATCH!>IntAndUnit() % 1<!>)
|
||||
takeInt(IntAndUnit() % 1)
|
||||
}
|
||||
|
||||
fun takeInt(x: Int) {}
|
||||
+1
-1
@@ -10,7 +10,7 @@ public final class IntAndUnit {
|
||||
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.Int
|
||||
public final operator fun rem(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public final operator fun rem(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
object OldMod {
|
||||
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(x: Int) {}
|
||||
}
|
||||
|
||||
object RemExtension
|
||||
operator fun RemExtension.rem(x: Int) {}
|
||||
|
||||
fun foo() {
|
||||
OldMod <!DEPRECATED_BINARY_MOD_AS_REM!>%<!> 123
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public fun foo(): kotlin.Unit
|
||||
public operator fun RemExtension.rem(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
public object RemExtension {
|
||||
private constructor RemExtension()
|
||||
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
|
||||
}
|
||||
@@ -9,8 +9,16 @@ class Bar {
|
||||
<!UNSUPPORTED_FEATURE!>operator<!> fun remAssign(x: Int) {}
|
||||
}
|
||||
|
||||
fun baz() {
|
||||
val f = Foo() % 1
|
||||
val b = Bar()
|
||||
b %= 1
|
||||
class Baz {
|
||||
companion object {
|
||||
<!UNSUPPORTED_FEATURE!>operator<!> fun rem(x: Int) {}
|
||||
<!UNSUPPORTED_FEATURE!>operator<!> fun Int.rem(x: Int) {}
|
||||
}
|
||||
}
|
||||
|
||||
<!UNSUPPORTED_FEATURE!>operator<!> fun Baz.rem(x: Int) {}
|
||||
|
||||
fun local() {
|
||||
<!UNSUPPORTED_FEATURE!>operator<!> fun Int.rem(x: Int) {}
|
||||
<!UNSUPPORTED_FEATURE!>operator<!> fun String.remAssign(x: Int) {}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package
|
||||
|
||||
public fun baz(): kotlin.Unit
|
||||
public fun local(): kotlin.Unit
|
||||
public operator fun Baz.rem(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
|
||||
public final class Bar {
|
||||
public constructor Bar()
|
||||
@@ -10,6 +11,22 @@ public final class Bar {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Baz {
|
||||
public constructor Baz()
|
||||
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 companion object Companion {
|
||||
private constructor Companion()
|
||||
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 rem(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public final operator fun kotlin.Int.rem(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
}
|
||||
}
|
||||
|
||||
public final class Foo {
|
||||
public constructor Foo()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class A {
|
||||
companion object {
|
||||
operator fun A.rem(x: Int) = 0
|
||||
}
|
||||
|
||||
fun test() {
|
||||
<!DEPRECATED_BINARY_MOD!>operator<!> fun A.mod(x: Int) = ""
|
||||
|
||||
takeInt(A() % 123)
|
||||
}
|
||||
}
|
||||
|
||||
fun takeInt(x: Int) {}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public fun takeInt(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor 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 fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
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 final operator fun A.rem(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
object B
|
||||
|
||||
class A {
|
||||
operator fun B.rem(x: Int) = 0
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
<!DEPRECATED_BINARY_MOD!>operator<!> fun B.mod(x: Int) = ""
|
||||
|
||||
with(A()) {
|
||||
takeInt(B % 10)
|
||||
}
|
||||
}
|
||||
|
||||
class C {
|
||||
<!DEPRECATED_BINARY_MOD!>operator<!> fun B.mod(x: Int) = ""
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
operator fun B.rem(x: Int) = 0
|
||||
|
||||
with(C()) {
|
||||
takeInt(B % 10)
|
||||
}
|
||||
}
|
||||
|
||||
fun takeInt(x: Int) {}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package
|
||||
|
||||
public fun takeInt(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public fun test1(): kotlin.Unit
|
||||
public fun test2(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public final operator fun B.rem(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
}
|
||||
|
||||
public object B {
|
||||
private constructor 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class C {
|
||||
public constructor C()
|
||||
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 final operator fun B.mod(/*0*/ x: kotlin.Int): kotlin.String
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class A {
|
||||
<!DEPRECATED_BINARY_MOD!>operator<!> fun Int.mod(s: String) = 4
|
||||
}
|
||||
|
||||
class B {
|
||||
operator fun Int.rem(s: String) = ""
|
||||
}
|
||||
|
||||
fun test() {
|
||||
with(B()) {
|
||||
with(A()) {
|
||||
takeString(1 % "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun takeString(s: String) {}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package
|
||||
|
||||
public fun takeString(/*0*/ s: kotlin.String): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public final operator fun kotlin.Int.mod(/*0*/ s: kotlin.String): kotlin.Int
|
||||
}
|
||||
|
||||
public final class B {
|
||||
public constructor 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public final operator fun kotlin.Int.rem(/*0*/ s: kotlin.String): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
object A {
|
||||
@Deprecated("Use mod instead", ReplaceWith("mod"), DeprecationLevel.HIDDEN)
|
||||
operator fun rem(x: Int) = 0
|
||||
|
||||
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(x: Int) = ""
|
||||
}
|
||||
|
||||
fun test() {
|
||||
takeString(A <!DEPRECATED_BINARY_MOD_AS_REM!>%<!> 123)
|
||||
}
|
||||
|
||||
fun takeString(s: String) {}
|
||||
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public fun takeString(/*0*/ s: kotlin.String): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public object A {
|
||||
private constructor 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 mod(/*0*/ x: kotlin.Int): kotlin.String
|
||||
@kotlin.Deprecated(level = DeprecationLevel.HIDDEN, message = "Use mod instead", replaceWith = kotlin.ReplaceWith(expression = "mod", imports = {})) public final operator fun rem(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -206,18 +206,6 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DeprecatedModAssignOperatorConventions.kt")
|
||||
public void testDeprecatedModAssignOperatorConventions() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/DeprecatedModAssignOperatorConventions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DeprecatedModOperatorConventions.kt")
|
||||
public void testDeprecatedModOperatorConventions() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/DeprecatedModOperatorConventions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DeprecatedUnaryOperatorConventions.kt")
|
||||
public void testDeprecatedUnaryOperatorConventions() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/DeprecatedUnaryOperatorConventions.kt");
|
||||
@@ -13336,12 +13324,30 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/operatorRem"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("DeprecatedModAssignOperatorConventions.kt")
|
||||
public void testDeprecatedModAssignOperatorConventions() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/DeprecatedModAssignOperatorConventions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("deprecatedModConvention.kt")
|
||||
public void testDeprecatedModConvention() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/deprecatedModConvention.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DeprecatedModOperatorConventions.kt")
|
||||
public void testDeprecatedModOperatorConventions() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/DeprecatedModOperatorConventions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("doNotResolveToInapplicableRem.kt")
|
||||
public void testDoNotResolveToInapplicableRem() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/doNotResolveToInapplicableRem.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noDeprecatedModConventionWithoutFeature.kt")
|
||||
public void testNoDeprecatedModConventionWithoutFeature() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/noDeprecatedModConventionWithoutFeature.kt");
|
||||
@@ -13372,11 +13378,59 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("preferRemFromCompanionObjectOverRem.kt")
|
||||
public void testPreferRemFromCompanionObjectOverRem() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/preferRemFromCompanionObjectOverRem.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("preferRemOverModInLocalFunctions.kt")
|
||||
public void testPreferRemOverModInLocalFunctions() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/preferRemOverModInLocalFunctions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("preferRemWithImplicitReceivers.kt")
|
||||
public void testPreferRemWithImplicitReceivers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/preferRemWithImplicitReceivers.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("prefereRemAsExtensionOverMemberMod.kt")
|
||||
public void testPrefereRemAsExtensionOverMemberMod() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/prefereRemAsExtensionOverMemberMod.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("remAndRemAssignAmbiguity.kt")
|
||||
public void testRemAndRemAssignAmbiguity() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/remAndRemAssignAmbiguity.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("remWithModAndModAssign.kt")
|
||||
public void testRemWithModAndModAssign() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/remWithModAndModAssign.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("remWithModAssign.kt")
|
||||
public void testRemWithModAssign() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/remWithModAssign.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("resolveModIfRemIsHidden.kt")
|
||||
public void testResolveModIfRemIsHidden() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/resolveModIfRemIsHidden.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("resolveToModWhenNoOperatorRemFeature.kt")
|
||||
public void testResolveToModWhenNoOperatorRemFeature() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/operatorRem/resolveToModWhenNoOperatorRemFeature.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/operatorsOverloading")
|
||||
|
||||
Reference in New Issue
Block a user