J2K: convert method references according to special methods

This commit is contained in:
Natalia Ukhorskaya
2016-01-21 13:37:55 +03:00
parent 25b64b198c
commit 9d66852ae2
3 changed files with 43 additions and 12 deletions
@@ -1,4 +1,4 @@
// ERROR: Type inference failed: Not enough information to infer parameter T in fun <T : kotlin.Any!> emptyList(): kotlin.collections.(Mutable)List<T!>! Please specify it explicitly.
// ERROR: Type inference failed: Not enough information to infer parameter T in fun <T> emptyList(): kotlin.collections.List<T> Please specify it explicitly.
package test
import java.util.Collections
@@ -72,7 +72,7 @@ internal class Java8Class {
}
fun testLibraryFunctions() {
val memberFunFromClass = { obj: String -> obj.length() }
val memberFunFromClass = { obj: String -> obj.length }
memberFunFromClass.invoke("str")
}
@@ -85,7 +85,7 @@ internal class Java8Class {
}
fun testGenericFunctions() {
val emptyList = { Collections.emptyList() }
val emptyList = { emptyList() }
emptyList.invoke()
}
@@ -117,11 +117,11 @@ internal class Java8Class {
}
fun testLibraryFunctions() {
val memberFunFromClass = JFunction2<String, Int> { it.length() }
val memberFunFromClass = JFunction2<String, Int> { it.length }
memberFunFromClass.foo("str")
Thread(Runnable { System.out.println() }).start()
Runnable { System.out.println() }.run()
Thread(Runnable { println() }).start()
Runnable { println() }.run()
}
fun testOverloads() {
@@ -137,10 +137,10 @@ internal class Java8Class {
}
fun testGenericFunctions() {
val emptyList = JFunction1<List<String>> { Collections.emptyList() }
val emptyList = JFunction1<List<String>> { emptyList() }
emptyList.foo()
MethodReferenceHelperClass.staticFun1(JFunction1<List<String>> { Collections.emptyList() })
h.memberFun1(JFunction1<List<String>> { Collections.emptyList() })
MethodReferenceHelperClass.staticFun1(JFunction1<List<String>> { emptyList() })
h.memberFun1(JFunction1<List<String>> { emptyList() })
}
fun memberFun(): Int {