[K/JS] Rework main function call to support it in per-file
This commit is contained in:
@@ -605,14 +605,15 @@ class GenerateIrRuntime {
|
||||
symbolTable,
|
||||
additionalExportedDeclarationNames = emptySet(),
|
||||
keep = emptySet(),
|
||||
configuration
|
||||
configuration,
|
||||
null
|
||||
)
|
||||
|
||||
ExternalDependenciesGenerator(symbolTable, listOf(jsLinker)).generateUnboundSymbolsAsDependencies()
|
||||
|
||||
jsPhases.invokeToplevel(phaseConfig, context, listOf(module))
|
||||
|
||||
val transformer = IrModuleToJsTransformer(context, null)
|
||||
val transformer = IrModuleToJsTransformer(context, shouldReferMainFunction = false)
|
||||
|
||||
return transformer.generateModule(listOf(module), setOf(TranslationMode.PER_MODULE_DEV), false)
|
||||
}
|
||||
|
||||
@@ -25,10 +25,7 @@ import org.jetbrains.kotlin.ir.backend.js.SourceMapsInfo
|
||||
import org.jetbrains.kotlin.ir.backend.js.WholeWorldStageController
|
||||
import org.jetbrains.kotlin.ir.backend.js.ic.*
|
||||
import org.jetbrains.kotlin.ir.backend.js.jsPhases
|
||||
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.CompilationOutputs
|
||||
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.JsGenerationGranularity
|
||||
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.extension
|
||||
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.safeModuleName
|
||||
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImplForJsIC
|
||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
||||
import org.jetbrains.kotlin.js.test.converters.ClassicJsBackendFacade
|
||||
@@ -44,6 +41,7 @@ import org.jetbrains.kotlin.test.builders.LanguageVersionSettingsBuilder
|
||||
import org.jetbrains.kotlin.test.util.JUnit4Assertions
|
||||
import org.jetbrains.kotlin.test.utils.TestDisposable
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||
import org.junit.ComparisonFailure
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import java.io.File
|
||||
@@ -313,11 +311,16 @@ abstract class AbstractInvalidationTest(
|
||||
)
|
||||
}
|
||||
|
||||
private fun writeJsCode(stepId: Int, mainModuleName: String, jsOutput: CompilationOutputs): List<String> {
|
||||
private fun writeJsCode(
|
||||
stepId: Int,
|
||||
mainModuleName: String,
|
||||
jsOutput: CompilationOutputs,
|
||||
dtsStrategy: TsCompilationStrategy
|
||||
): List<String> {
|
||||
val compiledJsFiles = jsOutput.writeAll(
|
||||
jsDir,
|
||||
mainModuleName,
|
||||
true,
|
||||
dtsStrategy,
|
||||
mainModuleName,
|
||||
projectInfo.moduleKind
|
||||
).filter {
|
||||
@@ -341,6 +344,12 @@ abstract class AbstractInvalidationTest(
|
||||
fun execute() {
|
||||
if (granularity in projectInfo.ignoredGranularities) return
|
||||
|
||||
val mainArguments = runIf(projectInfo.callMain) { emptyList<String>() }
|
||||
val dtsStrategy = when (granularity) {
|
||||
JsGenerationGranularity.PER_FILE -> TsCompilationStrategy.EACH_FILE
|
||||
else -> TsCompilationStrategy.MERGED
|
||||
}
|
||||
|
||||
for (projStep in projectInfo.steps) {
|
||||
val testInfo = projStep.order.map { setupTestStep(projStep, it) }
|
||||
|
||||
@@ -363,10 +372,10 @@ abstract class AbstractInvalidationTest(
|
||||
cacheDir = buildDir.resolve("incremental-cache").absolutePath,
|
||||
compilerConfiguration = configuration,
|
||||
irFactory = { IrFactoryImplForJsIC(WholeWorldStageController()) },
|
||||
mainArguments = null,
|
||||
compilerInterfaceFactory = { mainModule, cfg ->
|
||||
JsIrCompilerWithIC(
|
||||
mainModule,
|
||||
mainArguments,
|
||||
cfg,
|
||||
granularity,
|
||||
getPhaseConfig(projStep.id),
|
||||
@@ -390,7 +399,7 @@ abstract class AbstractInvalidationTest(
|
||||
)
|
||||
|
||||
val (jsOutput, rebuiltModules) = jsExecutableProducer.buildExecutable(granularity, outJsProgram = true)
|
||||
val writtenFiles = writeJsCode(projStep.id, mainModuleName, jsOutput)
|
||||
val writtenFiles = writeJsCode(projStep.id, mainModuleName, jsOutput, dtsStrategy)
|
||||
|
||||
verifyJsExecutableProducerBuildModules(projStep.id, rebuiltModules, dirtyData)
|
||||
verifyJsCode(projStep.id, mainModuleName, writtenFiles)
|
||||
|
||||
@@ -138,10 +138,13 @@ class JsIrBackendFacade(
|
||||
PhaseConfig(jsPhases)
|
||||
}
|
||||
|
||||
val mainArguments = JsEnvironmentConfigurator.getMainCallParametersForModule(module)
|
||||
.run { if (shouldBeGenerated()) arguments() else null }
|
||||
|
||||
val loweredIr = compileIr(
|
||||
irModuleFragment.apply { resolveTestPaths() },
|
||||
MainModule.Klib(inputArtifact.outputFile.absolutePath),
|
||||
mainArguments,
|
||||
configuration,
|
||||
dependencyModules.onEach { it.resolveTestPaths() },
|
||||
emptyMap(),
|
||||
@@ -157,12 +160,10 @@ class JsIrBackendFacade(
|
||||
granularity = granularity,
|
||||
)
|
||||
|
||||
return loweredIr2JsArtifact(module, loweredIr)
|
||||
return loweredIr2JsArtifact(module, loweredIr, mainArguments != null)
|
||||
}
|
||||
|
||||
private fun loweredIr2JsArtifact(module: TestModule, loweredIr: LoweredIr): BinaryArtifacts.Js {
|
||||
val mainArguments = JsEnvironmentConfigurator.getMainCallParametersForModule(module)
|
||||
.run { if (shouldBeGenerated()) arguments() else null }
|
||||
private fun loweredIr2JsArtifact(module: TestModule, loweredIr: LoweredIr, shouldReferMainFunction: Boolean): BinaryArtifacts.Js {
|
||||
val runIrDce = JsEnvironmentConfigurationDirectives.RUN_IR_DCE in module.directives
|
||||
val onlyIrDce = JsEnvironmentConfigurationDirectives.ONLY_IR_DCE in module.directives
|
||||
val perModuleOnly = JsEnvironmentConfigurationDirectives.SPLIT_PER_MODULE in module.directives
|
||||
@@ -178,12 +179,12 @@ class JsIrBackendFacade(
|
||||
|
||||
val transformer = IrModuleToJsTransformer(
|
||||
loweredIr.context,
|
||||
mainArguments,
|
||||
moduleToName = runIf(isEsModules) {
|
||||
loweredIr.allModules.associateWith {
|
||||
"./${getJsArtifactSimpleName(testServices, it.safeName)}_v5".minifyIfNeed()
|
||||
}
|
||||
} ?: emptyMap()
|
||||
} ?: emptyMap(),
|
||||
shouldReferMainFunction,
|
||||
)
|
||||
// If runIrDce then include DCE results
|
||||
// If perModuleOnly then skip whole program
|
||||
@@ -290,7 +291,7 @@ class JsIrBackendFacade(
|
||||
val tmpBuildDir = rootDir.resolve("tmp-build")
|
||||
// CompilationOutputs keeps the `outputDir` clean by removing all outdated JS and other unknown files.
|
||||
// To ensure that useful files around `outputFile`, such as irdump, are not removed, use `tmpBuildDir` instead.
|
||||
val allJsFiles = writeAll(tmpBuildDir, outputFile.nameWithoutExtension, false, moduleId, moduleKind).filter {
|
||||
val allJsFiles = writeAll(tmpBuildDir, outputFile.nameWithoutExtension, TsCompilationStrategy.NONE, moduleId, moduleKind).filter {
|
||||
it.extension == "js" || it.extension == "mjs"
|
||||
}
|
||||
|
||||
|
||||
Generated
+6
@@ -343,6 +343,12 @@ public class JsFirInvalidationPerFileTestGenerated extends AbstractJsFirInvalida
|
||||
runTest("js/js.translator/testData/incremental/invalidation/localObjectsLeakThroughInterface/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mainFunction")
|
||||
public void testMainFunction() throws Exception {
|
||||
runTest("js/js.translator/testData/incremental/invalidation/mainFunction/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mainModuleInvalidation")
|
||||
public void testMainModuleInvalidation() throws Exception {
|
||||
|
||||
Generated
+6
@@ -343,6 +343,12 @@ public class JsFirInvalidationPerModuleTestGenerated extends AbstractJsFirInvali
|
||||
runTest("js/js.translator/testData/incremental/invalidation/localObjectsLeakThroughInterface/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mainFunction")
|
||||
public void testMainFunction() throws Exception {
|
||||
runTest("js/js.translator/testData/incremental/invalidation/mainFunction/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mainModuleInvalidation")
|
||||
public void testMainModuleInvalidation() throws Exception {
|
||||
|
||||
Generated
+6
@@ -343,6 +343,12 @@ public class JsIrES6InvalidationPerFileTestGenerated extends AbstractJsIrES6Inva
|
||||
runTest("js/js.translator/testData/incremental/invalidation/localObjectsLeakThroughInterface/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mainFunction")
|
||||
public void testMainFunction() throws Exception {
|
||||
runTest("js/js.translator/testData/incremental/invalidation/mainFunction/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mainModuleInvalidation")
|
||||
public void testMainModuleInvalidation() throws Exception {
|
||||
|
||||
+6
@@ -343,6 +343,12 @@ public class JsIrES6InvalidationPerModuleTestGenerated extends AbstractJsIrES6In
|
||||
runTest("js/js.translator/testData/incremental/invalidation/localObjectsLeakThroughInterface/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mainFunction")
|
||||
public void testMainFunction() throws Exception {
|
||||
runTest("js/js.translator/testData/incremental/invalidation/mainFunction/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mainModuleInvalidation")
|
||||
public void testMainModuleInvalidation() throws Exception {
|
||||
|
||||
Generated
+6
@@ -343,6 +343,12 @@ public class JsIrInvalidationPerFileTestGenerated extends AbstractJsIrInvalidati
|
||||
runTest("js/js.translator/testData/incremental/invalidation/localObjectsLeakThroughInterface/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mainFunction")
|
||||
public void testMainFunction() throws Exception {
|
||||
runTest("js/js.translator/testData/incremental/invalidation/mainFunction/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mainModuleInvalidation")
|
||||
public void testMainModuleInvalidation() throws Exception {
|
||||
|
||||
Generated
+6
@@ -343,6 +343,12 @@ public class JsIrInvalidationPerModuleTestGenerated extends AbstractJsIrInvalida
|
||||
runTest("js/js.translator/testData/incremental/invalidation/localObjectsLeakThroughInterface/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mainFunction")
|
||||
public void testMainFunction() throws Exception {
|
||||
runTest("js/js.translator/testData/incremental/invalidation/mainFunction/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mainModuleInvalidation")
|
||||
public void testMainModuleInvalidation() throws Exception {
|
||||
|
||||
+58
@@ -2598,6 +2598,64 @@ public class FirJsBoxTestGenerated extends AbstractFirJsBoxTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/main")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Main {
|
||||
@Test
|
||||
public void testAllFilesPresentInMain() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/main"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("differentMains.kt")
|
||||
public void testDifferentMains() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/differentMains.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("incremental.kt")
|
||||
public void testIncremental() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/incremental.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noArgs.kt")
|
||||
public void testNoArgs() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/noArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/simple.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendMain.kt")
|
||||
public void testSuspendMain() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/suspendMain.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendMainNoArgs.kt")
|
||||
public void testSuspendMainNoArgs() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/suspendMainNoArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendMainThrows.kt")
|
||||
public void testSuspendMainThrows() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/suspendMainThrows.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("twoMains.kt")
|
||||
public void testTwoMains() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/twoMains.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/native")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+58
@@ -2704,6 +2704,64 @@ public class FirJsES6BoxTestGenerated extends AbstractFirJsES6BoxTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/main")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Main {
|
||||
@Test
|
||||
public void testAllFilesPresentInMain() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/main"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("differentMains.kt")
|
||||
public void testDifferentMains() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/differentMains.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("incremental.kt")
|
||||
public void testIncremental() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/incremental.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noArgs.kt")
|
||||
public void testNoArgs() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/noArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/simple.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendMain.kt")
|
||||
public void testSuspendMain() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/suspendMain.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendMainNoArgs.kt")
|
||||
public void testSuspendMainNoArgs() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/suspendMainNoArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendMainThrows.kt")
|
||||
public void testSuspendMainThrows() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/suspendMainThrows.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("twoMains.kt")
|
||||
public void testTwoMains() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/twoMains.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/native")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+58
@@ -2704,6 +2704,64 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/main")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Main {
|
||||
@Test
|
||||
public void testAllFilesPresentInMain() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/main"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("differentMains.kt")
|
||||
public void testDifferentMains() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/differentMains.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("incremental.kt")
|
||||
public void testIncremental() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/incremental.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noArgs.kt")
|
||||
public void testNoArgs() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/noArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/simple.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendMain.kt")
|
||||
public void testSuspendMain() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/suspendMain.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendMainNoArgs.kt")
|
||||
public void testSuspendMainNoArgs() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/suspendMainNoArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendMainThrows.kt")
|
||||
public void testSuspendMainThrows() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/suspendMainThrows.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("twoMains.kt")
|
||||
public void testTwoMains() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/twoMains.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/native")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+58
@@ -2598,6 +2598,64 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/main")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Main {
|
||||
@Test
|
||||
public void testAllFilesPresentInMain() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/main"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("differentMains.kt")
|
||||
public void testDifferentMains() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/differentMains.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("incremental.kt")
|
||||
public void testIncremental() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/incremental.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noArgs.kt")
|
||||
public void testNoArgs() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/noArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/simple.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendMain.kt")
|
||||
public void testSuspendMain() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/suspendMain.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendMainNoArgs.kt")
|
||||
public void testSuspendMainNoArgs() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/suspendMainNoArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendMainThrows.kt")
|
||||
public void testSuspendMainThrows() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/suspendMainThrows.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("twoMains.kt")
|
||||
public void testTwoMains() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/main/twoMains.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/native")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1281
|
||||
// ES_MODULES
|
||||
// CALL_MAIN
|
||||
|
||||
var ok: String = "OK"
|
||||
|
||||
fun main(args: Array<Int>) {
|
||||
ok += "Fail Int"
|
||||
}
|
||||
|
||||
fun main(args: Array<in String>) {
|
||||
ok += "Fail IN"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>): Unit? {
|
||||
ok += "Fail return Unit?"
|
||||
return Unit
|
||||
}
|
||||
|
||||
fun Any.main(args: Array<String>) {
|
||||
ok += "Fail Any.main(...)"
|
||||
}
|
||||
|
||||
fun box() = ok
|
||||
@@ -0,0 +1,56 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1281
|
||||
// ES_MODULES
|
||||
// CALL_MAIN
|
||||
|
||||
// FILE: ok.kt
|
||||
|
||||
package ok
|
||||
|
||||
var ok: String = "fail"
|
||||
|
||||
// FILE: 1.kt
|
||||
// RECOMPILE
|
||||
|
||||
package a.a
|
||||
|
||||
import ok.*
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
ok = "fail: b.b"
|
||||
}
|
||||
|
||||
// FILE: 0.kt
|
||||
|
||||
package b
|
||||
|
||||
import ok.*
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
ok = "fail: b"
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
package a
|
||||
|
||||
import ok.*
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
ok = "OK"
|
||||
}
|
||||
|
||||
// FILE: 3.kt
|
||||
|
||||
package a.b
|
||||
|
||||
import ok.*
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
ok = "fail: a.b"
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
import ok.*
|
||||
|
||||
fun box() = ok
|
||||
@@ -0,0 +1,11 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1281
|
||||
// ES_MODULES
|
||||
// CALL_MAIN
|
||||
|
||||
var ok: String = "fail"
|
||||
|
||||
fun main() {
|
||||
ok = "OK"
|
||||
}
|
||||
|
||||
fun box() = ok
|
||||
@@ -0,0 +1,13 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1281
|
||||
// ES_MODULES
|
||||
// CALL_MAIN
|
||||
|
||||
var ok: String = "fail"
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (0 != args.size) error("fail")
|
||||
|
||||
ok = "OK"
|
||||
}
|
||||
|
||||
fun box() = ok
|
||||
@@ -0,0 +1,27 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1296
|
||||
// ES_MODULES
|
||||
// CALL_MAIN
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
var ok: String = "fail"
|
||||
|
||||
var callback: () -> Unit = {}
|
||||
|
||||
suspend fun main(args: Array<String>) {
|
||||
if (0 != args.size) error("Fail")
|
||||
|
||||
suspendCoroutine<Unit> { cont ->
|
||||
callback = {
|
||||
cont.resume(Unit)
|
||||
}
|
||||
}
|
||||
|
||||
ok = "OK"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if ("fail" != ok) return "Fail"
|
||||
callback()
|
||||
return ok
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1296
|
||||
// ES_MODULES
|
||||
// CALL_MAIN
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
var ok: String = "fail"
|
||||
|
||||
var callback: () -> Unit = {}
|
||||
|
||||
suspend fun main() {
|
||||
suspendCoroutine<Unit> { cont ->
|
||||
callback = {
|
||||
cont.resume(Unit)
|
||||
}
|
||||
}
|
||||
|
||||
ok = "OK"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if ("fail" != ok) error("Fail")
|
||||
callback()
|
||||
return ok
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1299
|
||||
// ES_MODULES
|
||||
// CALL_MAIN
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
var callback: () -> Unit = {}
|
||||
|
||||
val exception = Exception()
|
||||
|
||||
suspend fun main() {
|
||||
|
||||
suspendCoroutine<Unit> { cont ->
|
||||
callback = {
|
||||
cont.resume(Unit)
|
||||
}
|
||||
}
|
||||
|
||||
throw exception
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
callback()
|
||||
} catch (e: Exception) {
|
||||
if (e !== exception) return "Fail"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1281
|
||||
// ES_MODULES
|
||||
// CALL_MAIN
|
||||
|
||||
var o: String = "fail O"
|
||||
var k: String = "K"
|
||||
|
||||
fun main() {
|
||||
k = "fail K"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (args.size != 0) error("Fail")
|
||||
|
||||
o = "O"
|
||||
}
|
||||
|
||||
fun box() = o + k
|
||||
@@ -0,0 +1,7 @@
|
||||
package foo.bar
|
||||
|
||||
var ok = "Fail"
|
||||
|
||||
fun main() {
|
||||
ok = "OK"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package foo.bar
|
||||
|
||||
var ok = "OK"
|
||||
|
||||
fun main(args: Array<Int>) {
|
||||
ok += "Fail Int"
|
||||
}
|
||||
|
||||
fun main(args: Array<in String>) {
|
||||
ok += "Fail IN"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>): Unit? {
|
||||
ok += "Fail return Unit?"
|
||||
return Unit
|
||||
}
|
||||
|
||||
fun Any.main(args: Array<String>) {
|
||||
ok += "Fail Any.main(...)"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package foo.bar
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
var ok: String = "fail"
|
||||
|
||||
var callback: () -> Unit = {}
|
||||
|
||||
suspend fun main(args: Array<String>) {
|
||||
if (0 != args.size) error("Fail")
|
||||
|
||||
suspendCoroutine<Unit> { cont ->
|
||||
callback = {
|
||||
cont.resume(Unit)
|
||||
}
|
||||
}
|
||||
|
||||
ok = "OK"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package foo.bar
|
||||
|
||||
var ok = "fail"
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (args.size != 0) {
|
||||
ok = "Fail with args zie"
|
||||
} else {
|
||||
ok = "OK"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package foo
|
||||
|
||||
import foo.bar.ok
|
||||
|
||||
fun main() {
|
||||
ok = "OK2"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
var ok = "Fail"
|
||||
fun main() {
|
||||
ok = "OK"
|
||||
}
|
||||
fun box(stepId: Int): String {
|
||||
return when (stepId) {
|
||||
0 -> ok
|
||||
else -> "Unknown"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import foo.bar.ok
|
||||
|
||||
fun box(stepId: Int): String {
|
||||
return when (stepId) {
|
||||
0 -> ok
|
||||
1 -> ok
|
||||
2 -> ok
|
||||
3 -> ok
|
||||
4 -> ok
|
||||
5 -> if (ok != "OK2") "Fail" else "OK"
|
||||
else -> "Unknown"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import foo.bar.ok
|
||||
import foo.bar.callback
|
||||
|
||||
fun box(stepId: Int): String {
|
||||
return when (stepId) {
|
||||
0 -> ok
|
||||
1 -> ok
|
||||
2 -> ok
|
||||
3 -> {
|
||||
if (ok != "fail") return "Fail"
|
||||
callback()
|
||||
ok
|
||||
}
|
||||
4 -> ok
|
||||
5 -> if (ok != "OK2") "Fail" else "OK"
|
||||
else -> "Unknown"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import foo.bar.ok
|
||||
|
||||
fun box(stepId: Int): String {
|
||||
return when (stepId) {
|
||||
0 -> ok
|
||||
1 -> ok
|
||||
2 -> ok
|
||||
3 -> ok
|
||||
4 -> ok
|
||||
5 -> if (ok != "OK2") "Fail" else "OK"
|
||||
else -> "Unknown"
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
STEP 0:
|
||||
modifications:
|
||||
U : m.0.kt -> m.kt
|
||||
added file: m.kt
|
||||
STEP 1:
|
||||
modifications:
|
||||
U : m.1.kt -> m.kt
|
||||
U : f.1.kt -> f.kt
|
||||
added file: f.kt
|
||||
modified ir: m.kt
|
||||
STEP 2:
|
||||
modifications:
|
||||
U : f.2.kt -> f.kt
|
||||
modified ir: f.kt
|
||||
STEP 3:
|
||||
modifications:
|
||||
U : f.3.kt -> f.kt
|
||||
U : m.3.kt -> m.kt
|
||||
modified ir: f.kt, m.kt
|
||||
STEP 4:
|
||||
modifications:
|
||||
U : f.4.kt -> f.kt
|
||||
U : m.4.kt -> m.kt
|
||||
modified ir: f.kt, m.kt
|
||||
STEP 5:
|
||||
modifications:
|
||||
U : l.5.kt -> l.kt
|
||||
added file: l.kt
|
||||
updated exports: f.kt
|
||||
@@ -0,0 +1,27 @@
|
||||
MODULES: main
|
||||
CALL_MAIN: true
|
||||
|
||||
STEP 0:
|
||||
libs: main
|
||||
dirty js modules: main
|
||||
dirty js files: main/m, main/m.export, main
|
||||
STEP 1:
|
||||
libs: main
|
||||
dirty js modules: main
|
||||
dirty js files: main/foo/bar/f, main/m, main
|
||||
STEP 2:
|
||||
libs: main
|
||||
dirty js modules: main
|
||||
dirty js files: main/foo/bar/f, main
|
||||
STEP 3:
|
||||
libs: main
|
||||
dirty js modules: main
|
||||
dirty js files: main/foo/bar/f, main/m, main
|
||||
STEP 4:
|
||||
libs: main
|
||||
dirty js modules: main
|
||||
dirty js files: main/foo/bar/f, main/m, main
|
||||
STEP 5:
|
||||
libs: main
|
||||
dirty js modules: main
|
||||
dirty js files: main/foo/l, main/foo/bar/f, main
|
||||
Reference in New Issue
Block a user