Describe the bug
returning from inside a guard after doing something inside the else outputs wrong kotlin code
How to reproduce it
Given the swift code:
protocol Test {
var a: Int { get set }
}
func foo(arg: @escaping (Test?) -> ()) {
}
func baz() {
var k = 0
foo(arg: { t in
guard let td = t else {
k = 1
return
}
})
}
It outputs
internal interface Test {
var a: Int
}
internal fun foo(arg: (Test?) -> Unit) {
}
internal fun baz() {
var k: Int = 0
foo { t ->
val td: Test? = t
if (td == null) {
k = 1
return@foo(arg:)
}
}
}
The correct thing to do inside the lambda return is return@foo
Your environment (please complete the following information):
Describe the bug returning from inside a
guard
after doing something inside theelse
outputs wrong kotlin codeHow to reproduce it Given the swift code:
It outputs
The correct thing to do inside the lambda return is
return@foo
Your environment (please complete the following information):