From 261527939b70cf8f79333b980846f8a96175099e Mon Sep 17 00:00:00 2001 From: Alexander Korepanov Date: Thu, 12 Oct 2023 14:03:14 +0200 Subject: [PATCH] [JS IR] Fix JS code diagnostics tests according to new KLIB checks ^KT-62425 --- .../jsCode/argumentIsLiteral.fir.kt | 27 +++++++++++-------- .../jsCode/argumentIsLiteral.kt | 17 +++++++----- .../jsCode/badAssignment.fir.kt | 7 ++++- .../jsCode/badAssignment.kt | 7 ++++- .../jsCode/deleteOperation.fir.kt | 9 +++++-- .../jsCode/deleteOperation.kt | 7 ++++- .../jsCode/error.fir.kt | 23 +++++++++------- .../jsCode/error.kt | 9 +++++-- .../jsCode/noJavaScriptProduced.fir.kt | 19 ++++++++----- .../jsCode/noJavaScriptProduced.kt | 13 ++++++--- .../jsCode/warning.fir.kt | 13 ++++++--- .../jsCode/warning.kt | 9 +++++-- 12 files changed, 110 insertions(+), 50 deletions(-) diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/argumentIsLiteral.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/argumentIsLiteral.fir.kt index 5d376d4a646..7b81e092618 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/argumentIsLiteral.fir.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/argumentIsLiteral.fir.kt @@ -1,3 +1,8 @@ +// FIR_DIFFERENCE +// The diagnostic cannot be implemented with the FIR frontend checker because it requires constant evaluation over FIR. +// The diagnostic is implemented as a klib check over IR. + +// ERROR_POLICY: SEMANTIC val a = "1" fun nonConst(): String = "1" @@ -5,20 +10,20 @@ fun nonConst(): String = "1" fun test() { val b = "b" - js(a) - js((b)) + js(a) + js((b)) js(("c")) - js(3) - js(3 + 2) - js(1.0f) - js(true) - js("$a") + js(3) + js(3 + 2) + js(1.0f) + js(true) + js("$a") js("${1}") - js("$b;") - js("${b}bb") - js(a + a) + js("$b;") + js("${b}bb") + js(a + a) js("a" + "a") js("ccc") - js(nonConst()) + js(nonConst()) } diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/argumentIsLiteral.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/argumentIsLiteral.kt index 827b60773ac..1f815e4f492 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/argumentIsLiteral.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/argumentIsLiteral.kt @@ -1,3 +1,8 @@ +// FIR_DIFFERENCE +// The diagnostic cannot be implemented with the FIR frontend checker because it requires constant evaluation over FIR. +// The diagnostic is implemented as a klib check over IR. + +// ERROR_POLICY: SEMANTIC val a = "1" fun nonConst(): String = "1" @@ -5,18 +10,18 @@ fun nonConst(): String = "1" fun test() { val b = "b" - js(a) - js((b)) + js(a) + js((b)) js(("c")) js(3) js(3 + 2) js(1.0f) js(true) - js("$a") + js("$a") js("${1}") - js("$b;") - js("${b}bb") - js(a + a) + js("$b;") + js("${b}bb") + js(a + a) js("a" + "a") js("ccc") diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/badAssignment.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/badAssignment.fir.kt index 83a609d6284..2eab3a272cd 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/badAssignment.fir.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/badAssignment.fir.kt @@ -1,4 +1,9 @@ +// FIR_DIFFERENCE +// The diagnostic cannot be implemented with the FIR frontend checker because it requires constant evaluation over FIR. +// The diagnostic is implemented as a klib check over IR. + +// ERROR_POLICY: SEMANTIC // !DIAGNOSTICS: -UNUSED_PARAMETER fun Int.foo(x: Int) { - js("this = x;") + js("this = x;") } diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/badAssignment.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/badAssignment.kt index 5bcc2563c3d..db67429000c 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/badAssignment.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/badAssignment.kt @@ -1,4 +1,9 @@ +// FIR_DIFFERENCE +// The diagnostic cannot be implemented with the FIR frontend checker because it requires constant evaluation over FIR. +// The diagnostic is implemented as a klib check over IR. + +// ERROR_POLICY: SEMANTIC // !DIAGNOSTICS: -UNUSED_PARAMETER fun Int.foo(x: Int) { js("this = x;") -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/deleteOperation.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/deleteOperation.fir.kt index e07dd1adc65..5aa5c2eaf07 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/deleteOperation.fir.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/deleteOperation.fir.kt @@ -1,8 +1,13 @@ +// FIR_DIFFERENCE +// The diagnostic cannot be implemented with the FIR frontend checker because it requires constant evaluation over FIR. +// The diagnostic is implemented as a klib check over IR. + +// ERROR_POLICY: SEMANTIC // !DIAGNOSTICS: -UNUSED_PARAMETER fun foo(x: Any) { js("delete x.foo;") js("delete x['bar'];") - js("delete x.baz();") - js("delete this;") + js("delete x.baz();") + js("delete this;") } diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/deleteOperation.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/deleteOperation.kt index 0d63a37f396..a8cb95f0c8d 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/deleteOperation.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/deleteOperation.kt @@ -1,3 +1,8 @@ +// FIR_DIFFERENCE +// The diagnostic cannot be implemented with the FIR frontend checker because it requires constant evaluation over FIR. +// The diagnostic is implemented as a klib check over IR. + +// ERROR_POLICY: SEMANTIC // !DIAGNOSTICS: -UNUSED_PARAMETER fun foo(x: Any) { @@ -5,4 +10,4 @@ fun foo(x: Any) { js("delete x['bar'];") js("delete x.baz();") js("delete this;") -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/error.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/error.fir.kt index 329b808e742..0a405f5956c 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/error.fir.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/error.fir.kt @@ -1,25 +1,30 @@ +// FIR_DIFFERENCE +// The diagnostic cannot be implemented with the FIR frontend checker because it requires constant evaluation over FIR. +// The diagnostic is implemented as a klib check over IR. + +// ERROR_POLICY: SEMANTIC val code = """ var s = "hello" + ); """ fun main(): Unit { - js("var = 10;") + js("var = 10;") - js("""var = 10;""") + js("""var = 10;""") - js("""var + js("""var = 777; - """) + """) - js(""" + js(""" var = 777; - """) + """) - js("var " + " = " + "10;") + js("var " + " = " + "10;") val n = 10 - js("var = $n;") + js("var = $n;") - js(code) + js(code) } diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/error.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/error.kt index 017dc2cf2c0..21b79227647 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/error.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/error.kt @@ -1,3 +1,8 @@ +// FIR_DIFFERENCE +// The diagnostic cannot be implemented with the FIR frontend checker because it requires constant evaluation over FIR. +// The diagnostic is implemented as a klib check over IR. + +// ERROR_POLICY: SEMANTIC val code = """ var s = "hello" + ); @@ -19,7 +24,7 @@ fun main(): Unit { js("var " + " = " + "10;") val n = 10 - js("var = $n;") + js("var = $n;") - js(code) + js(code) } diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/noJavaScriptProduced.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/noJavaScriptProduced.fir.kt index be4f81c1449..a81dfd6f2d7 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/noJavaScriptProduced.fir.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/noJavaScriptProduced.fir.kt @@ -1,16 +1,21 @@ +// FIR_DIFFERENCE +// The diagnostic cannot be implemented with the FIR frontend checker because it requires constant evaluation over FIR. +// The diagnostic is implemented as a klib check over IR. + +// ERROR_POLICY: SEMANTIC fun test() { - js("") - js(" ") - js(""" - """) + js("") + js(" ") + js(""" + """) val empty = "" - js(empty) + js(empty) val whitespace = " " - js(whitespace) + js(whitespace) val multiline = """ """ - js(multiline) + js(multiline) } diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/noJavaScriptProduced.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/noJavaScriptProduced.kt index 117a24fdb7d..93c3114daf6 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/noJavaScriptProduced.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/noJavaScriptProduced.kt @@ -1,3 +1,8 @@ +// FIR_DIFFERENCE +// The diagnostic cannot be implemented with the FIR frontend checker because it requires constant evaluation over FIR. +// The diagnostic is implemented as a klib check over IR. + +// ERROR_POLICY: SEMANTIC fun test() { js("") js(" ") @@ -5,12 +10,12 @@ fun test() { """) val empty = "" - js(empty) + js(empty) val whitespace = " " - js(whitespace) + js(whitespace) val multiline = """ """ - js(multiline) -} \ No newline at end of file + js(multiline) +} diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/warning.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/warning.fir.kt index 9407dd89d1d..94c2dad0cb1 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/warning.fir.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/warning.fir.kt @@ -1,10 +1,15 @@ +// FIR_DIFFERENCE +// The diagnostic cannot be implemented with the FIR frontend checker because it requires constant evaluation over FIR. +// The diagnostic is implemented as a klib check over IR. + +// ERROR_POLICY: SEMANTIC fun main(): Unit { - js("var a = 08;") + js("var a = 08;") - js("""var a = + js("""var a = - 08;""") + 08;""") val code = "var a = 08;" - js(code) + js(code) } diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/warning.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/warning.kt index 10066d5e3db..1cc4c56e712 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/warning.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/warning.kt @@ -1,3 +1,8 @@ +// FIR_DIFFERENCE +// The diagnostic cannot be implemented with the FIR frontend checker because it requires constant evaluation over FIR. +// The diagnostic is implemented as a klib check over IR. + +// ERROR_POLICY: SEMANTIC fun main(): Unit { js("var a = 08;") @@ -6,5 +11,5 @@ fun main(): Unit { 08;""") val code = "var a = 08;" - js(code) -} \ No newline at end of file + js(code) +}