JVM: correctly merge typed null values
1. merge(null of type A, null of type B) = null of unknown type; 2. merge(null of type A, something of type B) = merge(unknown null, B). ^KT-52311 Fixed
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// WITH_STDLIB
|
||||
// WITH_COROUTINES
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
fun someCondition() = true
|
||||
|
||||
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn {
|
||||
it.resume(Unit)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
|
||||
fun expectString(x: String?) = x!!
|
||||
|
||||
suspend fun foo(): String {
|
||||
var x: String? = null
|
||||
if (someCondition()) {
|
||||
x = "OK"
|
||||
}
|
||||
suspendHere()
|
||||
return expectString(x)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
suspend { result = foo() }.startCoroutine(EmptyContinuation)
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// WITH_STDLIB
|
||||
// WITH_COROUTINES
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
fun someCondition() = false
|
||||
|
||||
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn {
|
||||
it.resume(Unit)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
|
||||
fun expectString(x: String?) = x!!
|
||||
|
||||
suspend fun foo(): String {
|
||||
var x: String? = "OK"
|
||||
if (someCondition()) {
|
||||
x = null as String?
|
||||
}
|
||||
suspendHere()
|
||||
return expectString(x)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
suspend { result = foo() }.startCoroutine(EmptyContinuation)
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user