[FIR JS] KT-57601: Get rid of the builtin provider

In this example we get 2 variants of `kotlin/toString()`:
one coming from the KLib provider, and the
other coming from the builtins provider.
These are identical deserialized functions.

^KT-57601 Fixed
This commit is contained in:
Nikolay Lunyak
2023-04-10 15:48:21 +03:00
committed by Space Team
parent 2a391f7330
commit 360d236b7e
11 changed files with 19 additions and 8 deletions
+1
View File
@@ -56,6 +56,7 @@ projectTest(
defineJDKEnvVariables = listOf(JdkMajorVersion.JDK_1_8, JdkMajorVersion.JDK_11_0, JdkMajorVersion.JDK_17_0)
) {
dependsOn(":dist")
useJsIrBoxTests(version = version, buildDir = "$buildDir/")
workingDir = rootDir
systemProperty("kotlin.test.script.classpath", testSourceSet.output.classesDirs.joinToString(File.pathSeparator))
@@ -66,6 +66,7 @@ projectTest(
dependsOn(":dist")
workingDir = rootDir
useJUnitPlatform()
useJsIrBoxTests(version = version, buildDir = "$buildDir/")
}
testsJar()
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.fir.deserialization.SingleModuleDataProvider
import org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrar
import org.jetbrains.kotlin.fir.java.FirProjectSessionProvider
import org.jetbrains.kotlin.fir.resolve.calls.ConeCallConflictResolverFactory
import org.jetbrains.kotlin.fir.resolve.providers.impl.FirBuiltinSymbolProvider
import org.jetbrains.kotlin.fir.resolve.providers.impl.FirBuiltinSyntheticFunctionInterfaceProvider
import org.jetbrains.kotlin.fir.resolve.providers.impl.FirExtensionSyntheticFunctionInterfaceProvider
import org.jetbrains.kotlin.fir.scopes.FirKotlinScopeProvider
import org.jetbrains.kotlin.fir.scopes.FirPlatformClassMapper
@@ -95,10 +95,7 @@ object FirJsSessionFactory : FirAbstractSessionFactory() {
createProviders = { session, builtinsModuleData, kotlinScopeProvider ->
listOfNotNull(
KlibBasedSymbolProvider(session, moduleDataProvider, kotlinScopeProvider, resolvedLibraries),
// (Most) builtins should be taken from the dependencies in JS compilation, therefore builtins provider is the last one
// TODO: consider using "poisoning" provider for builtins to ensure that proper ones are taken from dependencies
// NOTE: it requires precise filtering for true builtins, like Function*
FirBuiltinSymbolProvider(session, builtinsModuleData, kotlinScopeProvider),
FirBuiltinSyntheticFunctionInterfaceProvider(session, builtinsModuleData, kotlinScopeProvider),
FirExtensionSyntheticFunctionInterfaceProvider.createIfNeeded(session, builtinsModuleData, kotlinScopeProvider),
)
}
@@ -43,10 +43,12 @@ sourceSets {
projectTest(parallel = true) {
workingDir = rootDir
dependsOn(":kotlin-stdlib-js-ir:packFullRuntimeKLib")
useJsIrBoxTests(version = version, buildDir = "$buildDir/")
}
projectTest("testJvmICWithJdk11", parallel = true) {
workingDir = rootDir
useJsIrBoxTests(version = version, buildDir = "$buildDir/")
filter {
includeTestsMatching("org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunnerTestGenerated*")
}
+2
View File
@@ -5,3 +5,5 @@ $TESTDATA_DIR$/fir.kt
$TEMP_DIR$
-ir-output-name
fir
-libraries
libraries/stdlib/js-ir/build/classes/kotlin/js/main
+2
View File
@@ -8,3 +8,5 @@ $TEMP_DIR$
-ir-output-name
firMpp
-XXLanguage\:+MultiPlatformProjects
-libraries
libraries/stdlib/js-ir/build/classes/kotlin/js/main
+2
View File
@@ -9,3 +9,5 @@ $TEMP_DIR$
firMppWithKlib
-XXLanguage\:+MultiPlatformProjects
-Xir-produce-klib-file=true
-libraries
libraries/stdlib/js-ir/build/classes/kotlin/js/main
+2
View File
@@ -14,3 +14,5 @@ fir-hmpp
-Xfragment-sources=c\:$TESTDATA_DIR$/../jvm/hmpp/src/c.kt
-Xfragment-refines=b\:a
-Xfragment-refines=c\:b
-libraries
libraries/stdlib/js-ir/build/classes/kotlin/js/main
@@ -1,3 +1,3 @@
import kotlin.Cloneable
import kotlin.<!UNRESOLVED_IMPORT!>Cloneable<!>
fun cloneable(): Cloneable = intArrayOf(42)
fun cloneable(): <!UNRESOLVED_REFERENCE!>Cloneable<!> = intArrayOf(42)
+3
View File
@@ -2,6 +2,9 @@
// SKIP_KLIB_TEST
// IGNORE_BACKEND_K1: JS_IR
// IGNORE_BACKEND_K1: JS_IR_ES6
// IGNORE_BACKEND_K2: JS_IR
// IGNORE_BACKEND_K2: JS_IR_ES6
// STATUS: This should not work in JS, Cloneable is JVM-specific API
class A : Cloneable
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_K2: JS_IR
// KJS_WITH_FULL_RUNTIME
// EXPECTED_REACHABLE_NODES: 1378
package foo