diff --git a/HACKING.md b/HACKING.md index 2a62cf43490..af450c6341c 100644 --- a/HACKING.md +++ b/HACKING.md @@ -12,14 +12,6 @@ There are several gradle flags one can use for Konan build. ./gradlew -Pshims=true dist -* **-Pfilter** allows one to choose test files to run. - - ./gradlew -Pfilter=overflowLong.kt run_external - -* **-Pprefix** allows one to choose external test directories to run. Only tests from directories with given prefix will be executed. - - ./gradlew -Pprefix=external_codegen_box_cast run_external - ## Compiler environment variables * **KONAN_DATA_DIR** changes `.konan` local data directory location (`$HOME/.konan` by default). Works both with cli compiler and gradle plugin @@ -36,6 +28,14 @@ To update the blackbox compiler tests set TeamCity build number in `gradle.prope and run `./gradlew update_external_tests` +* **-Pfilter** allows one to choose test files to run. + + ./gradlew -Pfilter=overflowLong.kt run_external + +* **-Pprefix** allows one to choose external test directories to run. Only tests from directories with given prefix will be executed. + + ./gradlew -Pprefix=external_codegen_box_cast run_external + * **-Ptest_flags** passes flags to the compiler used to compile tests ./gradlew -Ptest_flags="--time" backend.native:tests:array0 @@ -46,5 +46,9 @@ and run `./gradlew update_external_tests` * **-Premote=user@host** sets remote test execution login/hostname. Good for cross compiled tests. - ./gradles -Premote=kotlin@111.22.33.444 backend.native:tests:run + ./gradlew -Premote=kotlin@111.22.33.444 backend.native:tests:run + +* **-Ptest_verbose** enables printing compiler args and other helpful information during a test execution. + + ./gradlew -Ptest_verbose :backend.native:tests:mpp_optional_expectation diff --git a/backend.native/build.gradle b/backend.native/build.gradle index 7a38e97fbfb..46ec8c7c20d 100644 --- a/backend.native/build.gradle +++ b/backend.native/build.gradle @@ -185,6 +185,7 @@ targetList.each { target -> '-Xuse-experimental=kotlin.ExperimentalMultiplatform', '-Xallow-result-return-type', commonSrc.absolutePath, + "-Xcommon-sources=${commonSrc.absolutePath}", project(':Interop:Runtime').file('src/main/kotlin'), project(':Interop:Runtime').file('src/native/kotlin'), project(':Interop:JsRuntime').file('src/main/kotlin'), diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/DescriptorTable.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/DescriptorTable.kt index 9b845239fad..61e1cdb0d05 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/DescriptorTable.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/DescriptorTable.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.DescriptorUtils +import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker import org.jetbrains.kotlin.resolve.constants.StringValue import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.types.TypeUtils @@ -36,6 +37,9 @@ internal fun DeclarationDescriptor.symbolName(): String = when (this) { internal val DeclarationDescriptor.uniqId get() = this.symbolName().localHash.value +internal val DeclarationDescriptor.isSerializableExpectClass: Boolean + get() = this is ClassDescriptor && ExpectedActualDeclarationChecker.shouldGenerateExpectClass(this) + // TODO: We don't manage id clashes anyhow now. class DescriptorTable(val builtIns: IrBuiltIns) { @@ -95,7 +99,7 @@ val IrBuiltIns.irBuiltInDescriptors * and so should be computable from the descriptor itself without checking a backend state. */ internal tailrec fun DeclarationDescriptor.isExported(): Boolean { - assert(!this.isExpectMember) { this } + assert(!this.isExpectMember || this.isSerializableExpectClass) { this } if (this.annotations.findAnnotation(ContractsDslNames.CONTRACTS_DSL_ANNOTATION_FQN) != null) { // TODO: Seems like this should be deleted in PsiToIR. diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanSerializationUtil.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanSerializationUtil.kt index 17803507adb..58df04da370 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanSerializationUtil.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanSerializationUtil.kt @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion import org.jetbrains.kotlin.metadata.konan.KonanProtoBuf import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.DescriptorUtils +import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker import org.jetbrains.kotlin.resolve.descriptorUtil.module import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.serialization.KonanDescriptorSerializer @@ -83,7 +84,7 @@ internal class KonanSerializationUtil(val context: Context, metadataVersion: Bin val classifierDescriptors = KonanDescriptorSerializer.sort( fragments.flatMap { it.getMemberScope().getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS) - }.filter { !it.isExpectMember } + }.filter { !it.isExpectMember || it.isSerializableExpectClass } ) val members = fragments.flatMap { fragment -> diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index 78faf32b67d..6c703866713 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -2317,7 +2317,7 @@ task mpp_optional_expectation(type: RunStandaloneKonanTest) { def outputRoot = project.ext."$outputSourceSetName" flags = [ '-Xmulti-platform', - "-Xcommon-sources=${file("$outputRoot/$name/mpp_optional_expectation.kt")}" + "-Xcommon-sources=$outputRoot/$name/mpp_optional_expectation.kt" ] } diff --git a/backend.native/tests/codegen/mpp/mpp_optional_expectation.kt b/backend.native/tests/codegen/mpp/mpp_optional_expectation.kt index 52fd1175580..42ff5550055 100644 --- a/backend.native/tests/codegen/mpp/mpp_optional_expectation.kt +++ b/backend.native/tests/codegen/mpp/mpp_optional_expectation.kt @@ -1,10 +1,17 @@ @file:Suppress("EXPERIMENTAL_API_USAGE_ERROR") + +import kotlin.js.* + @OptionalExpectation expect annotation class Optional() @Optional fun foo() { println(42) } +@JsName("jsBar") +fun bar() { println(43) } + fun main(args: Array) { foo() + bar() } \ No newline at end of file diff --git a/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy b/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy index c327c9e1a45..d80da9b1206 100644 --- a/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy +++ b/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy @@ -118,7 +118,10 @@ abstract class KonanTest extends JavaExec { if (enableKonanAssertions) { args "-ea" } - println(args) + if (project.hasProperty("test_verbose")) { + println("Files to compile: $filesToCompile") + println(args) + } standardOutput = log errorOutput = log super.exec()