Support OptionalExpectation in serializer (#2048)
* [serializer] Support OptionalExpectation * Fix OptionalExectation test for Windows * [tests] Don't print compiler args by default
This commit is contained in:
+13
-9
@@ -12,14 +12,6 @@ There are several gradle flags one can use for Konan build.
|
|||||||
|
|
||||||
./gradlew -Pshims=true dist
|
./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
|
## Compiler environment variables
|
||||||
|
|
||||||
* **KONAN_DATA_DIR** changes `.konan` local data directory location (`$HOME/.konan` by default). Works both with cli compiler and gradle plugin
|
* **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`
|
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
|
* **-Ptest_flags** passes flags to the compiler used to compile tests
|
||||||
|
|
||||||
./gradlew -Ptest_flags="--time" backend.native:tests:array0
|
./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.
|
* **-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
|
||||||
|
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ targetList.each { target ->
|
|||||||
'-Xuse-experimental=kotlin.ExperimentalMultiplatform',
|
'-Xuse-experimental=kotlin.ExperimentalMultiplatform',
|
||||||
'-Xallow-result-return-type',
|
'-Xallow-result-return-type',
|
||||||
commonSrc.absolutePath,
|
commonSrc.absolutePath,
|
||||||
|
"-Xcommon-sources=${commonSrc.absolutePath}",
|
||||||
project(':Interop:Runtime').file('src/main/kotlin'),
|
project(':Interop:Runtime').file('src/main/kotlin'),
|
||||||
project(':Interop:Runtime').file('src/native/kotlin'),
|
project(':Interop:Runtime').file('src/native/kotlin'),
|
||||||
project(':Interop:JsRuntime').file('src/main/kotlin'),
|
project(':Interop:JsRuntime').file('src/main/kotlin'),
|
||||||
|
|||||||
+5
-1
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
|||||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
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.constants.StringValue
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||||
import org.jetbrains.kotlin.types.TypeUtils
|
import org.jetbrains.kotlin.types.TypeUtils
|
||||||
@@ -36,6 +37,9 @@ internal fun DeclarationDescriptor.symbolName(): String = when (this) {
|
|||||||
internal val DeclarationDescriptor.uniqId
|
internal val DeclarationDescriptor.uniqId
|
||||||
get() = this.symbolName().localHash.value
|
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.
|
// TODO: We don't manage id clashes anyhow now.
|
||||||
class DescriptorTable(val builtIns: IrBuiltIns) {
|
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.
|
* and so should be computable from the descriptor itself without checking a backend state.
|
||||||
*/
|
*/
|
||||||
internal tailrec fun DeclarationDescriptor.isExported(): Boolean {
|
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) {
|
if (this.annotations.findAnnotation(ContractsDslNames.CONTRACTS_DSL_ANNOTATION_FQN) != null) {
|
||||||
// TODO: Seems like this should be deleted in PsiToIR.
|
// TODO: Seems like this should be deleted in PsiToIR.
|
||||||
|
|||||||
+2
-1
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
|||||||
import org.jetbrains.kotlin.metadata.konan.KonanProtoBuf
|
import org.jetbrains.kotlin.metadata.konan.KonanProtoBuf
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
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.descriptorUtil.module
|
||||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||||
import org.jetbrains.kotlin.serialization.KonanDescriptorSerializer
|
import org.jetbrains.kotlin.serialization.KonanDescriptorSerializer
|
||||||
@@ -83,7 +84,7 @@ internal class KonanSerializationUtil(val context: Context, metadataVersion: Bin
|
|||||||
val classifierDescriptors = KonanDescriptorSerializer.sort(
|
val classifierDescriptors = KonanDescriptorSerializer.sort(
|
||||||
fragments.flatMap {
|
fragments.flatMap {
|
||||||
it.getMemberScope().getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS)
|
it.getMemberScope().getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS)
|
||||||
}.filter { !it.isExpectMember }
|
}.filter { !it.isExpectMember || it.isSerializableExpectClass }
|
||||||
)
|
)
|
||||||
|
|
||||||
val members = fragments.flatMap { fragment ->
|
val members = fragments.flatMap { fragment ->
|
||||||
|
|||||||
@@ -2317,7 +2317,7 @@ task mpp_optional_expectation(type: RunStandaloneKonanTest) {
|
|||||||
def outputRoot = project.ext."$outputSourceSetName"
|
def outputRoot = project.ext."$outputSourceSetName"
|
||||||
flags = [
|
flags = [
|
||||||
'-Xmulti-platform',
|
'-Xmulti-platform',
|
||||||
"-Xcommon-sources=${file("$outputRoot/$name/mpp_optional_expectation.kt")}"
|
"-Xcommon-sources=$outputRoot/$name/mpp_optional_expectation.kt"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
@file:Suppress("EXPERIMENTAL_API_USAGE_ERROR")
|
@file:Suppress("EXPERIMENTAL_API_USAGE_ERROR")
|
||||||
|
|
||||||
|
import kotlin.js.*
|
||||||
|
|
||||||
@OptionalExpectation
|
@OptionalExpectation
|
||||||
expect annotation class Optional()
|
expect annotation class Optional()
|
||||||
|
|
||||||
@Optional
|
@Optional
|
||||||
fun foo() { println(42) }
|
fun foo() { println(42) }
|
||||||
|
|
||||||
|
@JsName("jsBar")
|
||||||
|
fun bar() { println(43) }
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
foo()
|
foo()
|
||||||
|
bar()
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,10 @@ abstract class KonanTest extends JavaExec {
|
|||||||
if (enableKonanAssertions) {
|
if (enableKonanAssertions) {
|
||||||
args "-ea"
|
args "-ea"
|
||||||
}
|
}
|
||||||
println(args)
|
if (project.hasProperty("test_verbose")) {
|
||||||
|
println("Files to compile: $filesToCompile")
|
||||||
|
println(args)
|
||||||
|
}
|
||||||
standardOutput = log
|
standardOutput = log
|
||||||
errorOutput = log
|
errorOutput = log
|
||||||
super.exec()
|
super.exec()
|
||||||
|
|||||||
Reference in New Issue
Block a user