Pseudocode: Do not generate implicit return instruction inside of
Unit-typed lambdas #KT-5549 Fixed
This commit is contained in:
@@ -60,7 +60,7 @@ fun main1() {
|
||||
1.({Int.() -> 1})()
|
||||
1.(f())()
|
||||
1.if(true){f()}else{f()}()
|
||||
1.if(true){Int.() -> 1}else{f()}()
|
||||
1.if(true){Int.() -> <!UNUSED_EXPRESSION!>1<!>}else{f()}()
|
||||
1.if(true){Int.() -> 1}else{Int.() -> 1}()
|
||||
|
||||
1.<!FUNCTION_EXPECTED!>"sdf"<!>()
|
||||
|
||||
@@ -205,4 +205,4 @@ fun testFunctionLiterals() {
|
||||
object A {}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ fun test() {
|
||||
v1({})
|
||||
v1({}, {})
|
||||
v1({}, <!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>, {})
|
||||
v1({}, {}, {it})
|
||||
v1({}, {}, {<!UNUSED_EXPRESSION!>it<!>})
|
||||
v1({}) <!VARARG_OUTSIDE_PARENTHESES, DANGLING_FUNCTION_LITERAL_ARGUMENT_SUSPECTED!>{}<!>
|
||||
v1 <!VARARG_OUTSIDE_PARENTHESES, DANGLING_FUNCTION_LITERAL_ARGUMENT_SUSPECTED!>{}<!>
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fun main(args: Array<String>) {
|
||||
"".run {
|
||||
<!UNUSED_EXPRESSION!>""<!>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun <T> T.run(f: (T) -> Unit): Unit = f(this)
|
||||
@@ -13,4 +13,4 @@ fun test() {
|
||||
foo({if (1==1);}())
|
||||
|
||||
return if (true);
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -48,13 +48,13 @@ fun test2(): Unit { while(true) {} }
|
||||
|
||||
fun testCoercionToUnit() {
|
||||
val <!UNUSED_VARIABLE!>simple<!>: ()-> Unit = {
|
||||
41
|
||||
<!UNUSED_EXPRESSION!>41<!>
|
||||
}
|
||||
val <!UNUSED_VARIABLE!>withIf<!>: ()-> Unit = {
|
||||
if (true) {
|
||||
3
|
||||
<!UNUSED_EXPRESSION!>3<!>
|
||||
} else {
|
||||
45
|
||||
<!UNUSED_EXPRESSION!>45<!>
|
||||
}
|
||||
}
|
||||
val i = 34
|
||||
@@ -66,8 +66,8 @@ fun testCoercionToUnit() {
|
||||
doSmth(d)
|
||||
|
||||
}
|
||||
2 -> '4'
|
||||
else -> true
|
||||
2 -> <!UNUSED_EXPRESSION!>'4'<!>
|
||||
else -> <!UNUSED_EXPRESSION!>true<!>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fun main(args: Array<String>) {
|
||||
"".run {
|
||||
<!UNUSED_FUNCTION_LITERAL!>{}<!>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun <T> T.run(f: (T) -> Unit): Unit = f(this)
|
||||
@@ -13,6 +13,5 @@ public class A {
|
||||
|
||||
fun main() {
|
||||
A.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> { "Hello!" }
|
||||
A.foo(Runnable { "Hello!" })
|
||||
}
|
||||
|
||||
A.foo(Runnable { <!UNUSED_EXPRESSION!>"Hello!"<!> })
|
||||
}
|
||||
@@ -15,7 +15,7 @@ fun new2(body: Comment2.() -> Unit) = body
|
||||
fun main(args: Array<String>) {
|
||||
new {
|
||||
new2 {
|
||||
this@new //UNRESOLVED REFERENCE
|
||||
<!UNUSED_EXPRESSION!>this@new<!> //UNRESOLVED REFERENCE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
fun foo(x: Int) {
|
||||
r {
|
||||
when (x) {
|
||||
2 -> 0
|
||||
2 -> <!UNUSED_EXPRESSION!>0<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user