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:
Ilya Matveev
2018-09-13 14:39:29 +03:00
committed by GitHub
parent 87ce2dc0b5
commit 3e4f5fd4a2
7 changed files with 33 additions and 13 deletions
+13 -9
View File
@@ -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
+1
View File
@@ -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'),
@@ -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.
@@ -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 ->
+1 -1
View File
@@ -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"
]
}
@@ -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<String>) {
foo()
bar()
}
@@ -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()