From f52648af5ff2159677b1c4882d9c1c757768a5d4 Mon Sep 17 00:00:00 2001 From: Nikolay Lunyak Date: Thu, 4 Jan 2024 12:39:41 +0200 Subject: [PATCH] [FIR] Support CHECK_TYPE in K2 JS tests ^KT-60056 --- .../dynamicCallsWithLambdas.fir.kt | 34 ------------------- .../dynamicTypes/dynamicCallsWithLambdas.kt | 1 + .../dynamicTypes/overloading.fir.kt | 23 ------------- .../dynamicTypes/overloading.kt | 1 + .../fir/AbstractFirPsiJsDiagnosticTest.kt | 2 ++ 5 files changed, 4 insertions(+), 57 deletions(-) delete mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.fir.kt delete mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/overloading.fir.kt diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.fir.kt deleted file mode 100644 index 2bc4ec9e032..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.fir.kt +++ /dev/null @@ -1,34 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_ANONYMOUS_PARAMETER -// !CHECK_TYPE - -fun test(d: dynamic) { - d.foo {} - - d.foo { it } - - d.foo { x -> x.bar() } - - d.foo { x: Int -> "" } - - d.foo { x, y -> "" } - - d.foo { x: String, y: Int -> "" } - - d.foo { x, y: Int -> "" } - - d.foo({}) - - d.foo({ x -> }) - - d.foo(checkSubtype<(Int) -> Unit>({ x -> })) - - d.foo(label@ { x -> }) - - d.foo(label@ ({ x, y -> })) - - d.foo((label@ ({ x, y: Int -> }))) - - d.foo(({ x -> })) - - d.foo((({ x -> }))) -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.kt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.kt index 8c814e34414..cb4337731a9 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_ANONYMOUS_PARAMETER // !CHECK_TYPE diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/overloading.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/overloading.fir.kt deleted file mode 100644 index 747a260f686..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/overloading.fir.kt +++ /dev/null @@ -1,23 +0,0 @@ -// !CHECK_TYPE -// !DIAGNOSTICS: -UNUSED_PARAMETER - -fun dyn(d: dynamic) {} - -fun foo(d: dynamic): String = "" -fun foo(d: Int): Int = 1 - -fun nothing(d: dynamic): Int = 1 -fun nothing(d: Nothing): String = "" - -fun test(d: dynamic) { - dyn(1) - dyn("") - - foo(1).checkType { _() } - foo("").checkType { _() } - - // Checking specificity of `dynamic` vs `Nothing` - nothing(d).checkType { _() } - nothing("").checkType { _() } - @Suppress("UNREACHABLE_CODE") nothing(null!!).checkType { _() } -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/overloading.kt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/overloading.kt index 87ffa2f927e..d3e01a18f78 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/overloading.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/overloading.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_PARAMETER diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/fir/AbstractFirPsiJsDiagnosticTest.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/fir/AbstractFirPsiJsDiagnosticTest.kt index 8a64be264df..7b0503a0848 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/fir/AbstractFirPsiJsDiagnosticTest.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/fir/AbstractFirPsiJsDiagnosticTest.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.test.runners.configurationForClassicAndFirTestsAlong import org.jetbrains.kotlin.test.services.LibraryProvider import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurator +import org.jetbrains.kotlin.test.services.sourceProviders.AdditionalDiagnosticsSourceFilesProvider import org.jetbrains.kotlin.test.services.sourceProviders.CoroutineHelpersSourceFilesProvider abstract class AbstractFirJsDiagnosticTestBase(val parser: FirParser) : AbstractKotlinCompilerTest() { @@ -58,6 +59,7 @@ abstract class AbstractFirJsDiagnosticTestBase(val parser: FirParser) : Abstract useAdditionalSourceProviders( ::JsAdditionalSourceProvider, ::CoroutineHelpersSourceFilesProvider, + ::AdditionalDiagnosticsSourceFilesProvider, ) useAdditionalService(::LibraryProvider)