mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-10 08:31:29 +00:00
Expect/actual support in klibs under -Xklib-mpp
This commit is contained in:
committed by
alexander-gorshenev
parent
218d7c31ed
commit
dc8240c24e
@@ -320,6 +320,12 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
)
|
||||
var useMixedNamedArguments: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xklib-mpp",
|
||||
description = "Enable experimental support for multi-platform klib libraries"
|
||||
)
|
||||
var klibBasedMpp: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(value = "-Xdisable-default-scripting-plugin", description = "Do not enable scripting plugin by default")
|
||||
var disableDefaultScriptingPlugin: Boolean by FreezableVar(false)
|
||||
|
||||
@@ -341,6 +347,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
collector.report(CompilerMessageSeverity.WARNING, "'-Xexperimental' is deprecated and will be removed in a future release")
|
||||
}
|
||||
put(AnalysisFlags.useExperimental, useExperimental?.toList().orEmpty() + optIn?.toList().orEmpty())
|
||||
put(AnalysisFlags.klibBasedMpp, klibBasedMpp)
|
||||
put(AnalysisFlags.explicitApiVersion, apiVersion != null)
|
||||
put(AnalysisFlags.allowResultReturnType, allowResultReturnType)
|
||||
ExplicitApiMode.fromString(explicitApi)?.also { put(AnalysisFlags.explicitApiMode, it) } ?: collector.report(
|
||||
|
||||
@@ -23,6 +23,7 @@ fun <A : CommonCompilerArguments> CompilerConfiguration.setupCommonArguments(
|
||||
) {
|
||||
put(CommonConfigurationKeys.DISABLE_INLINE, arguments.noInline)
|
||||
put(CommonConfigurationKeys.USE_FIR, arguments.useFir)
|
||||
put(CommonConfigurationKeys.KLIB_MPP, arguments.klibBasedMpp)
|
||||
putIfNotNull(CLIConfigurationKeys.INTELLIJ_PLUGIN_ROOT, arguments.intellijPluginRoot)
|
||||
put(CommonConfigurationKeys.REPORT_OUTPUT_FILES, arguments.reportOutputFiles)
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@ object AnalysisFlags {
|
||||
@JvmStatic
|
||||
val multiPlatformDoNotCheckActual by AnalysisFlag.Delegates.Boolean
|
||||
|
||||
@JvmStatic
|
||||
val klibBasedMpp by AnalysisFlag.Delegates.Boolean
|
||||
|
||||
@JvmStatic
|
||||
val experimental by AnalysisFlag.Delegates.ListOfStrings
|
||||
|
||||
|
||||
@@ -44,6 +44,9 @@ object CommonConfigurationKeys {
|
||||
|
||||
@JvmField
|
||||
val USE_FIR = CompilerConfigurationKey.create<Boolean>("front-end IR")
|
||||
|
||||
@JvmField
|
||||
val KLIB_MPP = CompilerConfigurationKey.create<Boolean>("Klib based MPP")
|
||||
}
|
||||
|
||||
var CompilerConfiguration.languageVersionSettings: LanguageVersionSettings
|
||||
|
||||
@@ -54,6 +54,8 @@ class ExpectedActualDeclarationChecker(
|
||||
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||
if (!context.languageVersionSettings.supportsFeature(LanguageFeature.MultiPlatformProjects)) return
|
||||
// TODO: we need a klib based MPP aware ModuleStructureOracle. Just disable the checks for now.
|
||||
if (context.languageVersionSettings.getFlag(AnalysisFlags.klibBasedMpp)) return
|
||||
|
||||
// Note that this check is necessary, because for default accessors KtProperty is passed for KtDeclaration, so this
|
||||
// case won't be covered by the next check (also, it accidentally fixes KT-28385)
|
||||
|
||||
@@ -5,12 +5,20 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.ir
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
|
||||
val IrDeclaration.isExpect
|
||||
get() = this is IrClass && isExpect ||
|
||||
this is IrFunction && isExpect ||
|
||||
this is IrProperty && isExpect
|
||||
this is IrProperty && isExpect
|
||||
|
||||
// The original isExpect represents what user has written.
|
||||
// This predicate means "there can possibly exist an 'actual' for the given declaration".
|
||||
// Shouldn't it be incorporated to descriptor -> ir declaration psi2ir translation phase?
|
||||
val IrDeclaration.isProperExpect
|
||||
get() = this is IrClass && isExpect ||
|
||||
this is IrFunction && isExpect ||
|
||||
this is IrProperty && isExpect ||
|
||||
(this is IrClass || this is IrFunction || this is IrProperty || this is IrConstructor || this is IrEnumEntry)
|
||||
&& (this.parent as? IrDeclaration)?.isExpect ?: false
|
||||
|
||||
|
||||
@@ -82,6 +82,8 @@ fun compile(
|
||||
ExternalDependenciesGenerator(symbolTable, irProvidersWithoutDeserializer).generateUnboundSymbolsAsDependencies()
|
||||
moduleFragment.patchDeclarationParents()
|
||||
|
||||
deserializer.finalizeExpectActualLinker()
|
||||
|
||||
moveBodilessDeclarationsToSeparatePlace(context, moduleFragment)
|
||||
|
||||
jsPhases.invokeToplevel(phaseConfig, context, moduleFragment)
|
||||
|
||||
@@ -47,7 +47,7 @@ object JvmBackendFacade {
|
||||
psi2irContext.moduleDescriptor, psi2irContext.irBuiltIns, psi2irContext.symbolTable,
|
||||
extensions = extensions
|
||||
)
|
||||
val irModuleFragment = psi2ir.generateModuleFragment(psi2irContext, files, irProviders = irProviders)
|
||||
val irModuleFragment = psi2ir.generateModuleFragment(psi2irContext, files, irProviders = irProviders, expectDescriptorToSymbol = null)
|
||||
doGenerateFilesInternal(
|
||||
state, irModuleFragment, psi2irContext.symbolTable, psi2irContext.sourceManager, phaseConfig, irProviders, extensions
|
||||
)
|
||||
|
||||
@@ -51,6 +51,7 @@ fun compileWasm(
|
||||
val irProviders = generateTypicalIrProviderList(moduleDescriptor, irBuiltIns, symbolTable, deserializer)
|
||||
ExternalDependenciesGenerator(symbolTable, irProviders).generateUnboundSymbolsAsDependencies()
|
||||
moduleFragment.patchDeclarationParents()
|
||||
deserializer.finalizeExpectActualLinker()
|
||||
|
||||
wasmPhases.invokeToplevel(phaseConfig, context, moduleFragment)
|
||||
|
||||
|
||||
@@ -17,16 +17,15 @@
|
||||
package org.jetbrains.kotlin.psi2ir
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi2ir.generators.AnnotationGenerator
|
||||
import org.jetbrains.kotlin.psi2ir.generators.GeneratorContext
|
||||
import org.jetbrains.kotlin.psi2ir.generators.GeneratorExtensions
|
||||
import org.jetbrains.kotlin.psi2ir.generators.ModuleGenerator
|
||||
import org.jetbrains.kotlin.psi2ir.generators.*
|
||||
import org.jetbrains.kotlin.psi2ir.transformations.insertImplicitCasts
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
@@ -68,11 +67,13 @@ class Psi2IrTranslator(
|
||||
fun generateModuleFragment(
|
||||
context: GeneratorContext,
|
||||
ktFiles: Collection<KtFile>,
|
||||
irProviders: List<IrProvider>
|
||||
irProviders: List<IrProvider>,
|
||||
expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>? = null
|
||||
): IrModuleFragment {
|
||||
val moduleGenerator = ModuleGenerator(context)
|
||||
val irModule = moduleGenerator.generateModuleFragmentWithoutDependencies(ktFiles)
|
||||
|
||||
expectDescriptorToSymbol ?. let { referenceExpectsForUsedActuals(it, context.symbolTable, irModule) }
|
||||
irModule.patchDeclarationParents()
|
||||
postprocess(context, irModule)
|
||||
// do not generate unbound symbols before postprocessing,
|
||||
@@ -81,6 +82,7 @@ class Psi2IrTranslator(
|
||||
irModule.computeUniqIdForDeclarations(context.symbolTable)
|
||||
|
||||
moduleGenerator.generateUnboundSymbolsAsDependencies(irProviders)
|
||||
|
||||
return irModule
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package org.jetbrains.kotlin.psi2ir.generators
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.types.classOrNull
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||
import org.jetbrains.kotlin.resolve.multiplatform.findExpects
|
||||
|
||||
// Need to create unbound symbols for expects corresponding to actuals of the currently compiled module.
|
||||
// This is neccessary because there is no explicit links between expects and actuals
|
||||
// neither in descriptors nor in IR.
|
||||
fun referenceExpectsForUsedActuals(expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>, symbolTable: SymbolTable, irModule: IrModuleFragment) {
|
||||
irModule.acceptVoid(object : IrElementVisitorVoid {
|
||||
|
||||
private fun <T> T.forEachExpect(body: (DeclarationDescriptor) -> Unit) where T: IrDeclaration {
|
||||
this.descriptor.findExpects().forEach {
|
||||
body(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitElement(element: IrElement) {
|
||||
element.acceptChildrenVoid(this)
|
||||
}
|
||||
override fun visitClass(declaration: IrClass) {
|
||||
declaration.forEachExpect {
|
||||
val symbol = symbolTable.referenceClass(it as ClassDescriptor)
|
||||
expectDescriptorToSymbol.put(it, symbol);
|
||||
it.constructors.forEach {
|
||||
expectDescriptorToSymbol.put(it, symbolTable.referenceConstructor(it as ClassConstructorDescriptor))
|
||||
}
|
||||
}
|
||||
super.visitDeclaration(declaration)
|
||||
}
|
||||
override fun visitSimpleFunction(declaration: IrSimpleFunction) {
|
||||
declaration.forEachExpect {
|
||||
val symbol = symbolTable.referenceSimpleFunction(it as FunctionDescriptor);
|
||||
expectDescriptorToSymbol.put(it, symbol);
|
||||
}
|
||||
super.visitDeclaration(declaration)
|
||||
}
|
||||
override fun visitConstructor(declaration: IrConstructor) {
|
||||
declaration.forEachExpect {
|
||||
val symbol = symbolTable.referenceConstructor(it as ClassConstructorDescriptor)
|
||||
expectDescriptorToSymbol.put(it, symbol);
|
||||
|
||||
}
|
||||
super.visitDeclaration(declaration)
|
||||
}
|
||||
override fun visitProperty(declaration: IrProperty) {
|
||||
declaration.forEachExpect {
|
||||
val symbol = symbolTable.referenceProperty(it as PropertyDescriptor)
|
||||
expectDescriptorToSymbol.put(it, symbol);
|
||||
}
|
||||
super.visitDeclaration(declaration)
|
||||
}
|
||||
override fun visitEnumEntry(declaration: IrEnumEntry) {
|
||||
declaration.forEachExpect {
|
||||
val symbol = symbolTable.referenceEnumEntry(it as ClassDescriptor)
|
||||
expectDescriptorToSymbol.put(it, symbol);
|
||||
|
||||
}
|
||||
super.visitDeclaration(declaration)
|
||||
}
|
||||
override fun visitTypeAlias(declaration: IrTypeAlias) {
|
||||
// Force actual type alias right hand side deserialization.
|
||||
if (declaration.isActual) {
|
||||
declaration.expandedType.classOrNull?.descriptor?.let { symbolTable.referenceClass(it) }
|
||||
}
|
||||
|
||||
declaration.forEachExpect {
|
||||
val symbol = when (it) {
|
||||
is ClassDescriptor -> symbolTable.referenceClass(it)
|
||||
else -> error("Unexpected expect for actual type alias: $it")
|
||||
}
|
||||
expectDescriptorToSymbol.put(it, symbol);
|
||||
|
||||
}
|
||||
super.visitDeclaration(declaration)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -22,11 +22,7 @@ import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrModuleFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator
|
||||
import org.jetbrains.kotlin.ir.util.IrDeserializer
|
||||
import org.jetbrains.kotlin.ir.util.IrProvider
|
||||
import org.jetbrains.kotlin.ir.util.StubGeneratorExtensions
|
||||
import org.jetbrains.kotlin.ir.util.generateTypicalIrProviderList
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.findPackageFragmentForFile
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.jetbrains.kotlin.ir.symbols
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.util.UniqId
|
||||
|
||||
abstract class IrDelegatingSymbol<S: IrBindableSymbol<D, B>, B: IrSymbolOwner, D: DeclarationDescriptor>(var delegate: S)
|
||||
: IrBindableSymbol<D, B> {
|
||||
override val owner: B get() = delegate.owner
|
||||
override val descriptor: D get() = delegate.descriptor
|
||||
override val isBound: Boolean get() = delegate.isBound
|
||||
override var uniqId: UniqId
|
||||
get() = delegate.uniqId
|
||||
set(value: UniqId) { delegate.uniqId = value }
|
||||
|
||||
override fun bind(owner: B) = delegate.bind(owner)
|
||||
override fun hashCode() = delegate.hashCode()
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (this === delegate) return true
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
class IrDelegatingClassSymbolImpl(delegate: IrClassSymbol) :
|
||||
IrClassSymbol, IrDelegatingSymbol<IrClassSymbol, IrClass, ClassDescriptor>(delegate)
|
||||
|
||||
class IrDelegatingEnumEntrySymbolImpl(delegate: IrEnumEntrySymbol) :
|
||||
IrEnumEntrySymbol, IrDelegatingSymbol<IrEnumEntrySymbol, IrEnumEntry, ClassDescriptor>(delegate)
|
||||
|
||||
class IrDelegatingSimpleFunctionSymbolImpl(delegate: IrSimpleFunctionSymbol) :
|
||||
IrSimpleFunctionSymbol, IrDelegatingSymbol<IrSimpleFunctionSymbol, IrSimpleFunction, FunctionDescriptor>(delegate)
|
||||
|
||||
class IrDelegatingConstructorSymbolImpl(delegate: IrConstructorSymbol) :
|
||||
IrConstructorSymbol, IrDelegatingSymbol<IrConstructorSymbol, IrConstructor, ClassConstructorDescriptor>(delegate)
|
||||
|
||||
class IrDelegatingPropertySymbolImpl(delegate: IrPropertySymbol) :
|
||||
IrPropertySymbol, IrDelegatingSymbol<IrPropertySymbol, IrProperty, PropertyDescriptor>(delegate)
|
||||
|
||||
class IrDelegatingTypeAliasSymbolImpl(delegate: IrTypeAliasSymbol) :
|
||||
IrTypeAliasSymbol, IrDelegatingSymbol<IrTypeAliasSymbol, IrTypeAlias, TypeAliasDescriptor>(delegate)
|
||||
|
||||
fun wrapInDelegatedSymbol(delegate: IrSymbol) = when(delegate) {
|
||||
is IrClassSymbol -> IrDelegatingClassSymbolImpl(delegate)
|
||||
is IrEnumEntrySymbol -> IrDelegatingEnumEntrySymbolImpl(delegate)
|
||||
is IrSimpleFunctionSymbol -> IrDelegatingSimpleFunctionSymbolImpl(delegate)
|
||||
is IrConstructorSymbol -> IrDelegatingConstructorSymbolImpl(delegate)
|
||||
is IrPropertySymbol -> IrDelegatingPropertySymbolImpl(delegate)
|
||||
is IrTypeAliasSymbol -> IrDelegatingTypeAliasSymbolImpl(delegate)
|
||||
else -> error("Unexpected symbol to delegate to: $delegate")
|
||||
}
|
||||
@@ -81,6 +81,7 @@ message IrFile {
|
||||
repeated int32 fq_name = 3;
|
||||
repeated IrConstructorCall annotation = 4;
|
||||
repeated int32 explicitly_exported_to_compiler = 5;
|
||||
repeated Actual actuals = 6;
|
||||
}
|
||||
|
||||
/* ------ IrSymbols --------------------------------------------- */
|
||||
@@ -113,6 +114,11 @@ message IrSymbolData {
|
||||
optional DescriptorReference descriptor_reference = 7;
|
||||
}
|
||||
|
||||
message Actual {
|
||||
required int32 actual_symbol = 1;
|
||||
required int32 expect_symbol = 2;
|
||||
}
|
||||
|
||||
/* ------ IrTypes --------------------------------------------- */
|
||||
|
||||
enum IrTypeVariance { // Should we import metadata variance, or better stay separate?
|
||||
|
||||
@@ -14,7 +14,8 @@ enum class DescriptorReferenceFlags {
|
||||
IS_DEFAULT_CONSTRUCTOR,
|
||||
IS_ENUM_ENTRY,
|
||||
IS_ENUM_SPECIAL,
|
||||
IS_TYPE_PARAMETER;
|
||||
IS_TYPE_PARAMETER,
|
||||
IS_EXPECT;
|
||||
|
||||
fun encode(isSet: Boolean): Int = if (isSet) 1 shl ordinal else 0
|
||||
fun decode(flags: Int): Boolean = (flags and (1 shl ordinal) != 0)
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
import org.jetbrains.kotlin.resolve.multiplatform.ExpectedActualResolver
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
|
||||
|
||||
@@ -87,6 +88,21 @@ abstract class DescriptorReferenceDeserializer(
|
||||
return ClassMembers(classConstructorDescriptor, allMembersMap, realMembersMap)
|
||||
}
|
||||
|
||||
// TODO: the real findExpects() returns a list.
|
||||
// Need to account for multiple expects here.
|
||||
private fun MemberDescriptor.toExpect() =
|
||||
if (this.isExpect)
|
||||
this
|
||||
else
|
||||
ExpectedActualResolver.findExpectedForActual(
|
||||
this,
|
||||
currentModule,
|
||||
{ true }
|
||||
)?.get(ExpectedActualResolver.Compatibility.Compatible)?.single()
|
||||
|
||||
private fun Collection<DeclarationDescriptor>.toExpects() = this.map { (it as MemberDescriptor).toExpect() }.filterNotNull().distinct()
|
||||
|
||||
|
||||
open fun deserializeDescriptorReference(
|
||||
packageFqName: FqName,
|
||||
classFqName: FqName,
|
||||
@@ -98,10 +114,21 @@ abstract class DescriptorReferenceDeserializer(
|
||||
val protoIndex = index
|
||||
|
||||
val (clazz, members) = if (classFqName.isRoot) {
|
||||
Pair(null, getContributedDescriptors(packageFqName, name))
|
||||
Pair(null,
|
||||
getContributedDescriptors(packageFqName, name).let {
|
||||
if (DescriptorReferenceFlags.IS_EXPECT.decode(flags)) it.toExpects() else it
|
||||
}
|
||||
)
|
||||
} else {
|
||||
val clazz = currentModule.findClassAcrossModuleDependencies(ClassId(packageFqName, classFqName, false))!!
|
||||
Pair(clazz, getContributedDescriptors(clazz.unsubstitutedMemberScope, name) + clazz.getConstructors())
|
||||
val classifier = (currentModule.findClassifierAcrossModuleDependencies(ClassId(packageFqName, classFqName, false)) as? MemberDescriptor)
|
||||
?: error("Could not find class across modules: $packageFqName/$classFqName")
|
||||
|
||||
val expect = if (DescriptorReferenceFlags.IS_EXPECT.decode(flags)) {
|
||||
classifier.toExpect()
|
||||
} else null
|
||||
|
||||
val expectOrActualClass = (expect as ClassDescriptor?) ?: (classifier as ClassDescriptor) // TODO: OMG!!!
|
||||
Pair(expectOrActualClass, getContributedDescriptors(expectOrActualClass.unsubstitutedMemberScope, name) + expectOrActualClass.getConstructors())
|
||||
}
|
||||
|
||||
// TODO: This is still native specific. Eliminate.
|
||||
@@ -157,7 +184,7 @@ abstract class DescriptorReferenceDeserializer(
|
||||
|
||||
val membersWithIndices = getMembers(members)
|
||||
|
||||
return when {
|
||||
val result = when {
|
||||
DescriptorReferenceFlags.IS_DEFAULT_CONSTRUCTOR.decode(flags) -> membersWithIndices.defaultConstructor
|
||||
|
||||
else -> {
|
||||
@@ -172,5 +199,11 @@ abstract class DescriptorReferenceDeserializer(
|
||||
}
|
||||
} ?:
|
||||
error("Could not find serialized descriptor for index: ${index} ${packageFqName},${classFqName},${name}")
|
||||
|
||||
// TODO: why we don't have "expect" bit on all the expect declarations?
|
||||
//if (DescriptorReferenceFlags.IS_EXPECT.decode(flags)) assert(if (result is ClassConstructorDescriptor) result.constructedClass.isExpect() else result.isExpectMember) {
|
||||
// "expected expect, found $result"
|
||||
//}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package org.jetbrains.kotlin.backend.common.serialization
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.types.classOrNull
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.resolve.multiplatform.findActuals
|
||||
import org.jetbrains.kotlin.resolve.multiplatform.findExpects
|
||||
|
||||
class ExpectActualTable(val expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>) {
|
||||
val table = mutableMapOf<DeclarationDescriptor, IrSymbol>()
|
||||
|
||||
private fun IrElement.recordActuals(rightHandSide: Map<DeclarationDescriptor, IrSymbol>, inModule: ModuleDescriptor) {
|
||||
this.acceptVoid(object : IrElementVisitorVoid {
|
||||
|
||||
private fun recordDeclarationActuals(declaration: IrDeclaration) {
|
||||
|
||||
expectDescriptorToSymbol.put(declaration.descriptor, (declaration as IrSymbolOwner).symbol)
|
||||
|
||||
declaration.descriptor.findActuals(inModule).forEach {
|
||||
val realActual = if (it is TypeAliasDescriptor)
|
||||
it.expandedType.constructor.declarationDescriptor as? ClassDescriptor
|
||||
?: error("Unexpected actual typealias right hand side: $it")
|
||||
else it
|
||||
|
||||
// TODO: what to do with fake overrides???
|
||||
if (!(realActual is CallableMemberDescriptor && realActual.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE)) {
|
||||
table.put(
|
||||
declaration.descriptor, rightHandSide[realActual]
|
||||
?: error("Could not find actual type alias target member for: ${declaration.descriptor} -> $it")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitElement(element: IrElement) {
|
||||
element.acceptChildrenVoid(this)
|
||||
}
|
||||
|
||||
override fun visitFunction(declaration: IrFunction) {
|
||||
recordDeclarationActuals(declaration)
|
||||
super.visitFunction(declaration)
|
||||
}
|
||||
override fun visitClass(declaration: IrClass) {
|
||||
recordDeclarationActuals(declaration)
|
||||
super.visitClass(declaration)
|
||||
}
|
||||
override fun visitProperty(declaration: IrProperty) {
|
||||
recordDeclarationActuals(declaration)
|
||||
super.visitProperty(declaration)
|
||||
}
|
||||
override fun visitEnumEntry(declaration: IrEnumEntry) {
|
||||
recordDeclarationActuals(declaration)
|
||||
super.visitEnumEntry(declaration)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun IrDeclaration.recordRightHandSide(): Map<DeclarationDescriptor, IrSymbol> {
|
||||
val rightHandSide = mutableMapOf<DeclarationDescriptor, IrSymbol>()
|
||||
|
||||
this.acceptVoid(object : IrElementVisitorVoid {
|
||||
override fun visitElement(element: IrElement) {
|
||||
element.acceptChildrenVoid(this)
|
||||
}
|
||||
override fun visitFunction(declaration: IrFunction) {
|
||||
rightHandSide.put(declaration.descriptor, declaration.symbol)
|
||||
super.visitFunction(declaration)
|
||||
}
|
||||
override fun visitClass(declaration: IrClass) {
|
||||
rightHandSide.put(declaration.descriptor, declaration.symbol)
|
||||
super.visitClass(declaration)
|
||||
}
|
||||
override fun visitProperty(declaration: IrProperty) {
|
||||
rightHandSide.put(declaration.descriptor, declaration.symbol)
|
||||
super.visitProperty(declaration)
|
||||
}
|
||||
override fun visitEnumEntry(declaration: IrEnumEntry) {
|
||||
rightHandSide.put(declaration.descriptor, declaration.symbol)
|
||||
super.visitEnumEntry(declaration)
|
||||
}
|
||||
})
|
||||
return rightHandSide
|
||||
}
|
||||
|
||||
fun findExpectsForActuals(declaration: IrDeclaration) {
|
||||
if (declaration.descriptor !is MemberDescriptor) return
|
||||
if (declaration !is IrSymbolDeclaration<*>) return
|
||||
|
||||
val descriptor = declaration.symbol.descriptor
|
||||
|
||||
if (declaration is IrTypeAlias && declaration.isActual) {
|
||||
val rightHandSide = declaration.expandedType.classOrNull?.owner?.recordRightHandSide()
|
||||
?: error("Unexpected right hand side of actual typealias: ${declaration.descriptor}")
|
||||
|
||||
|
||||
declaration.descriptor.findExpects().forEach {
|
||||
expectDescriptorToSymbol[it]?.owner?.recordActuals(rightHandSide, declaration.descriptor.module)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
val expects: List<MemberDescriptor> = if (descriptor is ClassConstructorDescriptor && descriptor.isPrimary) {
|
||||
(descriptor.containingDeclaration.findExpects() as List<ClassDescriptor>).map {
|
||||
it.unsubstitutedPrimaryConstructor
|
||||
}.filterNotNull()
|
||||
} else {
|
||||
descriptor.findExpects()
|
||||
}
|
||||
|
||||
expects.forEach { expect ->
|
||||
table.put(expect, declaration.symbol)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.findTopLevelDeclaration
|
||||
import org.jetbrains.kotlin.ir.util.lineStartOffsets
|
||||
import org.jetbrains.kotlin.ir.util.module
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||
@@ -115,16 +116,22 @@ import org.jetbrains.kotlin.backend.common.serialization.proto.ModalityKind as P
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.NullableIrExpression as ProtoNullableIrExpression
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.TypeArguments as ProtoTypeArguments
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.Visibility as ProtoVisibility
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.Actual as ProtoActual
|
||||
|
||||
open class IrFileSerializer(
|
||||
val logger: LoggingContext,
|
||||
private val declarationTable: DeclarationTable,
|
||||
private val bodiesOnlyForInlines: Boolean = false
|
||||
private val expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>,
|
||||
private val bodiesOnlyForInlines: Boolean = false,
|
||||
private val skipExpects: Boolean = false
|
||||
) {
|
||||
|
||||
private val loopIndex = mutableMapOf<IrLoop, Int>()
|
||||
private var currentLoopIndex = 0
|
||||
|
||||
// For every actual we keep a corresponding expects' uniqIds.
|
||||
// The linker substitutes actual symbols when asked for an expect uniqId.
|
||||
private val expectActualTable = ExpectActualTable(expectDescriptorToSymbol)
|
||||
|
||||
// The same symbol can be used multiple times in a file
|
||||
// so use this index to store symbol data only once.
|
||||
private val protoSymbolMap = mutableMapOf<IrSymbol, Int>()
|
||||
@@ -141,7 +148,7 @@ open class IrFileSerializer(
|
||||
private val protoBodyArray = mutableListOf<XStatementOrExpression>()
|
||||
|
||||
private val descriptorReferenceSerializer =
|
||||
DescriptorReferenceSerializer(declarationTable, { serializeString(it) }, { serializeFqName(it) })
|
||||
DescriptorReferenceSerializer(declarationTable, { serializeString(it) }, { serializeFqName(it) }, skipExpects)
|
||||
|
||||
sealed class XStatementOrExpression {
|
||||
abstract fun toByteArray(): ByteArray
|
||||
@@ -984,13 +991,15 @@ open class IrFileSerializer(
|
||||
return proto.build()
|
||||
}
|
||||
|
||||
private fun serializeIrDeclarationBase(declaration: IrDeclaration) =
|
||||
ProtoDeclarationBase.newBuilder()
|
||||
private fun serializeIrDeclarationBase(declaration: IrDeclaration): ProtoDeclarationBase {
|
||||
expectActualTable.findExpectsForActuals(declaration)
|
||||
return ProtoDeclarationBase.newBuilder()
|
||||
.setSymbol(serializeIrSymbol((declaration as IrSymbolOwner).symbol))
|
||||
.setCoordinates(serializeCoordinates(declaration.startOffset, declaration.endOffset))
|
||||
.addAllAnnotation(serializeAnnotations(declaration.annotations))
|
||||
.setOrigin(serializeIrDeclarationOrigin(declaration.origin))
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun serializeIrValueParameter(parameter: IrValueParameter): ProtoValueParameter {
|
||||
val proto = ProtoValueParameter.newBuilder()
|
||||
@@ -1280,7 +1289,7 @@ open class IrFileSerializer(
|
||||
.addAllAnnotation(serializeAnnotations(file.annotations))
|
||||
|
||||
file.declarations.forEach {
|
||||
if (it.descriptor.isExpectMember && !it.descriptor.isSerializableExpectClass) {
|
||||
if (skipExpects && it.descriptor.isExpectMember && !it.descriptor.isSerializableExpectClass) {
|
||||
topLevelDeclarations.add(SkippedDeclaration)
|
||||
return@forEach
|
||||
}
|
||||
@@ -1323,6 +1332,8 @@ open class IrFileSerializer(
|
||||
}
|
||||
})
|
||||
|
||||
serializeExpectActualSubstitutionTable(proto)
|
||||
|
||||
return SerializedIrFile(
|
||||
proto.build().toByteArray(),
|
||||
file.fqName.asString(),
|
||||
@@ -1334,4 +1345,23 @@ open class IrFileSerializer(
|
||||
IrMemoryDeclarationWriter(topLevelDeclarations).writeIntoMemory()
|
||||
)
|
||||
}
|
||||
|
||||
fun serializeExpectActualSubstitutionTable(proto: ProtoFile.Builder) {
|
||||
if (skipExpects) return
|
||||
|
||||
expectActualTable.table.forEach next@{ (expect, actualSymbol) ->
|
||||
val expectSymbol = expectDescriptorToSymbol[expect]
|
||||
?: error("Could not find expect symbol for expect descriptor $expect")
|
||||
val expectDeclaration = expectSymbol.owner as IrDeclaration
|
||||
val actualDeclaration = actualSymbol.owner as IrDeclaration
|
||||
|
||||
proto.addActuals(
|
||||
ProtoActual.newBuilder()
|
||||
.setExpectSymbol(serializeIrSymbol(expectSymbol))
|
||||
.setActualSymbol(serializeIrSymbol(actualSymbol))
|
||||
.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,7 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.EmptyPackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrModuleFragmentImpl
|
||||
@@ -21,8 +19,7 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrLoopBase
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrErrorTypeImpl
|
||||
@@ -41,6 +38,7 @@ import org.jetbrains.kotlin.backend.common.serialization.proto.IrType as ProtoTy
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.IrStatement as ProtoStatement
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.IrExpression as ProtoExpression
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall as ProtoConstructorCall
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.Actual as ProtoActual
|
||||
|
||||
abstract class KotlinIrLinker(
|
||||
val logger: LoggingContext,
|
||||
@@ -51,6 +49,10 @@ abstract class KotlinIrLinker(
|
||||
mangler: KotlinMangler
|
||||
) : DescriptorUniqIdAware, IrDeserializer {
|
||||
|
||||
private val expectUniqIdToActualUniqId = mutableMapOf<UniqId, UniqId>()
|
||||
private val topLevelActualUniqItToDeserializer = mutableMapOf<UniqId, IrModuleDeserializer>()
|
||||
private val expectSymbols = mutableMapOf<UniqId, IrSymbol>()
|
||||
private val actualSymbols = mutableMapOf<UniqId, IrSymbol>()
|
||||
|
||||
sealed class DeserializationState<T> {
|
||||
val deserializedSymbols = mutableMapOf<UniqId, IrSymbol>()
|
||||
@@ -139,6 +141,7 @@ abstract class KotlinIrLinker(
|
||||
|
||||
inner class IrDeserializerForFile(
|
||||
private var annotations: List<ProtoConstructorCall>?,
|
||||
private val actuals: List<ProtoActual>,
|
||||
private val fileIndex: Int,
|
||||
onlyHeaders: Boolean
|
||||
) : IrFileDeserializer(logger, builtIns, symbolTable) {
|
||||
@@ -161,6 +164,21 @@ abstract class KotlinIrLinker(
|
||||
return deserializeDeclaration(loadTopLevelDeclarationProto(key), file)
|
||||
}
|
||||
|
||||
fun deserializeExpectActualMapping() {
|
||||
actuals.forEach {
|
||||
val expectSymbol = loadSymbolProto(it.expectSymbol)
|
||||
val actualSymbol = loadSymbolProto(it.actualSymbol)
|
||||
val expect = UniqId(expectSymbol.uniqIdIndex)
|
||||
val actual = UniqId(actualSymbol.uniqIdIndex)
|
||||
assert(expectUniqIdToActualUniqId[expect] == null) {
|
||||
"Expect uniqid ${expect.index} is already actualized by ${expectUniqIdToActualUniqId[expect]?.index}, while we try to record ${actual.index}"
|
||||
}
|
||||
expectUniqIdToActualUniqId.put(expect, actual)
|
||||
// Non-null only for topLevel declarations.
|
||||
getModuleForTopLevelId(actual)?. let { topLevelActualUniqItToDeserializer.put(actual, it) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadTopLevelDeclarationProto(uniqId: UniqId): ProtoDeclaration {
|
||||
val stream = reader(moduleDescriptor, fileIndex, uniqId).codedInputStream
|
||||
return ProtoDeclaration.parseFrom(stream, newInstance())
|
||||
@@ -323,7 +341,14 @@ abstract class KotlinIrLinker(
|
||||
if (it !in fdState) fdState.addUniqID(it)
|
||||
}
|
||||
|
||||
referenceDeserializedSymbol(proto, descriptor)
|
||||
val symbol = referenceDeserializedSymbol(proto, descriptor).let {
|
||||
if (expectUniqIdToActualUniqId[key] != null) wrapInDelegatedSymbol(it) else it
|
||||
}
|
||||
|
||||
if (key in expectUniqIdToActualUniqId.keys) expectSymbols.put(key, symbol)
|
||||
if (key in expectUniqIdToActualUniqId.values) actualSymbols.put(key, symbol)
|
||||
|
||||
symbol
|
||||
}
|
||||
if (symbol.descriptor is ClassDescriptor &&
|
||||
symbol.descriptor !is WrappedDeclarationDescriptor<*> &&
|
||||
@@ -402,7 +427,8 @@ abstract class KotlinIrLinker(
|
||||
val fileEntry = NaiveSourceBasedFileEntryImpl(fileName, fileProto.fileEntry.lineStartOffsetsList.toIntArray())
|
||||
|
||||
val fileDeserializer =
|
||||
IrDeserializerForFile(fileProto.annotationList, fileIndex, !deserializationStrategy.needBodies).apply {
|
||||
IrDeserializerForFile(fileProto.annotationList, fileProto.actualsList, fileIndex, !deserializationStrategy.needBodies).apply {
|
||||
|
||||
// Explicitly exported declarations (e.g. top-level initializers) must be deserialized before all other declarations.
|
||||
// Thus we schedule their deserialization in deserializer's constructor.
|
||||
fileProto.explicitlyExportedToCompilerList.forEach {
|
||||
@@ -555,8 +581,11 @@ abstract class KotlinIrLinker(
|
||||
findDeserializedDeclarationForDescriptor(symbol.descriptor) ?: return null
|
||||
}
|
||||
|
||||
// TODO: we do have serializations for those, but let's just create a stub for now.
|
||||
if (!symbol.isBound && (symbol.descriptor.isExpectMember || symbol.descriptor.containingDeclaration?.isExpectMember ?: false)) return null
|
||||
|
||||
assert(symbol.isBound) {
|
||||
"findDeserializedDeclaration: symbol ${symbol} is unbound, descriptor = ${symbol.descriptor}, hash = ${symbol.descriptor.hashCode()}"
|
||||
"getDeclaration: symbol ${symbol} is unbound, descriptor = ${symbol.descriptor}, hash = ${symbol.descriptor.hashCode()}"
|
||||
}
|
||||
|
||||
return symbol.owner as IrDeclaration
|
||||
@@ -597,6 +626,49 @@ abstract class KotlinIrLinker(
|
||||
}
|
||||
}
|
||||
|
||||
fun initializeExpectActualLinker() {
|
||||
deserializersForModules.values.forEach {
|
||||
it.fileToDeserializerMap.values.forEach {
|
||||
it.deserializeExpectActualMapping()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The issue here is that an expect can not trigger its actual deserialization by reachability
|
||||
// because the expect can not see the actual higher in the module dependency dag.
|
||||
// So we force deserialization of actuals for all deserialized expect symbols here.
|
||||
fun finalizeExpectActualLinker() {
|
||||
expectUniqIdToActualUniqId.filter{ topLevelActualUniqItToDeserializer[it.value] != null}.forEach {
|
||||
val expectSymbol = expectSymbols[it.key]
|
||||
val actualSymbol = actualSymbols[it.value]
|
||||
if (expectSymbol != null && (actualSymbol == null || !actualSymbol.isBound)) {
|
||||
topLevelActualUniqItToDeserializer[it.value]!!.addModuleReachableTopLevel(it.value)
|
||||
deserializeAllReachableTopLevels()
|
||||
}
|
||||
}
|
||||
|
||||
// Now after all actuals have been deserialized, retarget delegating symbols from expects to actuals.
|
||||
expectUniqIdToActualUniqId.forEach {
|
||||
val expectSymbol = expectSymbols[it.key]
|
||||
val actualSymbol = actualSymbols[it.value]
|
||||
if (expectSymbol != null && actualSymbol != null) {
|
||||
when (expectSymbol) {
|
||||
is IrDelegatingClassSymbolImpl ->
|
||||
expectSymbol.delegate = actualSymbol as IrClassSymbol
|
||||
is IrDelegatingEnumEntrySymbolImpl ->
|
||||
expectSymbol.delegate = actualSymbol as IrEnumEntrySymbol
|
||||
is IrDelegatingSimpleFunctionSymbolImpl ->
|
||||
expectSymbol.delegate = actualSymbol as IrSimpleFunctionSymbol
|
||||
is IrDelegatingConstructorSymbolImpl ->
|
||||
expectSymbol.delegate = actualSymbol as IrConstructorSymbol
|
||||
is IrDelegatingPropertySymbolImpl ->
|
||||
expectSymbol.delegate = actualSymbol as IrPropertySymbol
|
||||
else -> error("Unexpected expect symbol kind during actualization: $expectSymbol")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun deserializeIrModuleHeader(
|
||||
moduleDescriptor: ModuleDescriptor,
|
||||
deserializationStrategy: DeserializationStrategy = DeserializationStrategy.ONLY_REFERENCED
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.serialization
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.ir.isExpect
|
||||
import org.jetbrains.kotlin.backend.common.ir.isProperExpect
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
@@ -296,7 +298,10 @@ abstract class KotlinManglerImpl : KotlinMangler {
|
||||
is IrTypeParameter -> this.symbolName
|
||||
is IrTypeAlias -> this.symbolName
|
||||
else -> error("Unexpected exported declaration: $this")
|
||||
}
|
||||
} + expectPart
|
||||
|
||||
// TODO: need to figure out the proper OptionalExpectation behavior
|
||||
private val IrDeclaration.expectPart get() = if (this.isProperExpect) "#expect" else ""
|
||||
|
||||
private val IrDeclarationParent.fqNameUnique: FqName
|
||||
get() = when (this) {
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.serialization
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.ir.isExpect
|
||||
import org.jetbrains.kotlin.backend.common.ir.isProperExpect
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.DescriptorReference as ProtoDescriptorReference
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
@@ -20,7 +22,8 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.classId
|
||||
open class DescriptorReferenceSerializer(
|
||||
val declarationTable: DeclarationTable,
|
||||
val serializeString: (String) -> Int,
|
||||
val serializeFqName: (FqName) -> List<Int>
|
||||
val serializeFqName: (FqName) -> List<Int>,
|
||||
val skipExpects: Boolean
|
||||
) {
|
||||
|
||||
private fun isEnumSpecialMember(descriptor: DeclarationDescriptor): Boolean {
|
||||
@@ -122,8 +125,8 @@ open class DescriptorReferenceSerializer(
|
||||
DescriptorReferenceFlags.IS_DEFAULT_CONSTRUCTOR.encode(isDefaultConstructor) or
|
||||
DescriptorReferenceFlags.IS_ENUM_ENTRY.encode(isEnumEntry) or
|
||||
DescriptorReferenceFlags.IS_ENUM_SPECIAL.encode(isEnumSpecial) or
|
||||
DescriptorReferenceFlags.IS_TYPE_PARAMETER.encode(isTypeParameter)
|
||||
|
||||
DescriptorReferenceFlags.IS_TYPE_PARAMETER.encode(isTypeParameter) or
|
||||
DescriptorReferenceFlags.IS_EXPECT.encode(!skipExpects && declaration.isProperExpect)
|
||||
proto.flags = flags
|
||||
|
||||
if (uniqId != null) proto.uniqIdIndex = uniqId.index
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
package org.jetbrains.kotlin.ir.backend.js.lower.serialization.metadata
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.serialization.DescriptorTable
|
||||
import org.jetbrains.kotlin.backend.common.serialization.isExpectMember
|
||||
import org.jetbrains.kotlin.backend.common.serialization.isSerializableExpectClass
|
||||
import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataSerializer
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
@@ -26,8 +24,10 @@ import org.jetbrains.kotlin.serialization.DescriptorSerializer
|
||||
class KlibMetadataIncrementalSerializer(
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
metadataVersion: BinaryVersion,
|
||||
descriptorTable: DescriptorTable
|
||||
) : KlibMetadataSerializer(languageVersionSettings, metadataVersion, descriptorTable) {
|
||||
moduleDescriptor: ModuleDescriptor,
|
||||
descriptorTable: DescriptorTable,
|
||||
skipExpects: Boolean
|
||||
) : KlibMetadataSerializer(languageVersionSettings, metadataVersion, moduleDescriptor, descriptorTable, skipExpects) {
|
||||
|
||||
fun serializePackageFragment(
|
||||
module: ModuleDescriptor,
|
||||
@@ -41,13 +41,11 @@ class KlibMetadataIncrementalSerializer(
|
||||
|
||||
val classifierDescriptors = allDescriptors
|
||||
.filterIsInstance<ClassifierDescriptor>()
|
||||
.filter { !it.isExpectMember || it.isSerializableExpectClass }
|
||||
.sortedBy { it.fqNameSafe.asString() }
|
||||
|
||||
val topLevelDescriptors = DescriptorSerializer.sort(
|
||||
allDescriptors
|
||||
.filterIsInstance<CallableDescriptor>()
|
||||
.filter { !it.isExpectMember }
|
||||
)
|
||||
|
||||
// TODO: For now, in the incremental serializer, we assume
|
||||
|
||||
@@ -19,8 +19,10 @@ import org.jetbrains.kotlin.serialization.DescriptorSerializer
|
||||
class KlibMetadataMonolithicSerializer(
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
metadataVersion: BinaryVersion,
|
||||
descriptorTable: DescriptorTable
|
||||
) : KlibMetadataSerializer(languageVersionSettings, metadataVersion, descriptorTable) {
|
||||
moduleDescriptor: ModuleDescriptor,
|
||||
descriptorTable: DescriptorTable,
|
||||
skipExpects: Boolean
|
||||
) : KlibMetadataSerializer(languageVersionSettings, metadataVersion, moduleDescriptor, descriptorTable, skipExpects) {
|
||||
|
||||
private fun serializePackageFragment(fqName: FqName, module: ModuleDescriptor): List<ProtoBuf.PackageFragment> {
|
||||
|
||||
@@ -33,13 +35,13 @@ class KlibMetadataMonolithicSerializer(
|
||||
val classifierDescriptors = DescriptorSerializer.sort(
|
||||
fragments.flatMap {
|
||||
it.getMemberScope().getDescriptorsFiltered(DescriptorKindFilter.CLASSIFIERS)
|
||||
}.filter { !it.isExpectMember || it.isSerializableExpectClass }
|
||||
}
|
||||
)
|
||||
|
||||
val topLevelDescriptors = DescriptorSerializer.sort(
|
||||
fragments.flatMap { fragment ->
|
||||
fragment.getMemberScope().getDescriptorsFiltered(DescriptorKindFilter.CALLABLES)
|
||||
}.filter { !it.isExpectMember }
|
||||
}
|
||||
)
|
||||
|
||||
return serializeDescriptors(fqName, classifierDescriptors, topLevelDescriptors)
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
package org.jetbrains.kotlin.backend.common.serialization.metadata
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.serialization.DescriptorTable
|
||||
import org.jetbrains.kotlin.backend.common.serialization.isExpectMember
|
||||
import org.jetbrains.kotlin.backend.common.serialization.isSerializableExpectClass
|
||||
import org.jetbrains.kotlin.backend.common.serialization.newDescriptorUniqId
|
||||
import org.jetbrains.kotlin.config.AnalysisFlags
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
@@ -14,7 +16,10 @@ import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.serialization.DescriptorSerializer
|
||||
import org.jetbrains.kotlin.serialization.StringTableImpl
|
||||
@@ -28,7 +33,9 @@ internal fun <T, R> Iterable<T>.maybeChunked(size: Int?, transform: (List<T>) ->
|
||||
abstract class KlibMetadataSerializer(
|
||||
val languageVersionSettings: LanguageVersionSettings,
|
||||
val metadataVersion: BinaryVersion,
|
||||
val descriptorTable: DescriptorTable
|
||||
val moduleDescriptor: ModuleDescriptor,
|
||||
val descriptorTable: DescriptorTable,
|
||||
val skipExpects: Boolean = false
|
||||
) {
|
||||
|
||||
lateinit var serializerContext: SerializerContext
|
||||
@@ -109,12 +116,30 @@ abstract class KlibMetadataSerializer(
|
||||
}
|
||||
}
|
||||
|
||||
protected fun serializeClasses(packageName: FqName,
|
||||
// TODO: we filter out expects with present actuals.
|
||||
// This is done because deserialized member scope doesn't give us actuals
|
||||
// when it has a choice
|
||||
private fun List<DeclarationDescriptor>.filterOutExpectsWithActuals(): List<DeclarationDescriptor> {
|
||||
val actualClassIds = this.filter{ !it.isExpectMember }.map { ClassId.topLevel(it.fqNameSafe) }
|
||||
return this.filterNot {
|
||||
// TODO: this only filters classes for now.
|
||||
// Need to do the same for functions etc
|
||||
(it is ClassDescriptor) && it.isExpect() && ClassId.topLevel(it.fqNameSafe) in actualClassIds
|
||||
}
|
||||
}
|
||||
|
||||
protected fun List<DeclarationDescriptor>.filterOutExpects(): List<DeclarationDescriptor> =
|
||||
if (skipExpects)
|
||||
this.filterNot { it.isExpectMember && !it.isSerializableExpectClass }
|
||||
else
|
||||
this.filterOutExpectsWithActuals()
|
||||
|
||||
private fun serializeClasses(packageName: FqName,
|
||||
//builder: ProtoBuf.PackageFragment.Builder,
|
||||
descriptors: Collection<DeclarationDescriptor>): List<Pair<ProtoBuf.Class, Int>> {
|
||||
|
||||
return descriptors.filterIsInstance<ClassDescriptor>().flatMap {
|
||||
serializeClass(packageName, /*builder, */it)
|
||||
serializeClass(packageName, it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +156,9 @@ abstract class KlibMetadataSerializer(
|
||||
topLevelDescriptors: List<DeclarationDescriptor>
|
||||
): List<ProtoBuf.PackageFragment> {
|
||||
|
||||
val classifierDescriptors = classifierDescriptors.filterOutExpects()
|
||||
val topLevelDescriptors = topLevelDescriptors.filterOutExpects()
|
||||
|
||||
if (TOP_LEVEL_CLASS_DECLARATION_COUNT_PER_FILE == null &&
|
||||
TOP_LEVEL_DECLARATION_COUNT_PER_FILE == null) {
|
||||
|
||||
|
||||
@@ -0,0 +1,428 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: compiler/ir/serialization.common/src/KotlinIr.proto
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.serialization.proto;
|
||||
|
||||
/**
|
||||
* Protobuf type {@code org.jetbrains.kotlin.backend.common.serialization.proto.Actual}
|
||||
*/
|
||||
public final class Actual extends
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessageLite implements
|
||||
// @@protoc_insertion_point(message_implements:org.jetbrains.kotlin.backend.common.serialization.proto.Actual)
|
||||
ActualOrBuilder {
|
||||
// Use Actual.newBuilder() to construct.
|
||||
private Actual(org.jetbrains.kotlin.protobuf.GeneratedMessageLite.Builder builder) {
|
||||
super(builder);
|
||||
this.unknownFields = builder.getUnknownFields();
|
||||
}
|
||||
private Actual(boolean noInit) { this.unknownFields = org.jetbrains.kotlin.protobuf.ByteString.EMPTY;}
|
||||
|
||||
private static final Actual defaultInstance;
|
||||
public static Actual getDefaultInstance() {
|
||||
return defaultInstance;
|
||||
}
|
||||
|
||||
public Actual getDefaultInstanceForType() {
|
||||
return defaultInstance;
|
||||
}
|
||||
|
||||
private final org.jetbrains.kotlin.protobuf.ByteString unknownFields;
|
||||
private Actual(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
initFields();
|
||||
int mutable_bitField0_ = 0;
|
||||
org.jetbrains.kotlin.protobuf.ByteString.Output unknownFieldsOutput =
|
||||
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
|
||||
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
|
||||
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
|
||||
unknownFieldsOutput, 1);
|
||||
try {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
done = true;
|
||||
break;
|
||||
default: {
|
||||
if (!parseUnknownField(input, unknownFieldsCodedOutput,
|
||||
extensionRegistry, tag)) {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
bitField0_ |= 0x00000001;
|
||||
actualSymbol_ = input.readInt32();
|
||||
break;
|
||||
}
|
||||
case 16: {
|
||||
bitField0_ |= 0x00000002;
|
||||
expectSymbol_ = input.readInt32();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(this);
|
||||
} catch (java.io.IOException e) {
|
||||
throw new org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException(
|
||||
e.getMessage()).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
try {
|
||||
unknownFieldsCodedOutput.flush();
|
||||
} catch (java.io.IOException e) {
|
||||
// Should not happen
|
||||
} finally {
|
||||
unknownFields = unknownFieldsOutput.toByteString();
|
||||
}
|
||||
makeExtensionsImmutable();
|
||||
}
|
||||
}
|
||||
public static org.jetbrains.kotlin.protobuf.Parser<Actual> PARSER =
|
||||
new org.jetbrains.kotlin.protobuf.AbstractParser<Actual>() {
|
||||
public Actual parsePartialFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return new Actual(input, extensionRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
@java.lang.Override
|
||||
public org.jetbrains.kotlin.protobuf.Parser<Actual> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
private int bitField0_;
|
||||
public static final int ACTUAL_SYMBOL_FIELD_NUMBER = 1;
|
||||
private int actualSymbol_;
|
||||
/**
|
||||
* <code>required int32 actual_symbol = 1;</code>
|
||||
*/
|
||||
public boolean hasActualSymbol() {
|
||||
return ((bitField0_ & 0x00000001) == 0x00000001);
|
||||
}
|
||||
/**
|
||||
* <code>required int32 actual_symbol = 1;</code>
|
||||
*/
|
||||
public int getActualSymbol() {
|
||||
return actualSymbol_;
|
||||
}
|
||||
|
||||
public static final int EXPECT_SYMBOL_FIELD_NUMBER = 2;
|
||||
private int expectSymbol_;
|
||||
/**
|
||||
* <code>required int32 expect_symbol = 2;</code>
|
||||
*/
|
||||
public boolean hasExpectSymbol() {
|
||||
return ((bitField0_ & 0x00000002) == 0x00000002);
|
||||
}
|
||||
/**
|
||||
* <code>required int32 expect_symbol = 2;</code>
|
||||
*/
|
||||
public int getExpectSymbol() {
|
||||
return expectSymbol_;
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
actualSymbol_ = 0;
|
||||
expectSymbol_ = 0;
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
if (!hasActualSymbol()) {
|
||||
memoizedIsInitialized = 0;
|
||||
return false;
|
||||
}
|
||||
if (!hasExpectSymbol()) {
|
||||
memoizedIsInitialized = 0;
|
||||
return false;
|
||||
}
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void writeTo(org.jetbrains.kotlin.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
getSerializedSize();
|
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
output.writeInt32(1, actualSymbol_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
output.writeInt32(2, expectSymbol_);
|
||||
}
|
||||
output.writeRawBytes(unknownFields);
|
||||
}
|
||||
|
||||
private int memoizedSerializedSize = -1;
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSerializedSize;
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeInt32Size(1, actualSymbol_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeInt32Size(2, expectSymbol_);
|
||||
}
|
||||
size += unknownFields.size();
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
@java.lang.Override
|
||||
protected java.lang.Object writeReplace()
|
||||
throws java.io.ObjectStreamException {
|
||||
return super.writeReplace();
|
||||
}
|
||||
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.Actual parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.ByteString data)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.Actual parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.ByteString data,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.Actual parseFrom(byte[] data)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.Actual parseFrom(
|
||||
byte[] data,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.Actual parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.Actual parseFrom(
|
||||
java.io.InputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.Actual parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseDelimitedFrom(input);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.Actual parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseDelimitedFrom(input, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.Actual parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.Actual parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input, extensionRegistry);
|
||||
}
|
||||
|
||||
public static Builder newBuilder() { return Builder.create(); }
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder(org.jetbrains.kotlin.backend.common.serialization.proto.Actual prototype) {
|
||||
return newBuilder().mergeFrom(prototype);
|
||||
}
|
||||
public Builder toBuilder() { return newBuilder(this); }
|
||||
|
||||
/**
|
||||
* Protobuf type {@code org.jetbrains.kotlin.backend.common.serialization.proto.Actual}
|
||||
*/
|
||||
public static final class Builder extends
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessageLite.Builder<
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.Actual, Builder>
|
||||
implements
|
||||
// @@protoc_insertion_point(builder_implements:org.jetbrains.kotlin.backend.common.serialization.proto.Actual)
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.ActualOrBuilder {
|
||||
// Construct using org.jetbrains.kotlin.backend.common.serialization.proto.Actual.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
|
||||
private void maybeForceBuilderInitialization() {
|
||||
}
|
||||
private static Builder create() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
actualSymbol_ = 0;
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
expectSymbol_ = 0;
|
||||
bitField0_ = (bitField0_ & ~0x00000002);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder clone() {
|
||||
return create().mergeFrom(buildPartial());
|
||||
}
|
||||
|
||||
public org.jetbrains.kotlin.backend.common.serialization.proto.Actual getDefaultInstanceForType() {
|
||||
return org.jetbrains.kotlin.backend.common.serialization.proto.Actual.getDefaultInstance();
|
||||
}
|
||||
|
||||
public org.jetbrains.kotlin.backend.common.serialization.proto.Actual build() {
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.Actual result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public org.jetbrains.kotlin.backend.common.serialization.proto.Actual buildPartial() {
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.Actual result = new org.jetbrains.kotlin.backend.common.serialization.proto.Actual(this);
|
||||
int from_bitField0_ = bitField0_;
|
||||
int to_bitField0_ = 0;
|
||||
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
to_bitField0_ |= 0x00000001;
|
||||
}
|
||||
result.actualSymbol_ = actualSymbol_;
|
||||
if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
to_bitField0_ |= 0x00000002;
|
||||
}
|
||||
result.expectSymbol_ = expectSymbol_;
|
||||
result.bitField0_ = to_bitField0_;
|
||||
return result;
|
||||
}
|
||||
|
||||
public Builder mergeFrom(org.jetbrains.kotlin.backend.common.serialization.proto.Actual other) {
|
||||
if (other == org.jetbrains.kotlin.backend.common.serialization.proto.Actual.getDefaultInstance()) return this;
|
||||
if (other.hasActualSymbol()) {
|
||||
setActualSymbol(other.getActualSymbol());
|
||||
}
|
||||
if (other.hasExpectSymbol()) {
|
||||
setExpectSymbol(other.getExpectSymbol());
|
||||
}
|
||||
setUnknownFields(
|
||||
getUnknownFields().concat(other.unknownFields));
|
||||
return this;
|
||||
}
|
||||
|
||||
public final boolean isInitialized() {
|
||||
if (!hasActualSymbol()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!hasExpectSymbol()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Builder mergeFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.Actual parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage = (org.jetbrains.kotlin.backend.common.serialization.proto.Actual) e.getUnfinishedMessage();
|
||||
throw e;
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
mergeFrom(parsedMessage);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
private int bitField0_;
|
||||
|
||||
private int actualSymbol_ ;
|
||||
/**
|
||||
* <code>required int32 actual_symbol = 1;</code>
|
||||
*/
|
||||
public boolean hasActualSymbol() {
|
||||
return ((bitField0_ & 0x00000001) == 0x00000001);
|
||||
}
|
||||
/**
|
||||
* <code>required int32 actual_symbol = 1;</code>
|
||||
*/
|
||||
public int getActualSymbol() {
|
||||
return actualSymbol_;
|
||||
}
|
||||
/**
|
||||
* <code>required int32 actual_symbol = 1;</code>
|
||||
*/
|
||||
public Builder setActualSymbol(int value) {
|
||||
bitField0_ |= 0x00000001;
|
||||
actualSymbol_ = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>required int32 actual_symbol = 1;</code>
|
||||
*/
|
||||
public Builder clearActualSymbol() {
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
actualSymbol_ = 0;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private int expectSymbol_ ;
|
||||
/**
|
||||
* <code>required int32 expect_symbol = 2;</code>
|
||||
*/
|
||||
public boolean hasExpectSymbol() {
|
||||
return ((bitField0_ & 0x00000002) == 0x00000002);
|
||||
}
|
||||
/**
|
||||
* <code>required int32 expect_symbol = 2;</code>
|
||||
*/
|
||||
public int getExpectSymbol() {
|
||||
return expectSymbol_;
|
||||
}
|
||||
/**
|
||||
* <code>required int32 expect_symbol = 2;</code>
|
||||
*/
|
||||
public Builder setExpectSymbol(int value) {
|
||||
bitField0_ |= 0x00000002;
|
||||
expectSymbol_ = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>required int32 expect_symbol = 2;</code>
|
||||
*/
|
||||
public Builder clearExpectSymbol() {
|
||||
bitField0_ = (bitField0_ & ~0x00000002);
|
||||
expectSymbol_ = 0;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.backend.common.serialization.proto.Actual)
|
||||
}
|
||||
|
||||
static {
|
||||
defaultInstance = new Actual(true);
|
||||
defaultInstance.initFields();
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:org.jetbrains.kotlin.backend.common.serialization.proto.Actual)
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: compiler/ir/serialization.common/src/KotlinIr.proto
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.serialization.proto;
|
||||
|
||||
public interface ActualOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:org.jetbrains.kotlin.backend.common.serialization.proto.Actual)
|
||||
org.jetbrains.kotlin.protobuf.MessageLiteOrBuilder {
|
||||
|
||||
/**
|
||||
* <code>required int32 actual_symbol = 1;</code>
|
||||
*/
|
||||
boolean hasActualSymbol();
|
||||
/**
|
||||
* <code>required int32 actual_symbol = 1;</code>
|
||||
*/
|
||||
int getActualSymbol();
|
||||
|
||||
/**
|
||||
* <code>required int32 expect_symbol = 2;</code>
|
||||
*/
|
||||
boolean hasExpectSymbol();
|
||||
/**
|
||||
* <code>required int32 expect_symbol = 2;</code>
|
||||
*/
|
||||
int getExpectSymbol();
|
||||
}
|
||||
@@ -0,0 +1,479 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: compiler/ir/serialization.common/src/KotlinIr.proto
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.serialization.proto;
|
||||
|
||||
/**
|
||||
* Protobuf type {@code org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable}
|
||||
*/
|
||||
public final class ExpectActualTable extends
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessageLite implements
|
||||
// @@protoc_insertion_point(message_implements:org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable)
|
||||
ExpectActualTableOrBuilder {
|
||||
// Use ExpectActualTable.newBuilder() to construct.
|
||||
private ExpectActualTable(org.jetbrains.kotlin.protobuf.GeneratedMessageLite.Builder builder) {
|
||||
super(builder);
|
||||
this.unknownFields = builder.getUnknownFields();
|
||||
}
|
||||
private ExpectActualTable(boolean noInit) { this.unknownFields = org.jetbrains.kotlin.protobuf.ByteString.EMPTY;}
|
||||
|
||||
private static final ExpectActualTable defaultInstance;
|
||||
public static ExpectActualTable getDefaultInstance() {
|
||||
return defaultInstance;
|
||||
}
|
||||
|
||||
public ExpectActualTable getDefaultInstanceForType() {
|
||||
return defaultInstance;
|
||||
}
|
||||
|
||||
private final org.jetbrains.kotlin.protobuf.ByteString unknownFields;
|
||||
private ExpectActualTable(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
initFields();
|
||||
int mutable_bitField0_ = 0;
|
||||
org.jetbrains.kotlin.protobuf.ByteString.Output unknownFieldsOutput =
|
||||
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
|
||||
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
|
||||
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
|
||||
unknownFieldsOutput, 1);
|
||||
try {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
done = true;
|
||||
break;
|
||||
default: {
|
||||
if (!parseUnknownField(input, unknownFieldsCodedOutput,
|
||||
extensionRegistry, tag)) {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 10: {
|
||||
if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
expectToActuals_ = new java.util.ArrayList<org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual>();
|
||||
mutable_bitField0_ |= 0x00000001;
|
||||
}
|
||||
expectToActuals_.add(input.readMessage(org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual.PARSER, extensionRegistry));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(this);
|
||||
} catch (java.io.IOException e) {
|
||||
throw new org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException(
|
||||
e.getMessage()).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
expectToActuals_ = java.util.Collections.unmodifiableList(expectToActuals_);
|
||||
}
|
||||
try {
|
||||
unknownFieldsCodedOutput.flush();
|
||||
} catch (java.io.IOException e) {
|
||||
// Should not happen
|
||||
} finally {
|
||||
unknownFields = unknownFieldsOutput.toByteString();
|
||||
}
|
||||
makeExtensionsImmutable();
|
||||
}
|
||||
}
|
||||
public static org.jetbrains.kotlin.protobuf.Parser<ExpectActualTable> PARSER =
|
||||
new org.jetbrains.kotlin.protobuf.AbstractParser<ExpectActualTable>() {
|
||||
public ExpectActualTable parsePartialFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return new ExpectActualTable(input, extensionRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
@java.lang.Override
|
||||
public org.jetbrains.kotlin.protobuf.Parser<ExpectActualTable> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
public static final int EXPECTTOACTUALS_FIELD_NUMBER = 1;
|
||||
private java.util.List<org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual> expectToActuals_;
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public java.util.List<org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual> getExpectToActualsList() {
|
||||
return expectToActuals_;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public java.util.List<? extends org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActualOrBuilder>
|
||||
getExpectToActualsOrBuilderList() {
|
||||
return expectToActuals_;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public int getExpectToActualsCount() {
|
||||
return expectToActuals_.size();
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual getExpectToActuals(int index) {
|
||||
return expectToActuals_.get(index);
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActualOrBuilder getExpectToActualsOrBuilder(
|
||||
int index) {
|
||||
return expectToActuals_.get(index);
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
expectToActuals_ = java.util.Collections.emptyList();
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
for (int i = 0; i < getExpectToActualsCount(); i++) {
|
||||
if (!getExpectToActuals(i).isInitialized()) {
|
||||
memoizedIsInitialized = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void writeTo(org.jetbrains.kotlin.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
getSerializedSize();
|
||||
for (int i = 0; i < expectToActuals_.size(); i++) {
|
||||
output.writeMessage(1, expectToActuals_.get(i));
|
||||
}
|
||||
output.writeRawBytes(unknownFields);
|
||||
}
|
||||
|
||||
private int memoizedSerializedSize = -1;
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSerializedSize;
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
for (int i = 0; i < expectToActuals_.size(); i++) {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeMessageSize(1, expectToActuals_.get(i));
|
||||
}
|
||||
size += unknownFields.size();
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
@java.lang.Override
|
||||
protected java.lang.Object writeReplace()
|
||||
throws java.io.ObjectStreamException {
|
||||
return super.writeReplace();
|
||||
}
|
||||
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.ByteString data)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.ByteString data,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable parseFrom(byte[] data)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable parseFrom(
|
||||
byte[] data,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable parseFrom(
|
||||
java.io.InputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseDelimitedFrom(input);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseDelimitedFrom(input, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input, extensionRegistry);
|
||||
}
|
||||
|
||||
public static Builder newBuilder() { return Builder.create(); }
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder(org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable prototype) {
|
||||
return newBuilder().mergeFrom(prototype);
|
||||
}
|
||||
public Builder toBuilder() { return newBuilder(this); }
|
||||
|
||||
/**
|
||||
* Protobuf type {@code org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable}
|
||||
*/
|
||||
public static final class Builder extends
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessageLite.Builder<
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable, Builder>
|
||||
implements
|
||||
// @@protoc_insertion_point(builder_implements:org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable)
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTableOrBuilder {
|
||||
// Construct using org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
|
||||
private void maybeForceBuilderInitialization() {
|
||||
}
|
||||
private static Builder create() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
expectToActuals_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder clone() {
|
||||
return create().mergeFrom(buildPartial());
|
||||
}
|
||||
|
||||
public org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable getDefaultInstanceForType() {
|
||||
return org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable.getDefaultInstance();
|
||||
}
|
||||
|
||||
public org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable build() {
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable buildPartial() {
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable result = new org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable(this);
|
||||
int from_bitField0_ = bitField0_;
|
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
expectToActuals_ = java.util.Collections.unmodifiableList(expectToActuals_);
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
}
|
||||
result.expectToActuals_ = expectToActuals_;
|
||||
return result;
|
||||
}
|
||||
|
||||
public Builder mergeFrom(org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable other) {
|
||||
if (other == org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable.getDefaultInstance()) return this;
|
||||
if (!other.expectToActuals_.isEmpty()) {
|
||||
if (expectToActuals_.isEmpty()) {
|
||||
expectToActuals_ = other.expectToActuals_;
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
} else {
|
||||
ensureExpectToActualsIsMutable();
|
||||
expectToActuals_.addAll(other.expectToActuals_);
|
||||
}
|
||||
|
||||
}
|
||||
setUnknownFields(
|
||||
getUnknownFields().concat(other.unknownFields));
|
||||
return this;
|
||||
}
|
||||
|
||||
public final boolean isInitialized() {
|
||||
for (int i = 0; i < getExpectToActualsCount(); i++) {
|
||||
if (!getExpectToActuals(i).isInitialized()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Builder mergeFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage = (org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable) e.getUnfinishedMessage();
|
||||
throw e;
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
mergeFrom(parsedMessage);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
private int bitField0_;
|
||||
|
||||
private java.util.List<org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual> expectToActuals_ =
|
||||
java.util.Collections.emptyList();
|
||||
private void ensureExpectToActualsIsMutable() {
|
||||
if (!((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
expectToActuals_ = new java.util.ArrayList<org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual>(expectToActuals_);
|
||||
bitField0_ |= 0x00000001;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public java.util.List<org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual> getExpectToActualsList() {
|
||||
return java.util.Collections.unmodifiableList(expectToActuals_);
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public int getExpectToActualsCount() {
|
||||
return expectToActuals_.size();
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual getExpectToActuals(int index) {
|
||||
return expectToActuals_.get(index);
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public Builder setExpectToActuals(
|
||||
int index, org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
ensureExpectToActualsIsMutable();
|
||||
expectToActuals_.set(index, value);
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public Builder setExpectToActuals(
|
||||
int index, org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual.Builder builderForValue) {
|
||||
ensureExpectToActualsIsMutable();
|
||||
expectToActuals_.set(index, builderForValue.build());
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public Builder addExpectToActuals(org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
ensureExpectToActualsIsMutable();
|
||||
expectToActuals_.add(value);
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public Builder addExpectToActuals(
|
||||
int index, org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
ensureExpectToActualsIsMutable();
|
||||
expectToActuals_.add(index, value);
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public Builder addExpectToActuals(
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual.Builder builderForValue) {
|
||||
ensureExpectToActualsIsMutable();
|
||||
expectToActuals_.add(builderForValue.build());
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public Builder addExpectToActuals(
|
||||
int index, org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual.Builder builderForValue) {
|
||||
ensureExpectToActualsIsMutable();
|
||||
expectToActuals_.add(index, builderForValue.build());
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public Builder addAllExpectToActuals(
|
||||
java.lang.Iterable<? extends org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual> values) {
|
||||
ensureExpectToActualsIsMutable();
|
||||
org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
|
||||
values, expectToActuals_);
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public Builder clearExpectToActuals() {
|
||||
expectToActuals_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
public Builder removeExpectToActuals(int index) {
|
||||
ensureExpectToActualsIsMutable();
|
||||
expectToActuals_.remove(index);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable)
|
||||
}
|
||||
|
||||
static {
|
||||
defaultInstance = new ExpectActualTable(true);
|
||||
defaultInstance.initFields();
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable)
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: compiler/ir/serialization.common/src/KotlinIr.proto
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.serialization.proto;
|
||||
|
||||
public interface ExpectActualTableOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:org.jetbrains.kotlin.backend.common.serialization.proto.ExpectActualTable)
|
||||
org.jetbrains.kotlin.protobuf.MessageLiteOrBuilder {
|
||||
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
java.util.List<org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual>
|
||||
getExpectToActualsList();
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual getExpectToActuals(int index);
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual expectToActuals = 1;</code>
|
||||
*/
|
||||
int getExpectToActualsCount();
|
||||
}
|
||||
@@ -0,0 +1,420 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: compiler/ir/serialization.common/src/KotlinIr.proto
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.serialization.proto;
|
||||
|
||||
/**
|
||||
* Protobuf type {@code org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual}
|
||||
*/
|
||||
public final class ExpectToActual extends
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessageLite implements
|
||||
// @@protoc_insertion_point(message_implements:org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual)
|
||||
ExpectToActualOrBuilder {
|
||||
// Use ExpectToActual.newBuilder() to construct.
|
||||
private ExpectToActual(org.jetbrains.kotlin.protobuf.GeneratedMessageLite.Builder builder) {
|
||||
super(builder);
|
||||
this.unknownFields = builder.getUnknownFields();
|
||||
}
|
||||
private ExpectToActual(boolean noInit) { this.unknownFields = org.jetbrains.kotlin.protobuf.ByteString.EMPTY;}
|
||||
|
||||
private static final ExpectToActual defaultInstance;
|
||||
public static ExpectToActual getDefaultInstance() {
|
||||
return defaultInstance;
|
||||
}
|
||||
|
||||
public ExpectToActual getDefaultInstanceForType() {
|
||||
return defaultInstance;
|
||||
}
|
||||
|
||||
private final org.jetbrains.kotlin.protobuf.ByteString unknownFields;
|
||||
private ExpectToActual(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
initFields();
|
||||
int mutable_bitField0_ = 0;
|
||||
org.jetbrains.kotlin.protobuf.ByteString.Output unknownFieldsOutput =
|
||||
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
|
||||
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
|
||||
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
|
||||
unknownFieldsOutput, 1);
|
||||
try {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
done = true;
|
||||
break;
|
||||
default: {
|
||||
if (!parseUnknownField(input, unknownFieldsCodedOutput,
|
||||
extensionRegistry, tag)) {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
bitField0_ |= 0x00000001;
|
||||
expect_ = input.readInt64();
|
||||
break;
|
||||
}
|
||||
case 16: {
|
||||
bitField0_ |= 0x00000002;
|
||||
actual_ = input.readInt64();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(this);
|
||||
} catch (java.io.IOException e) {
|
||||
throw new org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException(
|
||||
e.getMessage()).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
try {
|
||||
unknownFieldsCodedOutput.flush();
|
||||
} catch (java.io.IOException e) {
|
||||
// Should not happen
|
||||
} finally {
|
||||
unknownFields = unknownFieldsOutput.toByteString();
|
||||
}
|
||||
makeExtensionsImmutable();
|
||||
}
|
||||
}
|
||||
public static org.jetbrains.kotlin.protobuf.Parser<ExpectToActual> PARSER =
|
||||
new org.jetbrains.kotlin.protobuf.AbstractParser<ExpectToActual>() {
|
||||
public ExpectToActual parsePartialFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return new ExpectToActual(input, extensionRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
@java.lang.Override
|
||||
public org.jetbrains.kotlin.protobuf.Parser<ExpectToActual> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
private int bitField0_;
|
||||
public static final int EXPECT_FIELD_NUMBER = 1;
|
||||
private long expect_;
|
||||
/**
|
||||
* <code>required int64 expect = 1;</code>
|
||||
*/
|
||||
public boolean hasExpect() {
|
||||
return ((bitField0_ & 0x00000001) == 0x00000001);
|
||||
}
|
||||
/**
|
||||
* <code>required int64 expect = 1;</code>
|
||||
*/
|
||||
public long getExpect() {
|
||||
return expect_;
|
||||
}
|
||||
|
||||
public static final int ACTUAL_FIELD_NUMBER = 2;
|
||||
private long actual_;
|
||||
/**
|
||||
* <code>optional int64 actual = 2;</code>
|
||||
*/
|
||||
public boolean hasActual() {
|
||||
return ((bitField0_ & 0x00000002) == 0x00000002);
|
||||
}
|
||||
/**
|
||||
* <code>optional int64 actual = 2;</code>
|
||||
*/
|
||||
public long getActual() {
|
||||
return actual_;
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
expect_ = 0L;
|
||||
actual_ = 0L;
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
if (!hasExpect()) {
|
||||
memoizedIsInitialized = 0;
|
||||
return false;
|
||||
}
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void writeTo(org.jetbrains.kotlin.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
getSerializedSize();
|
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
output.writeInt64(1, expect_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
output.writeInt64(2, actual_);
|
||||
}
|
||||
output.writeRawBytes(unknownFields);
|
||||
}
|
||||
|
||||
private int memoizedSerializedSize = -1;
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSerializedSize;
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeInt64Size(1, expect_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeInt64Size(2, actual_);
|
||||
}
|
||||
size += unknownFields.size();
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
@java.lang.Override
|
||||
protected java.lang.Object writeReplace()
|
||||
throws java.io.ObjectStreamException {
|
||||
return super.writeReplace();
|
||||
}
|
||||
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.ByteString data)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.ByteString data,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual parseFrom(byte[] data)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual parseFrom(
|
||||
byte[] data,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual parseFrom(
|
||||
java.io.InputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseDelimitedFrom(input);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseDelimitedFrom(input, extensionRegistry);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input);
|
||||
}
|
||||
public static org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual parseFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return PARSER.parseFrom(input, extensionRegistry);
|
||||
}
|
||||
|
||||
public static Builder newBuilder() { return Builder.create(); }
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder(org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual prototype) {
|
||||
return newBuilder().mergeFrom(prototype);
|
||||
}
|
||||
public Builder toBuilder() { return newBuilder(this); }
|
||||
|
||||
/**
|
||||
* Protobuf type {@code org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual}
|
||||
*/
|
||||
public static final class Builder extends
|
||||
org.jetbrains.kotlin.protobuf.GeneratedMessageLite.Builder<
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual, Builder>
|
||||
implements
|
||||
// @@protoc_insertion_point(builder_implements:org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual)
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActualOrBuilder {
|
||||
// Construct using org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
|
||||
private void maybeForceBuilderInitialization() {
|
||||
}
|
||||
private static Builder create() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
expect_ = 0L;
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
actual_ = 0L;
|
||||
bitField0_ = (bitField0_ & ~0x00000002);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder clone() {
|
||||
return create().mergeFrom(buildPartial());
|
||||
}
|
||||
|
||||
public org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual getDefaultInstanceForType() {
|
||||
return org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual.getDefaultInstance();
|
||||
}
|
||||
|
||||
public org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual build() {
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual buildPartial() {
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual result = new org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual(this);
|
||||
int from_bitField0_ = bitField0_;
|
||||
int to_bitField0_ = 0;
|
||||
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
to_bitField0_ |= 0x00000001;
|
||||
}
|
||||
result.expect_ = expect_;
|
||||
if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
to_bitField0_ |= 0x00000002;
|
||||
}
|
||||
result.actual_ = actual_;
|
||||
result.bitField0_ = to_bitField0_;
|
||||
return result;
|
||||
}
|
||||
|
||||
public Builder mergeFrom(org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual other) {
|
||||
if (other == org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual.getDefaultInstance()) return this;
|
||||
if (other.hasExpect()) {
|
||||
setExpect(other.getExpect());
|
||||
}
|
||||
if (other.hasActual()) {
|
||||
setActual(other.getActual());
|
||||
}
|
||||
setUnknownFields(
|
||||
getUnknownFields().concat(other.unknownFields));
|
||||
return this;
|
||||
}
|
||||
|
||||
public final boolean isInitialized() {
|
||||
if (!hasExpect()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Builder mergeFrom(
|
||||
org.jetbrains.kotlin.protobuf.CodedInputStream input,
|
||||
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage = (org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual) e.getUnfinishedMessage();
|
||||
throw e;
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
mergeFrom(parsedMessage);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
private int bitField0_;
|
||||
|
||||
private long expect_ ;
|
||||
/**
|
||||
* <code>required int64 expect = 1;</code>
|
||||
*/
|
||||
public boolean hasExpect() {
|
||||
return ((bitField0_ & 0x00000001) == 0x00000001);
|
||||
}
|
||||
/**
|
||||
* <code>required int64 expect = 1;</code>
|
||||
*/
|
||||
public long getExpect() {
|
||||
return expect_;
|
||||
}
|
||||
/**
|
||||
* <code>required int64 expect = 1;</code>
|
||||
*/
|
||||
public Builder setExpect(long value) {
|
||||
bitField0_ |= 0x00000001;
|
||||
expect_ = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>required int64 expect = 1;</code>
|
||||
*/
|
||||
public Builder clearExpect() {
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
expect_ = 0L;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private long actual_ ;
|
||||
/**
|
||||
* <code>optional int64 actual = 2;</code>
|
||||
*/
|
||||
public boolean hasActual() {
|
||||
return ((bitField0_ & 0x00000002) == 0x00000002);
|
||||
}
|
||||
/**
|
||||
* <code>optional int64 actual = 2;</code>
|
||||
*/
|
||||
public long getActual() {
|
||||
return actual_;
|
||||
}
|
||||
/**
|
||||
* <code>optional int64 actual = 2;</code>
|
||||
*/
|
||||
public Builder setActual(long value) {
|
||||
bitField0_ |= 0x00000002;
|
||||
actual_ = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional int64 actual = 2;</code>
|
||||
*/
|
||||
public Builder clearActual() {
|
||||
bitField0_ = (bitField0_ & ~0x00000002);
|
||||
actual_ = 0L;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual)
|
||||
}
|
||||
|
||||
static {
|
||||
defaultInstance = new ExpectToActual(true);
|
||||
defaultInstance.initFields();
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual)
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: compiler/ir/serialization.common/src/KotlinIr.proto
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.serialization.proto;
|
||||
|
||||
public interface ExpectToActualOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:org.jetbrains.kotlin.backend.common.serialization.proto.ExpectToActual)
|
||||
org.jetbrains.kotlin.protobuf.MessageLiteOrBuilder {
|
||||
|
||||
/**
|
||||
* <code>required int64 expect = 1;</code>
|
||||
*/
|
||||
boolean hasExpect();
|
||||
/**
|
||||
* <code>required int64 expect = 1;</code>
|
||||
*/
|
||||
long getExpect();
|
||||
|
||||
/**
|
||||
* <code>optional int64 actual = 2;</code>
|
||||
*/
|
||||
boolean hasActual();
|
||||
/**
|
||||
* <code>optional int64 actual = 2;</code>
|
||||
*/
|
||||
long getActual();
|
||||
}
|
||||
@@ -137,6 +137,14 @@ public final class IrFile extends
|
||||
input.popLimit(limit);
|
||||
break;
|
||||
}
|
||||
case 50: {
|
||||
if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) {
|
||||
actuals_ = new java.util.ArrayList<org.jetbrains.kotlin.backend.common.serialization.proto.Actual>();
|
||||
mutable_bitField0_ |= 0x00000020;
|
||||
}
|
||||
actuals_.add(input.readMessage(org.jetbrains.kotlin.backend.common.serialization.proto.Actual.PARSER, extensionRegistry));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
||||
@@ -157,6 +165,9 @@ public final class IrFile extends
|
||||
if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) {
|
||||
explicitlyExportedToCompiler_ = java.util.Collections.unmodifiableList(explicitlyExportedToCompiler_);
|
||||
}
|
||||
if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) {
|
||||
actuals_ = java.util.Collections.unmodifiableList(actuals_);
|
||||
}
|
||||
try {
|
||||
unknownFieldsCodedOutput.flush();
|
||||
} catch (java.io.IOException e) {
|
||||
@@ -299,12 +310,48 @@ public final class IrFile extends
|
||||
return explicitlyExportedToCompiler_.get(index);
|
||||
}
|
||||
|
||||
public static final int ACTUALS_FIELD_NUMBER = 6;
|
||||
private java.util.List<org.jetbrains.kotlin.backend.common.serialization.proto.Actual> actuals_;
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public java.util.List<org.jetbrains.kotlin.backend.common.serialization.proto.Actual> getActualsList() {
|
||||
return actuals_;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public java.util.List<? extends org.jetbrains.kotlin.backend.common.serialization.proto.ActualOrBuilder>
|
||||
getActualsOrBuilderList() {
|
||||
return actuals_;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public int getActualsCount() {
|
||||
return actuals_.size();
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public org.jetbrains.kotlin.backend.common.serialization.proto.Actual getActuals(int index) {
|
||||
return actuals_.get(index);
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public org.jetbrains.kotlin.backend.common.serialization.proto.ActualOrBuilder getActualsOrBuilder(
|
||||
int index) {
|
||||
return actuals_.get(index);
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
declarationId_ = java.util.Collections.emptyList();
|
||||
fileEntry_ = org.jetbrains.kotlin.backend.common.serialization.proto.FileEntry.getDefaultInstance();
|
||||
fqName_ = java.util.Collections.emptyList();
|
||||
annotation_ = java.util.Collections.emptyList();
|
||||
explicitlyExportedToCompiler_ = java.util.Collections.emptyList();
|
||||
actuals_ = java.util.Collections.emptyList();
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
@@ -326,6 +373,12 @@ public final class IrFile extends
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < getActualsCount(); i++) {
|
||||
if (!getActuals(i).isInitialized()) {
|
||||
memoizedIsInitialized = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
@@ -348,6 +401,9 @@ public final class IrFile extends
|
||||
for (int i = 0; i < explicitlyExportedToCompiler_.size(); i++) {
|
||||
output.writeInt32(5, explicitlyExportedToCompiler_.get(i));
|
||||
}
|
||||
for (int i = 0; i < actuals_.size(); i++) {
|
||||
output.writeMessage(6, actuals_.get(i));
|
||||
}
|
||||
output.writeRawBytes(unknownFields);
|
||||
}
|
||||
|
||||
@@ -392,6 +448,10 @@ public final class IrFile extends
|
||||
size += dataSize;
|
||||
size += 1 * getExplicitlyExportedToCompilerList().size();
|
||||
}
|
||||
for (int i = 0; i < actuals_.size(); i++) {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeMessageSize(6, actuals_.get(i));
|
||||
}
|
||||
size += unknownFields.size();
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
@@ -496,6 +556,8 @@ public final class IrFile extends
|
||||
bitField0_ = (bitField0_ & ~0x00000008);
|
||||
explicitlyExportedToCompiler_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000010);
|
||||
actuals_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000020);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -543,6 +605,11 @@ public final class IrFile extends
|
||||
bitField0_ = (bitField0_ & ~0x00000010);
|
||||
}
|
||||
result.explicitlyExportedToCompiler_ = explicitlyExportedToCompiler_;
|
||||
if (((bitField0_ & 0x00000020) == 0x00000020)) {
|
||||
actuals_ = java.util.Collections.unmodifiableList(actuals_);
|
||||
bitField0_ = (bitField0_ & ~0x00000020);
|
||||
}
|
||||
result.actuals_ = actuals_;
|
||||
result.bitField0_ = to_bitField0_;
|
||||
return result;
|
||||
}
|
||||
@@ -591,6 +658,16 @@ public final class IrFile extends
|
||||
explicitlyExportedToCompiler_.addAll(other.explicitlyExportedToCompiler_);
|
||||
}
|
||||
|
||||
}
|
||||
if (!other.actuals_.isEmpty()) {
|
||||
if (actuals_.isEmpty()) {
|
||||
actuals_ = other.actuals_;
|
||||
bitField0_ = (bitField0_ & ~0x00000020);
|
||||
} else {
|
||||
ensureActualsIsMutable();
|
||||
actuals_.addAll(other.actuals_);
|
||||
}
|
||||
|
||||
}
|
||||
setUnknownFields(
|
||||
getUnknownFields().concat(other.unknownFields));
|
||||
@@ -612,6 +689,12 @@ public final class IrFile extends
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < getActualsCount(); i++) {
|
||||
if (!getActuals(i).isInitialized()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1017,6 +1100,131 @@ public final class IrFile extends
|
||||
return this;
|
||||
}
|
||||
|
||||
private java.util.List<org.jetbrains.kotlin.backend.common.serialization.proto.Actual> actuals_ =
|
||||
java.util.Collections.emptyList();
|
||||
private void ensureActualsIsMutable() {
|
||||
if (!((bitField0_ & 0x00000020) == 0x00000020)) {
|
||||
actuals_ = new java.util.ArrayList<org.jetbrains.kotlin.backend.common.serialization.proto.Actual>(actuals_);
|
||||
bitField0_ |= 0x00000020;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public java.util.List<org.jetbrains.kotlin.backend.common.serialization.proto.Actual> getActualsList() {
|
||||
return java.util.Collections.unmodifiableList(actuals_);
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public int getActualsCount() {
|
||||
return actuals_.size();
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public org.jetbrains.kotlin.backend.common.serialization.proto.Actual getActuals(int index) {
|
||||
return actuals_.get(index);
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public Builder setActuals(
|
||||
int index, org.jetbrains.kotlin.backend.common.serialization.proto.Actual value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
ensureActualsIsMutable();
|
||||
actuals_.set(index, value);
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public Builder setActuals(
|
||||
int index, org.jetbrains.kotlin.backend.common.serialization.proto.Actual.Builder builderForValue) {
|
||||
ensureActualsIsMutable();
|
||||
actuals_.set(index, builderForValue.build());
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public Builder addActuals(org.jetbrains.kotlin.backend.common.serialization.proto.Actual value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
ensureActualsIsMutable();
|
||||
actuals_.add(value);
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public Builder addActuals(
|
||||
int index, org.jetbrains.kotlin.backend.common.serialization.proto.Actual value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
ensureActualsIsMutable();
|
||||
actuals_.add(index, value);
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public Builder addActuals(
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.Actual.Builder builderForValue) {
|
||||
ensureActualsIsMutable();
|
||||
actuals_.add(builderForValue.build());
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public Builder addActuals(
|
||||
int index, org.jetbrains.kotlin.backend.common.serialization.proto.Actual.Builder builderForValue) {
|
||||
ensureActualsIsMutable();
|
||||
actuals_.add(index, builderForValue.build());
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public Builder addAllActuals(
|
||||
java.lang.Iterable<? extends org.jetbrains.kotlin.backend.common.serialization.proto.Actual> values) {
|
||||
ensureActualsIsMutable();
|
||||
org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
|
||||
values, actuals_);
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public Builder clearActuals() {
|
||||
actuals_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000020);
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
public Builder removeActuals(int index) {
|
||||
ensureActualsIsMutable();
|
||||
actuals_.remove(index);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.backend.common.serialization.proto.IrFile)
|
||||
}
|
||||
|
||||
|
||||
@@ -68,4 +68,18 @@ public interface IrFileOrBuilder extends
|
||||
* <code>repeated int32 explicitly_exported_to_compiler = 5;</code>
|
||||
*/
|
||||
int getExplicitlyExportedToCompiler(int index);
|
||||
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
java.util.List<org.jetbrains.kotlin.backend.common.serialization.proto.Actual>
|
||||
getActualsList();
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.Actual getActuals(int index);
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.Actual actuals = 6;</code>
|
||||
*/
|
||||
int getActualsCount();
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir.JsMangler
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.serialization.metadata.KlibMetadataIncrementalSerializer
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.util.ExpectDeclarationRemover
|
||||
import org.jetbrains.kotlin.ir.util.IrDeserializer
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
@@ -80,6 +81,9 @@ val emptyLoggingContext = object : LoggingContext {
|
||||
private val CompilerConfiguration.metadataVersion
|
||||
get() = get(CommonConfigurationKeys.METADATA_VERSION) as? KlibMetadataVersion ?: KlibMetadataVersion.INSTANCE
|
||||
|
||||
private val CompilerConfiguration.klibMpp: Boolean
|
||||
get() = get(CommonConfigurationKeys.KLIB_MPP) ?: false
|
||||
|
||||
class KotlinFileSerializedData(val metadata: ByteArray, val irData: SerializedIrFile)
|
||||
|
||||
fun generateKLib(
|
||||
@@ -124,11 +128,16 @@ fun generateKLib(
|
||||
|
||||
val psi2IrContext = runAnalysisAndPreparePsi2Ir(depsDescriptors)
|
||||
|
||||
val moduleFragment = psi2IrContext.generateModuleFragmentWithPlugins(project, files)
|
||||
val expectDescriptorToSymbol = mutableMapOf<DeclarationDescriptor, IrSymbol>()
|
||||
|
||||
val moduleFragment = psi2IrContext.generateModuleFragmentWithPlugins(project, files,
|
||||
deserializer = null, expectDescriptorToSymbol = expectDescriptorToSymbol)
|
||||
|
||||
val moduleName = configuration[CommonConfigurationKeys.MODULE_NAME]!!
|
||||
|
||||
moduleFragment.acceptVoid(ExpectDeclarationRemover(psi2IrContext.symbolTable, false))
|
||||
if (!configuration.klibMpp) {
|
||||
moduleFragment.acceptVoid(ExpectDeclarationRemover(psi2IrContext.symbolTable, false))
|
||||
}
|
||||
|
||||
serializeModuleIntoKlib(
|
||||
moduleName,
|
||||
@@ -138,6 +147,7 @@ fun generateKLib(
|
||||
outputKlibPath,
|
||||
allDependencies.getFullList(),
|
||||
moduleFragment,
|
||||
expectDescriptorToSymbol,
|
||||
icData,
|
||||
nopack
|
||||
)
|
||||
@@ -181,6 +191,8 @@ fun loadIr(
|
||||
deserializer.deserializeIrModuleHeader(depsDescriptors.getModuleDescriptor(it))!!
|
||||
}
|
||||
|
||||
deserializer.initializeExpectActualLinker()
|
||||
|
||||
val moduleFragment = psi2IrContext.generateModuleFragmentWithPlugins(project, files, deserializer)
|
||||
|
||||
return IrModuleInfo(moduleFragment, deserializedModuleFragments, irBuiltIns, symbolTable, deserializer)
|
||||
@@ -202,7 +214,8 @@ private fun runAnalysisAndPreparePsi2Ir(depsDescriptors: ModulesStructure): Gene
|
||||
fun GeneratorContext.generateModuleFragmentWithPlugins(
|
||||
project: Project,
|
||||
files: List<KtFile>,
|
||||
deserializer: IrDeserializer? = null
|
||||
deserializer: IrDeserializer? = null,
|
||||
expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>? = null
|
||||
): IrModuleFragment {
|
||||
val irProviders = generateTypicalIrProviderList(moduleDescriptor, irBuiltIns, symbolTable, deserializer)
|
||||
val psi2Ir = Psi2IrTranslator(languageVersionSettings, configuration, mangler = JsMangler)
|
||||
@@ -227,16 +240,17 @@ fun GeneratorContext.generateModuleFragmentWithPlugins(
|
||||
psi2Ir.generateModuleFragment(
|
||||
this,
|
||||
files,
|
||||
irProviders
|
||||
irProviders,
|
||||
expectDescriptorToSymbol
|
||||
)
|
||||
return moduleFragment
|
||||
}
|
||||
|
||||
fun GeneratorContext.generateModuleFragment(files: List<KtFile>, deserializer: IrDeserializer? = null): IrModuleFragment {
|
||||
fun GeneratorContext.generateModuleFragment(files: List<KtFile>, deserializer: IrDeserializer? = null, expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>? = null): IrModuleFragment {
|
||||
val irProviders = generateTypicalIrProviderList(moduleDescriptor, irBuiltIns, symbolTable, deserializer)
|
||||
return Psi2IrTranslator(
|
||||
languageVersionSettings, configuration, mangler = JsMangler
|
||||
).generateModuleFragment(this, files, irProviders)
|
||||
).generateModuleFragment(this, files, irProviders, expectDescriptorToSymbol)
|
||||
}
|
||||
|
||||
|
||||
@@ -358,6 +372,7 @@ fun serializeModuleIntoKlib(
|
||||
klibPath: String,
|
||||
dependencies: List<KotlinLibrary>,
|
||||
moduleFragment: IrModuleFragment,
|
||||
expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>,
|
||||
cleanFiles: List<KotlinFileSerializedData>,
|
||||
nopack: Boolean
|
||||
) {
|
||||
@@ -365,7 +380,7 @@ fun serializeModuleIntoKlib(
|
||||
|
||||
val descriptorTable = DescriptorTable.createDefault()
|
||||
val serializedIr =
|
||||
JsIrModuleSerializer(emptyLoggingContext, moduleFragment.irBuiltins, descriptorTable).serializedIrModule(moduleFragment)
|
||||
JsIrModuleSerializer(emptyLoggingContext, moduleFragment.irBuiltins, descriptorTable, skipExpects = !configuration.klibMpp, expectDescriptorToSymbol = expectDescriptorToSymbol).serializedIrModule(moduleFragment)
|
||||
|
||||
val moduleDescriptor = moduleFragment.descriptor
|
||||
|
||||
@@ -375,7 +390,10 @@ fun serializeModuleIntoKlib(
|
||||
val metadataSerializer = KlibMetadataIncrementalSerializer(
|
||||
languageVersionSettings,
|
||||
metadataVersion,
|
||||
descriptorTable)
|
||||
moduleDescriptor,
|
||||
descriptorTable,
|
||||
skipExpects = !configuration.klibMpp
|
||||
)
|
||||
|
||||
fun serializeScope(fqName: FqName, memberScope: Collection<DeclarationDescriptor>): ByteArray {
|
||||
return metadataSerializer.serializePackageFragment(
|
||||
|
||||
@@ -9,12 +9,16 @@ import org.jetbrains.kotlin.backend.common.LoggingContext
|
||||
import org.jetbrains.kotlin.backend.common.serialization.IrFileSerializer
|
||||
import org.jetbrains.kotlin.backend.common.serialization.DeclarationTable
|
||||
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
|
||||
class JsIrFileSerializer(
|
||||
logger: LoggingContext,
|
||||
declarationTable: DeclarationTable,
|
||||
private val expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>,
|
||||
skipExpects: Boolean,
|
||||
bodiesOnlyForInlines: Boolean = false
|
||||
) : IrFileSerializer(logger, declarationTable, bodiesOnlyForInlines) {
|
||||
) : IrFileSerializer(logger, declarationTable, expectDescriptorToSymbol, bodiesOnlyForInlines = bodiesOnlyForInlines, skipExpects = skipExpects) {
|
||||
|
||||
// Temporary keep order of any property, even of constants
|
||||
override fun keepOrderOfProperties(property: IrProperty): Boolean = true
|
||||
|
||||
@@ -9,14 +9,21 @@ import org.jetbrains.kotlin.backend.common.LoggingContext
|
||||
import org.jetbrains.kotlin.backend.common.serialization.DeclarationTable
|
||||
import org.jetbrains.kotlin.backend.common.serialization.DescriptorTable
|
||||
import org.jetbrains.kotlin.backend.common.serialization.IrModuleSerializer
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
|
||||
class JsIrModuleSerializer(logger: LoggingContext, irBuiltIns: IrBuiltIns, private val descriptorTable: DescriptorTable) :
|
||||
IrModuleSerializer<JsIrFileSerializer>(logger) {
|
||||
class JsIrModuleSerializer(
|
||||
logger: LoggingContext,
|
||||
irBuiltIns: IrBuiltIns,
|
||||
private val descriptorTable: DescriptorTable,
|
||||
private val expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>,
|
||||
val skipExpects: Boolean
|
||||
) : IrModuleSerializer<JsIrFileSerializer>(logger) {
|
||||
|
||||
private val globalDeclarationTable = JsGlobalDeclarationTable(irBuiltIns)
|
||||
|
||||
override fun createSerializerForFile(file: IrFile): JsIrFileSerializer =
|
||||
JsIrFileSerializer(logger, DeclarationTable(descriptorTable, globalDeclarationTable, 0))
|
||||
JsIrFileSerializer(logger, DeclarationTable(descriptorTable, globalDeclarationTable, 0), expectDescriptorToSymbol, skipExpects = skipExpects)
|
||||
}
|
||||
@@ -18,6 +18,8 @@ import org.jetbrains.kotlin.resolve.multiplatform.ExpectedActualResolver.Compati
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberDescriptor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeConstructor
|
||||
import org.jetbrains.kotlin.types.TypeConstructorSubstitution
|
||||
@@ -55,7 +57,7 @@ object ExpectedActualResolver {
|
||||
// TODO: use some other way to determine that the declaration is from Kotlin.
|
||||
// This way behavior differs between fast and PSI-based Java class reading mode
|
||||
// TODO: support non-source definitions (e.g. from Java)
|
||||
actual.source.containingFile != SourceFile.NO_SOURCE_FILE
|
||||
actual.couldHaveASource
|
||||
}.groupBy { actual ->
|
||||
areCompatibleCallables(expected, actual, platformModule)
|
||||
}
|
||||
@@ -63,7 +65,7 @@ object ExpectedActualResolver {
|
||||
is ClassDescriptor -> {
|
||||
expected.findClassifiersFromModule(platformModule, moduleVisibilityFilter).filter { actual ->
|
||||
expected != actual && !actual.isExpect &&
|
||||
actual.source.containingFile != SourceFile.NO_SOURCE_FILE
|
||||
actual.couldHaveASource
|
||||
}.groupBy { actual ->
|
||||
areCompatibleClassifiers(expected, actual)
|
||||
}
|
||||
@@ -560,3 +562,24 @@ object ExpectedActualResolver {
|
||||
}
|
||||
}
|
||||
|
||||
fun DeclarationDescriptor.findExpects(inModule: ModuleDescriptor = this.module): List<MemberDescriptor> {
|
||||
return ExpectedActualResolver.findExpectedForActual(
|
||||
this as MemberDescriptor,
|
||||
inModule,
|
||||
{ true }
|
||||
)?.get(Compatible).orEmpty()
|
||||
}
|
||||
|
||||
fun DeclarationDescriptor.findActuals(inModule: ModuleDescriptor = this.module): List<MemberDescriptor> {
|
||||
return ExpectedActualResolver.findActualForExpected(
|
||||
(this as MemberDescriptor),
|
||||
inModule,
|
||||
{ true }
|
||||
)?.get(Compatible).orEmpty()
|
||||
}
|
||||
|
||||
// TODO: Klibs still need to better handle source in deserialized descriptors.
|
||||
val DeclarationDescriptorWithSource.couldHaveASource: Boolean get() =
|
||||
this.source.containingFile != SourceFile.NO_SOURCE_FILE ||
|
||||
this is DeserializedMemberDescriptor ||
|
||||
this is DeserializedClassDescriptor
|
||||
1
compiler/testData/cli/js/jsExtraHelp.out
vendored
1
compiler/testData/cli/js/jsExtraHelp.out
vendored
@@ -34,6 +34,7 @@ where advanced options include:
|
||||
Use 'warning' level to issue warnings instead of errors.
|
||||
-Xinline-classes Enable experimental inline classes
|
||||
-Xintellij-plugin-root=<path> Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found
|
||||
-Xklib-mpp Enable experimental support for multi-platform klib libraries
|
||||
-Xlegacy-smart-cast-after-try Allow var smart casts despite assignment in try block
|
||||
-Xlist-phases List backend phases
|
||||
-Xmetadata-version Change metadata version of the generated binary files
|
||||
|
||||
1
compiler/testData/cli/jvm/extraHelp.out
vendored
1
compiler/testData/cli/jvm/extraHelp.out
vendored
@@ -91,6 +91,7 @@ where advanced options include:
|
||||
Use 'warning' level to issue warnings instead of errors.
|
||||
-Xinline-classes Enable experimental inline classes
|
||||
-Xintellij-plugin-root=<path> Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found
|
||||
-Xklib-mpp Enable experimental support for multi-platform klib libraries
|
||||
-Xlegacy-smart-cast-after-try Allow var smart casts despite assignment in try block
|
||||
-Xlist-phases List backend phases
|
||||
-Xmetadata-version Change metadata version of the generated binary files
|
||||
|
||||
60
compiler/testData/codegen/box/multiplatform/multiModule/expectActualLink.kt
vendored
Normal file
60
compiler/testData/codegen/box/multiplatform/multiModule/expectActualLink.kt
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// KLIB_BASED_MPP
|
||||
// IGNORE_BACKEND: JS
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
// MODULE: A
|
||||
// FILE: a.kt
|
||||
@file:Suppress("NO_ACTUAL_FOR_EXPECT")
|
||||
package foo
|
||||
|
||||
expect fun foo1(): String
|
||||
expect fun foo2(): String
|
||||
expect fun foo3(): String
|
||||
expect fun foo4(): String
|
||||
expect fun foo5(): String
|
||||
expect fun foo6(): String
|
||||
|
||||
actual fun foo1() = "1"
|
||||
actual fun foo2() = "2"
|
||||
|
||||
fun use1() = foo1()
|
||||
fun use3() = foo3()
|
||||
|
||||
|
||||
// MODULE: B(A)
|
||||
// FILE: b.kt
|
||||
@file:Suppress("ACTUAL_WITHOUT_EXPECT")
|
||||
package foo
|
||||
|
||||
actual fun foo3() = "3"
|
||||
actual fun foo4() = "4"
|
||||
actual fun foo5() = "5"
|
||||
|
||||
fun use2() = foo2()
|
||||
fun use4() = foo4()
|
||||
fun use6() = foo6()
|
||||
|
||||
|
||||
// MODULE: C(B)
|
||||
// FILE: c.kt
|
||||
@file:Suppress("ACTUAL_WITHOUT_EXPECT")
|
||||
package foo
|
||||
|
||||
actual fun foo6() = "6"
|
||||
|
||||
fun use5() = foo5()
|
||||
|
||||
|
||||
// MODULE: main(C)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import foo.*
|
||||
|
||||
fun box(): String {
|
||||
return if (use1() + use2() + use3() + use4() + use5() + use6() == "123456") "OK" else "FAIL"
|
||||
}
|
||||
|
||||
84
compiler/testData/codegen/box/multiplatform/multiModule/expectActualMemberLink.kt
vendored
Normal file
84
compiler/testData/codegen/box/multiplatform/multiModule/expectActualMemberLink.kt
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// KLIB_BASED_MPP
|
||||
// IGNORE_BACKEND: JS
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
// MODULE: A
|
||||
// FILE: a.kt
|
||||
@file:Suppress("NO_ACTUAL_FOR_EXPECT")
|
||||
package foo
|
||||
|
||||
expect class C1() {
|
||||
fun foo1(): String
|
||||
}
|
||||
expect class C2() {
|
||||
fun foo2(): String
|
||||
}
|
||||
expect class C3() {
|
||||
fun foo3(): String
|
||||
}
|
||||
expect class C4() {
|
||||
fun foo4(): String
|
||||
}
|
||||
expect class C5() {
|
||||
fun foo5(): String
|
||||
}
|
||||
expect class C6() {
|
||||
fun foo6(): String
|
||||
}
|
||||
|
||||
actual class C1 {
|
||||
actual fun foo1() = "1"
|
||||
}
|
||||
actual class C2 {
|
||||
actual fun foo2() = "2"
|
||||
}
|
||||
|
||||
fun use1() = C1().foo1()
|
||||
fun use3() = C3().foo3()
|
||||
|
||||
|
||||
// MODULE: B(A)
|
||||
// FILE: b.kt
|
||||
@file:Suppress("ACTUAL_WITHOUT_EXPECT")
|
||||
package foo
|
||||
|
||||
actual class C3 {
|
||||
actual fun foo3() = "3"
|
||||
}
|
||||
actual class C4 {
|
||||
actual fun foo4() = "4"
|
||||
}
|
||||
actual class C5 {
|
||||
actual fun foo5() = "5"
|
||||
}
|
||||
|
||||
fun use2() = C2().foo2()
|
||||
fun use4() = C4().foo4()
|
||||
fun use6() = C6().foo6()
|
||||
|
||||
|
||||
// MODULE: C(B)
|
||||
// FILE: c.kt
|
||||
@file:Suppress("ACTUAL_WITHOUT_EXPECT")
|
||||
package foo
|
||||
|
||||
actual class C6 {
|
||||
actual fun foo6() = "6"
|
||||
}
|
||||
|
||||
fun use5() = C5().foo5()
|
||||
|
||||
|
||||
// MODULE: main(C)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import foo.*
|
||||
|
||||
fun box(): String {
|
||||
return if (use1() + use2() + use3() + use4() + use5() + use6() == "123456") "OK" else "FAIL"
|
||||
}
|
||||
|
||||
91
compiler/testData/codegen/box/multiplatform/multiModule/expectActualTypealiasLink.kt
vendored
Normal file
91
compiler/testData/codegen/box/multiplatform/multiModule/expectActualTypealiasLink.kt
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// KLIB_BASED_MPP
|
||||
// IGNORE_BACKEND: JS
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
// MODULE: A
|
||||
// FILE: a.kt
|
||||
@file:Suppress("NO_ACTUAL_FOR_EXPECT")
|
||||
package foo
|
||||
|
||||
expect class C1() {
|
||||
fun foo1(): String
|
||||
}
|
||||
expect class C2() {
|
||||
fun foo2(): String
|
||||
}
|
||||
expect class C3() {
|
||||
fun foo3(): String
|
||||
}
|
||||
expect class C4() {
|
||||
fun foo4(): String
|
||||
}
|
||||
expect class C5() {
|
||||
fun foo5(): String
|
||||
}
|
||||
expect class C6() {
|
||||
fun foo6(): String
|
||||
}
|
||||
|
||||
class D1 {
|
||||
fun foo1() = "1"
|
||||
}
|
||||
class D2 {
|
||||
fun foo2() = "2"
|
||||
}
|
||||
|
||||
fun use1() = C1().foo1()
|
||||
fun use3() = C3().foo3()
|
||||
|
||||
|
||||
// MODULE: B(A)
|
||||
// FILE: b.kt
|
||||
@file:Suppress("ACTUAL_WITHOUT_EXPECT")
|
||||
package foo
|
||||
|
||||
class D3 {
|
||||
fun foo3() = "3"
|
||||
}
|
||||
class D4 {
|
||||
fun foo4() = "4"
|
||||
}
|
||||
class D5 {
|
||||
fun foo5() = "5"
|
||||
}
|
||||
|
||||
fun use2() = C2().foo2()
|
||||
fun use4() = C4().foo4()
|
||||
fun use6() = C6().foo6()
|
||||
|
||||
|
||||
// MODULE: C(B)
|
||||
// FILE: c.kt
|
||||
@file:Suppress("ACTUAL_WITHOUT_EXPECT")
|
||||
package foo
|
||||
|
||||
class D6 {
|
||||
fun foo6() = "6"
|
||||
}
|
||||
|
||||
fun use5() = C5().foo5()
|
||||
|
||||
actual typealias C1 = D1
|
||||
actual typealias C2 = D2
|
||||
actual typealias C3 = D3
|
||||
actual typealias C4 = D4
|
||||
actual typealias C5 = D5
|
||||
actual typealias C6 = D6
|
||||
|
||||
|
||||
// MODULE: main(C)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import foo.*
|
||||
|
||||
fun box(): String {
|
||||
return if (use1() + use2() + use3() + use4() + use5() + use6() == "123456") "OK" else "FAIL"
|
||||
}
|
||||
|
||||
@@ -16936,6 +16936,34 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/typeAlias.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/multiplatform/multiModule")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class MultiModule extends AbstractBlackBoxCodegenTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInMultiModule() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/multiModule"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualLink.kt")
|
||||
public void testExpectActualLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualLink.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualMemberLink.kt")
|
||||
public void testExpectActualMemberLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualMemberLink.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualTypealiasLink.kt")
|
||||
public void testExpectActualTypealiasLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualTypealiasLink.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/nonLocalReturns")
|
||||
|
||||
@@ -16936,6 +16936,34 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/typeAlias.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/multiplatform/multiModule")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class MultiModule extends AbstractLightAnalysisModeTest {
|
||||
@TestMetadata("expectActualLink.kt")
|
||||
public void ignoreExpectActualLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualLink.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualMemberLink.kt")
|
||||
public void ignoreExpectActualMemberLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualMemberLink.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualTypealiasLink.kt")
|
||||
public void ignoreExpectActualTypealiasLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualTypealiasLink.kt");
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInMultiModule() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/multiModule"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/nonLocalReturns")
|
||||
|
||||
@@ -15786,6 +15786,34 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/typeAlias.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/multiplatform/multiModule")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class MultiModule extends AbstractFirBlackBoxCodegenTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: ");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInMultiModule() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/multiModule"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualLink.kt")
|
||||
public void testExpectActualLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualLink.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualMemberLink.kt")
|
||||
public void testExpectActualMemberLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualMemberLink.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualTypealiasLink.kt")
|
||||
public void testExpectActualTypealiasLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualTypealiasLink.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/nonLocalReturns")
|
||||
|
||||
@@ -15786,6 +15786,34 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/typeAlias.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/multiplatform/multiModule")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class MultiModule extends AbstractIrBlackBoxCodegenTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInMultiModule() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/multiModule"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualLink.kt")
|
||||
public void testExpectActualLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualLink.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualMemberLink.kt")
|
||||
public void testExpectActualMemberLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualMemberLink.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualTypealiasLink.kt")
|
||||
public void testExpectActualTypealiasLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualTypealiasLink.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/nonLocalReturns")
|
||||
|
||||
@@ -164,7 +164,7 @@ class DeserializedClassDescriptor(
|
||||
|
||||
override fun getSealedSubclasses() = sealedSubclasses()
|
||||
|
||||
override fun toString() = "deserialized class $name" // not using descriptor render to preserve laziness
|
||||
override fun toString() = "deserialized ${if (isExpect()) "expect" else ""} class $name" // not using descriptor render to preserve laziness
|
||||
|
||||
override fun getSource() = sourceElement
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ abstract class BasicBoxTest(
|
||||
|
||||
val runPlainBoxFunction = RUN_PLAIN_BOX_FUNCTION.matcher(fileContent).find()
|
||||
val inferMainModule = INFER_MAIN_MODULE.matcher(fileContent).find()
|
||||
val klibBasedMpp = KLIB_BASED_MPP.matcher(fileContent).find()
|
||||
|
||||
TestFileFactoryImpl(coroutinesPackage).use { testFactory ->
|
||||
val inputFiles = TestFiles.createTestFiles(
|
||||
@@ -162,7 +163,7 @@ abstract class BasicBoxTest(
|
||||
testFactory.tmpDir,
|
||||
file.parent, module, outputFileName, dceOutputFileName, dependencies, allDependencies, friends, modules.size > 1,
|
||||
!SKIP_SOURCEMAP_REMAPPING.matcher(fileContent).find(), outputPrefixFile, outputPostfixFile,
|
||||
actualMainCallParameters, testPackage, testFunction, needsFullIrRuntime, isMainModule
|
||||
actualMainCallParameters, testPackage, testFunction, needsFullIrRuntime, isMainModule, klibBasedMpp
|
||||
)
|
||||
|
||||
when {
|
||||
@@ -362,7 +363,8 @@ abstract class BasicBoxTest(
|
||||
testPackage: String?,
|
||||
testFunction: String,
|
||||
needsFullIrRuntime: Boolean,
|
||||
isMainModule: Boolean
|
||||
isMainModule: Boolean,
|
||||
klibBasedMpp: Boolean
|
||||
) {
|
||||
val kotlinFiles = module.files.filter { it.fileName.endsWith(".kt") }
|
||||
val testFiles = kotlinFiles.map { it.fileName }
|
||||
@@ -378,7 +380,7 @@ abstract class BasicBoxTest(
|
||||
val psiFiles = createPsiFiles(allSourceFiles.sortedBy { it.canonicalPath }.map { it.canonicalPath })
|
||||
|
||||
val sourceDirs = (testFiles + additionalFiles).map { File(it).parent }.distinct()
|
||||
val config = createConfig(sourceDirs, module, dependencies, allDependencies, friends, multiModule, tmpDir, incrementalData = null)
|
||||
val config = createConfig(sourceDirs, module, dependencies, allDependencies, friends, multiModule, tmpDir, incrementalData = null, klibBasedMpp = klibBasedMpp)
|
||||
val outputFile = File(outputFileName)
|
||||
val dceOutputFile = File(dceOutputFileName)
|
||||
|
||||
@@ -391,7 +393,7 @@ abstract class BasicBoxTest(
|
||||
if (incrementalCompilationChecksEnabled && module.hasFilesToRecompile) {
|
||||
checkIncrementalCompilation(
|
||||
sourceDirs, module, kotlinFiles, dependencies, allDependencies, friends, multiModule, tmpDir, remap,
|
||||
outputFile, outputPrefixFile, outputPostfixFile, mainCallParameters, incrementalData, testPackage, testFunction, needsFullIrRuntime
|
||||
outputFile, outputPrefixFile, outputPostfixFile, mainCallParameters, incrementalData, testPackage, testFunction, needsFullIrRuntime, klibBasedMpp
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -413,7 +415,8 @@ abstract class BasicBoxTest(
|
||||
incrementalData: IncrementalData,
|
||||
testPackage: String?,
|
||||
testFunction: String,
|
||||
needsFullIrRuntime: Boolean
|
||||
needsFullIrRuntime: Boolean,
|
||||
klibBasedMpp: Boolean
|
||||
) {
|
||||
val sourceToTranslationUnit = hashMapOf<File, TranslationUnit>()
|
||||
for (testFile in kotlinFiles) {
|
||||
@@ -431,7 +434,7 @@ abstract class BasicBoxTest(
|
||||
.sortedBy { it.canonicalPath }
|
||||
.map { sourceToTranslationUnit[it]!! }
|
||||
|
||||
val recompiledConfig = createConfig(sourceDirs, module, dependencies, allDependencies, friends, multiModule, tmpDir, incrementalData)
|
||||
val recompiledConfig = createConfig(sourceDirs, module, dependencies, allDependencies, friends, multiModule, tmpDir, incrementalData, klibBasedMpp)
|
||||
val recompiledOutputFile = File(outputFile.parentFile, outputFile.nameWithoutExtension + "-recompiled.js")
|
||||
|
||||
translateFiles(
|
||||
@@ -644,7 +647,7 @@ abstract class BasicBoxTest(
|
||||
|
||||
private fun createConfig(
|
||||
sourceDirs: List<String>, module: TestModule, dependencies: List<String>, allDependencies: List<String>, friends: List<String>,
|
||||
multiModule: Boolean, tmpDir: File, incrementalData: IncrementalData?
|
||||
multiModule: Boolean, tmpDir: File, incrementalData: IncrementalData?, klibBasedMpp: Boolean
|
||||
): JsConfig {
|
||||
val configuration = environment.configuration.copy()
|
||||
|
||||
@@ -696,6 +699,8 @@ abstract class BasicBoxTest(
|
||||
)
|
||||
)
|
||||
|
||||
configuration.put(CommonConfigurationKeys.KLIB_MPP, klibBasedMpp)
|
||||
|
||||
return JsConfig(project, configuration, METADATA_CACHE, (JsConfig.JS_STDLIB + JsConfig.JS_KOTLIN_TEST).toSet())
|
||||
}
|
||||
|
||||
@@ -889,6 +894,7 @@ abstract class BasicBoxTest(
|
||||
private val SOURCE_MAP_SOURCE_EMBEDDING = Regex("^// *SOURCE_MAP_EMBED_SOURCES: ([A-Z]+)*\$", RegexOption.MULTILINE)
|
||||
private val CALL_MAIN_PATTERN = Pattern.compile("^// *CALL_MAIN *$", Pattern.MULTILINE)
|
||||
private val KJS_WITH_FULL_RUNTIME = Pattern.compile("^// *KJS_WITH_FULL_RUNTIME *\$", Pattern.MULTILINE)
|
||||
private val KLIB_BASED_MPP = Pattern.compile("^// KLIB_BASED_MPP *$", Pattern.MULTILINE)
|
||||
|
||||
@JvmStatic
|
||||
protected val runTestInNashorn = getBoolean("kotlin.js.useNashorn")
|
||||
|
||||
@@ -12911,6 +12911,34 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/typeAlias.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/multiplatform/multiModule")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class MultiModule extends AbstractIrJsCodegenBoxTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInMultiModule() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/multiModule"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualLink.kt")
|
||||
public void testExpectActualLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualLink.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualMemberLink.kt")
|
||||
public void testExpectActualMemberLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualMemberLink.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualTypealiasLink.kt")
|
||||
public void testExpectActualTypealiasLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualTypealiasLink.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/nonLocalReturns")
|
||||
|
||||
@@ -14051,6 +14051,34 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/typeAlias.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/multiplatform/multiModule")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class MultiModule extends AbstractJsCodegenBoxTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInMultiModule() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/multiModule"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualLink.kt")
|
||||
public void testExpectActualLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualLink.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualMemberLink.kt")
|
||||
public void testExpectActualMemberLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualMemberLink.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectActualTypealiasLink.kt")
|
||||
public void testExpectActualTypealiasLink() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualTypealiasLink.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/nonLocalReturns")
|
||||
|
||||
Reference in New Issue
Block a user