Supported unit return type functions

This commit is contained in:
Valentin Kipyatkov
2016-10-24 23:21:17 +03:00
parent 152e77bad3
commit 4c4c85e37a
16 changed files with 191 additions and 34 deletions
@@ -0,0 +1,14 @@
fun <caret>f(p1: Int, p2: Int) {
}
fun <T> doIt(p: () -> T): T = TODO()
fun g(p: String?) {
f(1, 2)
p?.let { f(3, 4) }
}
fun h() = f(5, 6)
fun x() = doIt { f(7, 8) }
@@ -0,0 +1,10 @@
fun <T> doIt(p: () -> T): T = TODO()
fun g(p: String?) {
p?.let { }
}
fun h() = Unit
fun x() = doIt { }
@@ -0,0 +1,20 @@
class C {
fun <caret>f(p1: Int, p2: Int) {
println(p1)
println(p2)
}
fun <T> doIt(p: () -> T): T = TODO()
fun g(p: String?, other: C) {
f(1, 2)
p?.let { f(3, 4) }
other?.f(5, 6)
}
fun h() = f(7, 8)
fun x() = doIt { f(9, 10) }
}
@@ -0,0 +1,29 @@
class C {
fun <T> doIt(p: () -> T): T = TODO()
fun g(p: String?, other: C) {
println(1)
println(2)
p?.let {
println(3)
println(4)
}
if (other != null) {
println(5)
println(6)
}
}
fun h() {
println(7)
println(8)
}
fun x() = doIt {
println(9)
println(10)
}
}
@@ -0,0 +1,25 @@
fun nonUnit(p: Int): Int = p
fun <T> doIt(p: () -> T): T = TODO()
fun g(p: String?) {
println(1)
nonUnit(2)
p?.let {
println(3)
nonUnit(4)
Unit
}
}
fun h() {
println(5)
nonUnit(6)
}
fun x() = doIt {
println(7)
nonUnit(8)
Unit
}
@@ -0,0 +1,18 @@
fun <caret>f(p1: Int, p2: Int) {
println(p1)
nonUnit(p2)
}
fun nonUnit(p: Int): Int = p
fun <T> doIt(p: () -> T): T = TODO()
fun g(p: String?) {
f(1, 2)
p?.let { f(3, 4) }
}
fun h() = f(5, 6)
fun x() = doIt { f(7, 8) }