-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/BoxJsTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrBoxJsTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
js/js.translator/testData/box/expression/function/lambdaReturnValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// EXPECTED_REACHABLE_NODES: 1285 | ||
|
||
fun <T> rawReturnValue(fn: () -> T): Any { | ||
return fn() as Any | ||
} | ||
|
||
fun unitFun() {} | ||
|
||
fun charFun(): Char = 'a' | ||
|
||
value class VC(val v: Int) | ||
|
||
fun vcFun(): VC = VC(1) | ||
|
||
|
||
|
||
fun box(): String { | ||
if (rawReturnValue { unitFun() } != Unit) return "fail1.1" | ||
if (rawReturnValue<Unit> { unitFun() } != Unit) return "fail1.2" | ||
if (rawReturnValue<Any> { unitFun() } != Unit) return "fail1.3" | ||
|
||
val boxedA: Any = 'a' | ||
|
||
if (rawReturnValue { charFun() } != boxedA) return "fail2.1" | ||
if (rawReturnValue<Char> { charFun() } != boxedA) return "fail2.2" | ||
if (rawReturnValue<Any> { charFun() } != boxedA) return "fail2.3" | ||
|
||
val boxed1: Any = VC(1) | ||
|
||
if (rawReturnValue { vcFun() } != boxed1) return "fail3.1" | ||
if (rawReturnValue<VC> { vcFun() } != boxed1) return "fail3.2" | ||
if (rawReturnValue<Any> { vcFun() } != boxed1) return "fail3.3" | ||
|
||
return "OK" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// EXPECTED_REACHABLE_NODES: 1274 | ||
|
||
fun box(): String { | ||
instance = Holder() | ||
instance?.applyAndRet<Unit> { sideEffect("left") } ?: sideEffect("right") | ||
|
||
if (log == "left") return "OK" else return "fail: $log" | ||
} | ||
|
||
var log = "" | ||
|
||
fun sideEffect(msg: String) { | ||
log += msg | ||
} | ||
|
||
var instance: Holder? = null | ||
|
||
class Holder() { | ||
fun <T> applyAndRet(block: () -> T): T { | ||
return block() | ||
} | ||
} |