Files
kotlin-fork/compiler/testData/diagnostics/tests/operatorRem/DeprecatedModOperatorConventions.fir.kt
T
Nikolay Lunyak e2403c801f [FIR] KT-55747: Report error for operator fun mod
^KT-55747 Fixed

Merge-request: KT-MR-8522
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-01-30 08:48:33 +00:00

37 lines
733 B
Kotlin
Vendored

// !LANGUAGE: -ProhibitOperatorMod
// !DIAGNOSTICS: -UNUSED_PARAMETER
class OldAndNew {
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(x: Int) {}
operator fun rem(x: Int) {}
}
class OnlyOld {
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(x: Int) {}
}
class OnlyNew {
operator fun rem(x: Int) {}
}
class Sample
<!DEPRECATED_BINARY_MOD!>operator<!> fun Sample.mod(x: Int) {}
operator fun Sample.rem(x: Int) {}
class IntAndUnit {
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(x: Int) = 0
operator fun rem(x: Int): Int = 0
}
fun test() {
OldAndNew() % 1
OnlyOld() <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>%<!> 1
OnlyNew() % 1
Sample() % 1
takeInt(IntAndUnit() % 1)
}
fun takeInt(x: Int) {}