Files
kotlin-fork/compiler/testData/diagnostics/tests/DeprecatedModAssignOperatorConventions.kt
T
Mikhail Zarechenskiy 97ca51381a Gradual migration of operator 'mod' to 'rem'
- Introduce new 'rem' operator convention
 - Prefer 'rem()' to 'mod()' when both are available, even if mod() is a
   member, and rem() -- an extension
 - Place operator 'rem' under the language feature
2016-12-09 16:43:35 +03:00

41 lines
777 B
Kotlin
Vendored

// !DIAGNOSTICS: -UNUSED_PARAMETER
class OldAndNew {
operator fun modAssign(x: Int) {}
operator fun remAssign(x: Int) {}
}
class OnlyOld {
operator fun modAssign(x: Int) {}
}
class OnlyNew {
operator fun remAssign(x: Int) {}
}
class Sample
operator fun Sample.modAssign(x: Int) {}
operator fun Sample.remAssign(x: Int) {}
class ModAndRemAssign {
operator fun mod(x: Int): ModAndRemAssign = ModAndRemAssign()
operator fun remAssign(x: Int) {}
}
fun test() {
val oldAndNew = OldAndNew()
oldAndNew %= 1
val onlyOld = OnlyOld()
onlyOld %= 1
val onlyNew = OnlyNew()
onlyNew %= 1
val sample = Sample()
sample %= 1
var modAndRemAssign = ModAndRemAssign()
modAndRemAssign <!ASSIGN_OPERATOR_AMBIGUITY!>%=<!> 1
}