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:
@@ -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'),
|
||||
|
||||
+5
-1
@@ -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.
|
||||
|
||||
+2
-1
@@ -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 ->
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
Reference in New Issue
Block a user