[Wasm] Fix unit issues

- Materialize unit when its value is actually needed.
- Special-case Unit_getInstance return type at codegen. It should be a
  proper Unit object instead of a "void"
This commit is contained in:
Svyatoslav Kuzmich
2021-05-24 18:06:26 +03:00
committed by TeamCityServer
parent 20ddaa9ebf
commit b79719d6f5
45 changed files with 289 additions and 141 deletions
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
// WASM_MUTE_REASON: STDLIB_COLLECTIONS
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
import kotlin.test.*
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
// WASM_MUTE_REASON: STDLIB_COLLECTIONS
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
import kotlin.test.*
-2
View File
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
package array_test
fun box() : String {
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
// WASM_MUTE_REASON: INLINE_ARRAY_CONSTRUCTOR
typealias ArrayS = Array<String>
fun testArray() {
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
// WASM_MUTE_REASON: EXCEPTIONS_NOT_IMPLEMENTED
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
// WASM_MUTE_REASON: EXCEPTIONS_NOT_IMPLEMENTED
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
-2
View File
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
fun println(s: String) {
}
-2
View File
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
fun println(s: String) {
}
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
fun foo() {}
fun bar(): Int? = foo() as? Int
-2
View File
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
class Bar {
}
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
// WASM_MUTE_REASON: STDLIB_COLLECTIONS
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
class ArrayWrapper<T>() {
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
// WASM_MUTE_REASON: COROUTINES
// WITH_RUNTIME
// WITH_COROUTINES
import helpers.*
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
fun box(): String {
var i = 0
{
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
data class A(val x: Unit)
fun box(): String {
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
data class A(val x: Unit)
fun box(): String {
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
// DONT_RUN_GENERATED_CODE: JS
tailrec fun foo(x: Int) {
-2
View File
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
interface A {
val method : () -> Unit?
}
-2
View File
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
class A {
fun get(vararg x: Int) = x.size
}
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
open class T(var value: Int) {}
fun localExtensionOnNullableParameter(): T {
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
fun <T> myRun(action: () -> T): T = action()
fun foo(): String = "foo"
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
class Inv<T>(val x: T?)
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
// !LANGUAGE: +InlineClasses
inline class UInt(private val value: Int) {
-2
View File
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
fun <T> tableView(init: Table<T>.() -> Unit) {
Table<T>().init()
}
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
// WASM_MUTE_REASON: STDLIB_COLLECTIONS
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
+1 -1
View File
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
// WASM_MUTE_REASON: STDLIB_COLLECTIONS
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
inline fun run2(block: () -> Unit) = block()
class A {
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
class A {
val prop: Int
constructor(arg: Boolean) {
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
class A {
val prop: Int
constructor(arg: Boolean) {
-2
View File
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
fun foo() {}
fun box(): String {
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
fun isNull(x: Unit?) = x == null
fun box(): String {
-2
View File
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
val c = Unit
val d = c
-2
View File
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
fun foo(): Any? = bar()
fun bar() {}
-2
View File
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
fun <T : Any, R> T.let(f: (T) -> R): R = f(this)
fun box(): String {
-2
View File
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
fun isNull(x: Unit?) = x == null
fun <T : Any> isNullGeneric(x: T?) = x == null
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
fun foo() {}
fun box(): String {
-2
View File
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
fun box(): String {
Unit
@@ -1,5 +1,3 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: UNIT_ISSUES
enum class En {
A,
B