From c9c0b9fd107082dfde47d4288ed7bf390f2b86d5 Mon Sep 17 00:00:00 2001 From: Svyatoslav Kuzmich Date: Tue, 28 Feb 2023 12:47:54 +0100 Subject: [PATCH] [Wasm] Add more jsCode diagnostic tests with String properties --- .../diagnostics/wasmTests/jsInterop/jsCode.kt | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/compiler/testData/diagnostics/wasmTests/jsInterop/jsCode.kt b/compiler/testData/diagnostics/wasmTests/jsInterop/jsCode.kt index 77b23b358ee..0182dd8e274 100644 --- a/compiler/testData/diagnostics/wasmTests/jsInterop/jsCode.kt +++ b/compiler/testData/diagnostics/wasmTests/jsInterop/jsCode.kt @@ -23,6 +23,36 @@ val p5: Int = js(a + a) val p6: Int = js("1" + "1") val p7: Int = js(nonConst()) +val propWithGetter: String + get() = "1" + +val propWithSimpleGetterAndInitializer: String = "1" + get() = field + "2" + +val propWithComplexGetterAndInitializer: String = "1" + get() = run { field + "2" } + +var varProp = "1" + +var varPropWithSetter = "1" + set(value) { field = field + value } + +const val constProp = "1" + +val delegatedVal: String by lazy { "1" } + +val p8: Int = js(propWithGetter) + +// TODO: This should be an error as property getters are no different to functions +val p9: Int = js(propWithSimpleGetterAndInitializer) +val p10: Int = js(propWithComplexGetterAndInitializer) + +val p11: Int = js(varProp) +val p12: Int = js(varPropWithSetter) +val p13: Int = js(constProp) +val p14: Int = js(delegatedVal) + + fun foo0(b: Boolean): Int = if (b) js("1") else js("2")