[Wasm] Better preserve IR types after inlining

This commit is contained in:
Igor Laevsky
2021-12-30 18:19:24 +02:00
parent 9ae452e489
commit cfcbe9e1e2
15 changed files with 49 additions and 62 deletions
@@ -1,10 +1,5 @@
// WITH_STDLIB
// IGNORE_BACKEND: WASM
// Result::getOrNull contains cast (value as T). It gets inlined but type parameter is not updated. We loose information that it was
// a String and instead we treat it as Any. We then fail to assign it into temporary variable of type String?.
// WASM_MUTE_REASON: TYPE_ISSUES
fun f1(): () -> Result<String> {
return {
runCatching {
@@ -1,10 +1,5 @@
// WITH_STDLIB
// IGNORE_BACKEND: WASM
// Result::getOrNull contains cast (value as T). It gets inlined but type parameter is not updated. We loose information that it was
// a String and instead we treat it as Any. We then fail to assign it into temporary variable of type String?.
// WASM_MUTE_REASON: TYPE_ISSUES
fun f1() = lazy {
runCatching {
"OK"
@@ -1,5 +1,4 @@
// WITH_STDLIB
// IGNORE_BACKEND: WASM
object Foo {
fun foo(result: Result<String>) {
@@ -1,9 +1,5 @@
// WITH_STDLIB
// IGNORE_BACKEND: JVM
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: FAKE_OVERRIDE_ISSUES
// On wasm this will produce conflicting return types, Result.<get-value> will return Any but we will try to interpret it as String.
// Before wasm native strings this worked by chance because we added unbox intrinsic for strings.
open class BaseWrapper<T>(val response: T)
class Wrapper(result: Result<String>) : BaseWrapper<Result<String>>(result)
@@ -1,8 +1,4 @@
// WITH_STDLIB
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: FAKE_OVERRIDE_ISSUES
// On wasm this will produce conflicting return types, Result::<get-value> will return Any but we will try to interpret it as String.
// Before wasm native strings this worked by chance because we added unbox intrinsic for strings.
class C {
fun foo(): Result<String> = Result.success("OK")
@@ -1,8 +1,4 @@
// WITH_STDLIB
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: FAKE_OVERRIDE_ISSUES
// On wasm this will produce conflicting return types, Result.<get-value> will return Any but we will try to interpret it as String.
// Before wasm native strings this worked by chance because we added unbox intrinsic for strings.
interface I {
fun foo(): Any
@@ -1,8 +1,4 @@
// WITH_STDLIB
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: FAKE_OVERRIDE_ISSUES
// On wasm this will produce conflicting return types, foo will return Any but we will try to interpret it as String.
// Before wasm native strings this worked by chance because we added unbox intrinsic for strings.
interface I<T> {
fun foo(): T
@@ -1,8 +1,4 @@
// WITH_STDLIB
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: FAKE_OVERRIDE_ISSUES
// On wasm this will produce conflicting return types, foo will return Any but we will try to interpret it as String.
// Before wasm native strings this worked by chance because we added unbox intrinsic for strings.
interface I {
fun foo(): Result<String>
@@ -1,8 +1,4 @@
// WITH_STDLIB
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: FAKE_OVERRIDE_ISSUES
// On wasm this will produce conflicting return types, Result.<get-value> will return Any but we will try to interpret it as String.
// Before wasm native strings this worked by chance because we added unbox intrinsic for strings.
interface I {
fun foo(): Result<String>
@@ -1,8 +1,4 @@
// WITH_STDLIB
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: FAKE_OVERRIDE_ISSUES
// On wasm this will produce conflicting return types, Result.<get-value> will return Any but we will try to interpret it as String.
// Before wasm native strings this worked by chance because we added unbox intrinsic for strings.
fun foo(): Result<String> = Result.success("OK")
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: WASM
// WITH_STDLIB
class Value<T>(val value: T) {