Files
kotlin-fork/compiler/testData/diagnostics/tests/InfixModifierApplicability.kt
T
Dmitriy Novozhilov e6b5cb5216 [TD] Update diagnostics test data due to new test runners
Update includes:
- Changing syntax of `OI/`NI` tags from `<!NI;TAG!>` to `<!TAG{NI}!>`
- Fix some incorrect directives
- Change order of diagnostics in some places
- Remove ignored diagnostics from FIR test data (previously `DIAGNOSTICS` didn't work)
- Update FIR dumps in some places and add `FIR_IDENTICAL` if needed
- Replace all JAVAC_SKIP with SKIP_JAVAC directive
2020-12-16 19:52:25 +03:00

28 lines
1.4 KiB
Kotlin
Vendored

// !DIAGNOSTICS: -UNUSED_PARAMETER
class Pair<A, B>(val a: A, val b: B)
infix fun <A, B> A.to(that: B): Pair<A, B> = Pair(this, that)
// OK
infix fun String.ok1(o: String) {}
class OkTest {
infix fun ok2(o: String) {}
infix fun String.ok3(o: String) {}
}
// Errors
<!INAPPLICABLE_INFIX_MODIFIER("must have a single value parameter")!>infix<!> fun String.e1(o: String, o2: String? = null) = o
<!INAPPLICABLE_INFIX_MODIFIER("must have a single value parameter")!>infix<!> fun String.e2(o: String = "", o2: String? = null) = o
<!INAPPLICABLE_INFIX_MODIFIER("must be a member or an extension function")!>infix<!> fun e3() {}
<!INAPPLICABLE_INFIX_MODIFIER("must be a member or an extension function")!>infix<!> fun e4(s: String) {}
<!INAPPLICABLE_INFIX_MODIFIER("must have a single value parameter")!>infix<!> fun String.e5() {}
<!INAPPLICABLE_INFIX_MODIFIER("must have a single value parameter")!>infix<!> fun String.e6(a: Int, b: Int) {}
<!INAPPLICABLE_INFIX_MODIFIER("must be a member or an extension function")!>infix<!> fun e7(a: Int, b: Int) {}
class Example {
<!INAPPLICABLE_INFIX_MODIFIER("must have a single value parameter")!>infix<!> fun e8(s: String, a: Int = 0) {}
<!INAPPLICABLE_INFIX_MODIFIER("must have a single value parameter")!>infix<!> fun e9(s: String, a: Int) {}
<!INAPPLICABLE_INFIX_MODIFIER("must have a single value parameter")!>infix<!> fun e10() {}
}