Files
kotlin-fork/compiler/testData/diagnostics/tests/Infix.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

39 lines
1.4 KiB
Kotlin
Vendored

class Pair<out A, out B>(val first: A, val second: B)
class Example {
infix fun to(other: Example) = Pair(this, other)
fun toNonInfix(other: Example) = Pair(this, other)
}
infix fun Example.toExt(other: Example) = Pair(this, other)
fun Example.toExtNonInfix(other: Example) = Pair(this, other)
<!INAPPLICABLE_INFIX_MODIFIER!>infix<!> fun Example.toExtWithExtraParams(other: Example, <!UNUSED_PARAMETER!>blah<!>: Int = 0) = Pair(this, other)
fun Example.toExtNonInfixWithExtraParams(other: Example, <!UNUSED_PARAMETER!>blah<!>: Int = 0) = Pair(this, other)
<!INAPPLICABLE_INFIX_MODIFIER!>infix<!> fun Example.toExtDefaultValues(other: Example? = null, <!UNUSED_PARAMETER!>blah<!>: Int = 0) = Pair(this, other)
fun Example.toExtNonInfixDefaultValues(other: Example? = null, <!UNUSED_PARAMETER!>blah<!>: Int = 0) = Pair(this, other)
fun Example.withLambda(f: () -> Unit) = Pair(this, f)
fun test() {
Example() to Example()
Example() <!INFIX_MODIFIER_REQUIRED!>toNonInfix<!> Example()
Example().toNonInfix(Example())
val a = Example()
val b = Example()
a toExt b
a <!INFIX_MODIFIER_REQUIRED!>toExtNonInfix<!> b
a.toExtNonInfix(b)
a toExtWithExtraParams b
a <!INFIX_MODIFIER_REQUIRED!>toExtNonInfixWithExtraParams<!> b
a toExtDefaultValues b
a <!INFIX_MODIFIER_REQUIRED!>toExtNonInfixDefaultValues<!> b
a <!INFIX_MODIFIER_REQUIRED!>withLambda<!> { }
}