Shorten References: Fix removal of explicit companion references in the position of callee expression

#KT-10102
This commit is contained in:
Alexey Sedunov
2015-11-27 16:04:53 +03:00
parent 2dcc38b92f
commit 44bc937499
12 changed files with 131 additions and 1 deletions
@@ -0,0 +1,11 @@
interface Factory {
operator fun invoke(i: Int): IntPredicate
companion object {
inline operator fun invoke(crossinline f: (Int) -> IntPredicate) = object : Factory {
override fun invoke(i: Int) = f(i)
}
}
}
<selection>fun foo(): Factory = Factory.Companion { k -> IntPredicate { n -> n % k == 0 } }</selection>
@@ -0,0 +1,11 @@
interface Factory {
operator fun invoke(i: Int): IntPredicate
companion object {
inline operator fun invoke(crossinline f: (Int) -> IntPredicate) = object : Factory {
override fun invoke(i: Int) = f(i)
}
}
}
fun foo(): Factory = Factory { k -> IntPredicate { n -> n % k == 0 } }
@@ -0,0 +1,13 @@
class T {
interface Factory {
operator fun invoke(i: Int): IntPredicate
companion object {
inline operator fun invoke(crossinline f: (Int) -> IntPredicate) = object : Factory {
override fun invoke(i: Int) = f(i)
}
}
}
}
<selection>fun foo(): T.Factory = T.Factory.Companion { k -> IntPredicate { n -> n % k == 0 } }</selection>
@@ -0,0 +1,13 @@
class T {
interface Factory {
operator fun invoke(i: Int): IntPredicate
companion object {
inline operator fun invoke(crossinline f: (Int) -> IntPredicate) = object : Factory {
override fun invoke(i: Int) = f(i)
}
}
}
}
fun foo(): T.Factory = T.Factory { k -> IntPredicate { n -> n % k == 0 } }