Diagnostics on 'infix' (declaration&use site)

This commit is contained in:
Yan Zhulanow
2015-09-29 19:22:28 +03:00
parent fff434d377
commit 1238e93b9f
11 changed files with 240 additions and 5 deletions
+26
View File
@@ -0,0 +1,26 @@
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)
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 <!INFIX_MODIFIER_REQUIRED!>withLambda<!> { }
}