Files
kotlin-fork/compiler/testData/diagnostics/tests/DeprecatedUnaryOperatorConventions.kt
T
Denis.Zharkov 2ecba6ac39 Remove WITH_NEW_INFERENCE directive from all tests
This directive anyway does not make test run twice with OI, and with NI
It only once run the test with specific settings (// LANGUAGE)
and ignores irrelevant (OI or NI tags)
2021-05-25 13:28:26 +03:00

33 lines
875 B
Kotlin
Vendored

// !DIAGNOSTICS: -UNUSED_PARAMETER
class Example {
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun plus(): String = ""
operator fun unaryPlus(): Int = 0
}
class ExampleDeprecated {
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun plus(): String = ""
}
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun String.plus(): String = this
operator fun String.unaryPlus(): Int = 0
fun test() {
requireInt(+ "")
requireInt(+ Example())
requireString(<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>+<!> ExampleDeprecated())
}
fun requireInt(n: Int) {}
fun requireString(s: String) {}
class Example2 {
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun plus() = this
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun minus() = this
fun test() {
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>+<!>this
<!UNRESOLVED_REFERENCE!>-<!>this
}
}