JVM_IR KT-41214 emit PermittedSubclasses on JDK17+

This commit is contained in:
Dmitry Petrov
2021-10-08 09:57:05 +03:00
committed by TeamCityServer
parent dca4a8e722
commit 146f0f4904
41 changed files with 695 additions and 43 deletions
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.lazy.IrMaybeDeserializedClass
import org.jetbrains.kotlin.ir.declarations.lazy.lazyVar
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.types.IrSimpleType
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
@@ -102,6 +103,10 @@ class Fir2IrLazyClass(
fir.superTypeRefs.map { it.toIrType(typeConverter) }
}
override var sealedSubclasses: List<IrClassSymbol> by lazyVar(lock) {
TODO()
}
override var thisReceiver: IrValueParameter? by lazyVar(lock) {
symbolTable.enterScope(this)
val typeArguments = fir.typeParameters.map {
@@ -55,7 +55,7 @@ open class JvmIrCodegenFactory(
val irProviders: List<IrProvider>,
val extensions: JvmGeneratorExtensionsImpl,
val backendExtension: JvmBackendExtension,
val notifyCodegenStart: () -> Unit,
val notifyCodegenStart: () -> Unit
) : CodegenFactory.BackendInput
override fun convertToIr(input: CodegenFactory.IrConversionInput): JvmIrBackendInput {
@@ -215,7 +215,7 @@ open class JvmIrCodegenFactory(
val phaseConfig = customPhaseConfig ?: PhaseConfig(jvmPhases)
val context = JvmBackendContext(
state, irModuleFragment.irBuiltins, irModuleFragment, symbolTable, phaseConfig, extensions, backendExtension, irSerializer,
notifyCodegenStart
notifyCodegenStart,
)
/* JvmBackendContext creates new unbound symbols, have to resolve them. */
ExternalDependenciesGenerator(symbolTable, irProviders).generateUnboundSymbolsAsDependencies()
@@ -241,7 +241,8 @@ open class JvmIrCodegenFactory(
generateModule(
state,
JvmIrBackendInput(
irModuleFragment, symbolTable, phaseConfig, irProviders, extensions, backendExtension, notifyCodegenStart
irModuleFragment, symbolTable, phaseConfig, irProviders, extensions, backendExtension,
notifyCodegenStart
)
)
}
@@ -48,7 +48,7 @@ class JvmBackendContext(
val generatorExtensions: JvmGeneratorExtensions,
val backendExtension: JvmBackendExtension,
val irSerializer: JvmIrSerializer?,
val notifyCodegenStart: () -> Unit,
val notifyCodegenStart: () -> Unit
) : CommonBackendContext {
// If the JVM fqname of a class differs from what is implied by its parent, e.g. if it's a file class
// annotated with @JvmPackageName, the correct name is recorded here.
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.codegen.addRecordComponent
import org.jetbrains.kotlin.codegen.inline.*
import org.jetbrains.kotlin.codegen.writeKotlinMetadata
import org.jetbrains.kotlin.config.JvmAnalysisFlags
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
@@ -130,6 +131,14 @@ class ClassCodegen private constructor(
if (generated) return
generated = true
// Generate PermittedSubclasses attribute for sealed class.
if (state.languageVersionSettings.supportsFeature(LanguageFeature.JvmPermittedSubclassesAttributeForSealed) &&
irClass.modality == Modality.SEALED &&
state.target >= JvmTarget.JVM_17
) {
generatePermittedSubclasses()
}
// Generating a method node may cause the addition of a field with an initializer if an inline function
// call uses `assert` and the JVM assertions mode is enabled. To avoid concurrent modification errors,
// there is a very specific generation order.
@@ -188,6 +197,15 @@ class ClassCodegen private constructor(
jvmSignatureClashDetector.reportErrors(classOrigin)
}
private fun generatePermittedSubclasses() {
val sealedSubclasses = irClass.sealedSubclasses
if (sealedSubclasses.isEmpty()) return
val classVisitor = visitor.visitor
for (sealedSubclassSymbol in sealedSubclasses) {
classVisitor.visitPermittedSubclass(typeMapper.mapClass(sealedSubclassSymbol.owner).internalName)
}
}
private fun addReifiedParametersFromSignature() {
for (type in irClass.superTypes) {
processTypeParameters(type)
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.psi2ir.generators
import org.jetbrains.kotlin.backend.common.CodegenUtil
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.descriptors.IrImplementingDelegateDescriptorImpl
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
@@ -56,6 +57,7 @@ import org.jetbrains.kotlin.types.TypeProjectionImpl
import org.jetbrains.kotlin.types.TypeSubstitutor
import org.jetbrains.kotlin.utils.newHashMapWithExpectedSize
@ObsoleteDescriptorBasedAPI
class ClassGenerator(
declarationGenerator: DeclarationGenerator
) : DeclarationGeneratorExtension(declarationGenerator) {
@@ -115,6 +117,8 @@ class ClassGenerator(
if (DescriptorUtils.isEnumClass(classDescriptor)) {
generateAdditionalMembersForEnumClass(irClass)
}
irClass.sealedSubclasses = classDescriptor.sealedSubclasses.map { context.symbolTable.referenceClass(it) }
}
}
@@ -14,7 +14,9 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.NotFoundClasses
import org.jetbrains.kotlin.ir.IrBuiltIns
import org.jetbrains.kotlin.ir.builders.IrGeneratorContext
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.expressions.IrDeclarationReference
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
import org.jetbrains.kotlin.ir.util.SymbolTable
import org.jetbrains.kotlin.ir.util.TypeTranslator
@@ -46,7 +48,7 @@ class GeneratorContext private constructor(
extensions: GeneratorExtensions,
typeTranslator: TypeTranslator,
irBuiltIns: IrBuiltIns,
fragmentContext: FragmentContext? = null
fragmentContext: FragmentContext? = null,
) : this(
configuration,
moduleDescriptor,
@@ -29,7 +29,7 @@ open class IrClassImpl(
override val startOffset: Int,
override val endOffset: Int,
override var origin: IrDeclarationOrigin,
override val symbol: IrClassSymbol,
final override val symbol: IrClassSymbol,
override val name: Name,
override val kind: ClassKind,
override var visibility: DescriptorVisibility,
@@ -70,4 +70,6 @@ open class IrClassImpl(
override var metadata: MetadataSource? = null
override var attributeOwnerId: IrAttributeContainer = this
override var sealedSubclasses: List<IrClassSymbol> = emptyList()
}
@@ -5,9 +5,23 @@
package org.jetbrains.kotlin.ir.declarations.persistent
import org.jetbrains.kotlin.descriptors.*
import java.util.ArrayList
import java.util.Collections
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
import org.jetbrains.kotlin.descriptors.InlineClassRepresentation
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.SourceElement
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
import org.jetbrains.kotlin.ir.declarations.MetadataSource
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ClassCarrier
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
@@ -18,7 +32,6 @@ import org.jetbrains.kotlin.ir.types.IrSimpleType
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IdSignature
import org.jetbrains.kotlin.name.Name
import java.util.*
// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT!
@@ -164,4 +177,15 @@ internal class PersistentIrClass(
}
override var attributeOwnerId: IrAttributeContainer = this
override var sealedSubclassesField: List<IrClassSymbol> = emptyList()
override var sealedSubclasses: List<IrClassSymbol>
get() = getCarrier().sealedSubclassesField
set(v) {
if (sealedSubclasses !== v) {
setCarrier()
sealedSubclassesField = v
}
}
}
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
@@ -29,6 +30,7 @@ internal interface ClassCarrier : DeclarationCarrier{
val typeParametersSymbolField: List<IrTypeParameterSymbol>
val superTypesField: List<IrType>
val inlineClassRepresentationField: InlineClassRepresentation<IrSimpleType>?
val sealedSubclassesField: List<IrClassSymbol>
override fun clone(): ClassCarrier {
return ClassCarrierImpl(
@@ -41,7 +43,8 @@ internal interface ClassCarrier : DeclarationCarrier{
modalityField,
typeParametersSymbolField,
superTypesField,
inlineClassRepresentationField
inlineClassRepresentationField,
sealedSubclassesField
)
}
}
@@ -56,7 +59,8 @@ internal class ClassCarrierImpl(
override val modalityField: Modality,
override val typeParametersSymbolField: List<IrTypeParameterSymbol>,
override val superTypesField: List<IrType>,
override val inlineClassRepresentationField: InlineClassRepresentation<IrSimpleType>?
override val inlineClassRepresentationField: InlineClassRepresentation<IrSimpleType>?,
override val sealedSubclassesField: List<IrClassSymbol>
) : ClassCarrier {
override val thisReceiverField: IrValueParameter?
@@ -87,6 +87,8 @@ internal abstract class IrCarrierDeserializer {
abstract fun deserializeSuperType(proto: Int): IrType
abstract fun deserializeSealedSubclass(proto: Long): IrClassSymbol
abstract fun deserializeType(proto: Int): IrType
abstract fun deserializeClass(proto: Long): IrClassSymbol
@@ -138,7 +140,8 @@ internal abstract class IrCarrierDeserializer {
deserializeModality(proto.flags),
proto.typeParametersList.map { deserializeTypeParameter(it) },
proto.superTypesList.map { deserializeSuperType(it) },
if (proto.hasInlineClassRepresentation()) deserializeInlineClassRepresentation(proto.inlineClassRepresentation) else null
if (proto.hasInlineClassRepresentation()) deserializeInlineClassRepresentation(proto.inlineClassRepresentation) else null,
proto.sealedSubclassesList.map { deserializeSealedSubclass(it) }
)
}
@@ -73,6 +73,8 @@ internal abstract class IrCarrierSerializer {
abstract fun serializeSuperType(value: IrType): Int
abstract fun serializeSealedSubclass(value: IrClassSymbol): Long
abstract fun serializeType(value: IrType): Int
abstract fun serializeClass(value: IrClassSymbol): Long
@@ -122,6 +124,7 @@ internal abstract class IrCarrierSerializer {
proto.addAllTypeParameters(carrier.typeParametersSymbolField.map { serializeTypeParameter(it) })
proto.addAllSuperTypes(carrier.superTypesField.map { serializeSuperType(it) })
carrier.inlineClassRepresentationField?.let { proto.setInlineClassRepresentation(serializeInlineClassRepresentation(it)) }
proto.addAllSealedSubclasses(carrier.sealedSubclassesField.map { serializeSealedSubclass(it) })
return proto.build().toByteArray()
}
@@ -22,6 +22,7 @@ internal fun PersistentIrGenerator.generateClass() {
descriptorType("InlineClassRepresentation") + "<" + import("IrSimpleType", "org.jetbrains.kotlin.ir.types") + ">?",
inlineClassRepresentationProto
)
val sealedSubclassesField = Field("sealedSubclasses", +"List<" + irSymbol("IrClassSymbol") + ">", sealedSubclassListProto)
writeFile("PersistentIrClass.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent") {
lines(
@@ -79,6 +80,7 @@ internal fun PersistentIrGenerator.generateClass() {
modalityField.toPersistentField(+"modality"),
inlineClassRepresentationField.toPersistentField(+"null"),
+"override var attributeOwnerId: " + IrAttributeContainer + " = this",
sealedSubclassesField.toPersistentField(+"emptyList()"),
),
id,
)()
@@ -93,6 +95,7 @@ internal fun PersistentIrGenerator.generateClass() {
typeParametersField,
superTypesField,
inlineClassRepresentationField,
sealedSubclassesField,
)()
})
@@ -104,5 +107,6 @@ internal fun PersistentIrGenerator.generateClass() {
typeParametersField,
superTypesField,
inlineClassRepresentationField,
sealedSubclassesField,
)
}
@@ -152,6 +152,7 @@ internal object PersistentIrGenerator {
val valueParameterListProto = Proto("int64", "valueParameter", +"Long", IrValueParameterSymbol, fieldKind = FieldKind.REPEATED)
val typeParameterListProto = Proto("int64", "typeParameter", +"Long", IrTypeParameterSymbol, fieldKind = FieldKind.REPEATED)
val superTypeListProto = Proto("int32", "superType", +"Int", IrType, fieldKind = FieldKind.REPEATED)
val sealedSubclassListProto = Proto("int64", "sealedSubclass", +"Long", IrClassSymbol, fieldKind = FieldKind.REPEATED)
val typeProto = Proto("int32", "type", +"Int", IrType, fieldKind = FieldKind.REQUIRED)
val optionalTypeProto = Proto("int32", "type", +"Int", IrType, fieldKind = FieldKind.OPTIONAL)
val variableProto = Proto("IrVariable", "variable", protoVariable, IrVariable)
@@ -187,6 +188,7 @@ internal object PersistentIrGenerator {
valueParameterListProto,
typeParameterListProto,
superTypeListProto,
sealedSubclassListProto,
typeProto,
optionalTypeProto,
classProto,
@@ -30,7 +30,6 @@ internal class IrCarrierDeserializerImpl(
val indexToBody: (Int) -> IrBody,
val indexToExpressionBody: (Int) -> IrExpressionBody
) : IrCarrierDeserializer() {
override fun deserializeParentSymbol(proto: Long): IrSymbol {
return declarationDeserializer.symbolDeserializer.deserializeIrSymbol(proto)
}
@@ -67,6 +66,10 @@ internal class IrCarrierDeserializerImpl(
return declarationDeserializer.deserializeIrType(proto)
}
override fun deserializeSealedSubclass(proto: Long): IrClassSymbol {
return declarationDeserializer.symbolDeserializer.deserializeIrSymbol(proto) as IrClassSymbol
}
override fun deserializeType(proto: Int): IrType {
return declarationDeserializer.deserializeIrType(proto)
}
@@ -63,6 +63,10 @@ internal class IrCarrierSerializerImpl(val fileSerializer: IrFileSerializer, val
return fileSerializer.serializeIrType(value)
}
override fun serializeSealedSubclass(value: IrClassSymbol): Long {
return fileSerializer.serializeIrSymbol(value)
}
override fun serializeType(value: IrType): Int {
return fileSerializer.serializeIrType(value)
}
@@ -51,6 +51,8 @@ abstract class IrClass :
abstract var inlineClassRepresentation: InlineClassRepresentation<IrSimpleType>?
abstract var sealedSubclasses: List<IrClassSymbol>
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitClass(this, data)
@@ -12,11 +12,7 @@ import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.types.IrSimpleType
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.DeclarationStubGenerator
import org.jetbrains.kotlin.ir.util.DeserializableClass
import org.jetbrains.kotlin.ir.util.TypeTranslator
import org.jetbrains.kotlin.ir.util.isObject
import org.jetbrains.kotlin.ir.util.render
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.metadata.ProtoBuf
import org.jetbrains.kotlin.metadata.deserialization.NameResolver
import org.jetbrains.kotlin.name.Name
@@ -65,10 +61,8 @@ class IrLazyClass(
generateChildStubs(descriptor.defaultType.memberScope.getContributedDescriptors(), it)
generateChildStubs(descriptor.staticScope.getContributedDescriptors(), it)
}
}.also {
it.forEach {
it.parent = this //initialize parent for non lazy cases
}
}.onEach {
it.parent = this //initialize parent for non lazy cases
}
}
@@ -98,6 +92,13 @@ class IrLazyClass(
}
}
override var sealedSubclasses: List<IrClassSymbol> by lazyVar(stubGenerator.lock) {
descriptor.sealedSubclasses.map { sealedSubclassDescriptor ->
// NB 'generateClassStub' would return an existing class if it's already present in symbol table
stubGenerator.generateClassStub(sealedSubclassDescriptor).symbol
}
}
override var inlineClassRepresentation: InlineClassRepresentation<IrSimpleType>? by lazyVar(stubGenerator.lock) {
descriptor.inlineClassRepresentation?.mapUnderlyingType {
it.toIrType() as? IrSimpleType ?: error("Inline class underlying type is not a simple type: ${render()}")
@@ -156,6 +156,9 @@ open class DeepCopyIrTreeWithSymbols(
superTypes = declaration.superTypes.map {
it.remapType()
}
sealedSubclasses = declaration.sealedSubclasses.map {
symbolRemapper.getReferencedClass(it)
}
thisReceiver = declaration.thisReceiver?.transform()
inlineClassRepresentation = declaration.inlineClassRepresentation?.mapUnderlyingType { it.remapType() as IrSimpleType }
declaration.transformDeclarationsTo(this)
@@ -111,6 +111,7 @@ class DumpIrTreeVisitor(
override fun visitClass(declaration: IrClass, data: String) {
declaration.dumpLabeledElementWith(data) {
dumpAnnotations(declaration)
declaration.sealedSubclasses.dumpItems("sealedSubclasses") { it.dump() }
declaration.thisReceiver?.accept(this, "\$this")
declaration.typeParameters.dumpElements()
declaration.declarations.ordered().dumpElements()
@@ -558,6 +558,7 @@ message IrClass {
repeated IrDeclaration declaration = 5;
repeated int32 super_type = 6 [packed=true];
optional IrInlineClassRepresentation inline_class_representation = 7;
repeated int64 sealed_subclass = 8 [packed=true];
}
message IrTypeAlias {
@@ -26,7 +26,8 @@ message PirClassCarrier {
repeated int64 typeParameters = 6;
repeated int32 superTypes = 7;
optional IrInlineClassRepresentation inlineClassRepresentation = 8;
optional int64 flags = 9 [default = 0];
repeated int64 sealedSubclasses = 9;
optional int64 flags = 10 [default = 0];
}
message PirConstructorCarrier {
@@ -348,6 +348,8 @@ class IrDeclarationDeserializer(
else -> computeMissingInlineClassRepresentationForCompatibility(this)
}
sealedSubclasses = proto.sealedSubclassList.map { deserializeIrSymbol(it) as IrClassSymbol }
fakeOverrideBuilder.enqueueClass(this, signature, compatibilityMode)
}
}
@@ -1327,6 +1327,10 @@ open class IrFileSerializer(
clazz.superTypes.forEach {
proto.addSuperType(serializeIrType(it))
}
clazz.sealedSubclasses.forEach {
proto.addSealedSubclass(serializeIrSymbol(it))
}
}
return proto.build()
@@ -134,6 +134,27 @@ public final class IrClass extends
bitField0_ |= 0x00000008;
break;
}
case 64: {
if (!((mutable_bitField0_ & 0x00000080) == 0x00000080)) {
sealedSubclass_ = new java.util.ArrayList<java.lang.Long>();
mutable_bitField0_ |= 0x00000080;
}
sealedSubclass_.add(input.readInt64());
break;
}
case 66: {
int length = input.readRawVarint32();
int limit = input.pushLimit(length);
if (!((mutable_bitField0_ & 0x00000080) == 0x00000080) && input.getBytesUntilLimit() > 0) {
sealedSubclass_ = new java.util.ArrayList<java.lang.Long>();
mutable_bitField0_ |= 0x00000080;
}
while (input.getBytesUntilLimit() > 0) {
sealedSubclass_.add(input.readInt64());
}
input.popLimit(limit);
break;
}
}
}
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
@@ -151,6 +172,9 @@ public final class IrClass extends
if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) {
superType_ = java.util.Collections.unmodifiableList(superType_);
}
if (((mutable_bitField0_ & 0x00000080) == 0x00000080)) {
sealedSubclass_ = java.util.Collections.unmodifiableList(sealedSubclass_);
}
try {
unknownFieldsCodedOutput.flush();
} catch (java.io.IOException e) {
@@ -330,6 +354,29 @@ public final class IrClass extends
return inlineClassRepresentation_;
}
public static final int SEALED_SUBCLASS_FIELD_NUMBER = 8;
private java.util.List<java.lang.Long> sealedSubclass_;
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public java.util.List<java.lang.Long>
getSealedSubclassList() {
return sealedSubclass_;
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public int getSealedSubclassCount() {
return sealedSubclass_.size();
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public long getSealedSubclass(int index) {
return sealedSubclass_.get(index);
}
private int sealedSubclassMemoizedSerializedSize = -1;
private void initFields() {
base_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclarationBase.getDefaultInstance();
name_ = 0;
@@ -338,6 +385,7 @@ public final class IrClass extends
declaration_ = java.util.Collections.emptyList();
superType_ = java.util.Collections.emptyList();
inlineClassRepresentation_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrInlineClassRepresentation.getDefaultInstance();
sealedSubclass_ = java.util.Collections.emptyList();
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
@@ -413,6 +461,13 @@ public final class IrClass extends
if (((bitField0_ & 0x00000008) == 0x00000008)) {
output.writeMessage(7, inlineClassRepresentation_);
}
if (getSealedSubclassList().size() > 0) {
output.writeRawVarint32(66);
output.writeRawVarint32(sealedSubclassMemoizedSerializedSize);
}
for (int i = 0; i < sealedSubclass_.size(); i++) {
output.writeInt64NoTag(sealedSubclass_.get(i));
}
output.writeRawBytes(unknownFields);
}
@@ -460,6 +515,20 @@ public final class IrClass extends
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(7, inlineClassRepresentation_);
}
{
int dataSize = 0;
for (int i = 0; i < sealedSubclass_.size(); i++) {
dataSize += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt64SizeNoTag(sealedSubclass_.get(i));
}
size += dataSize;
if (!getSealedSubclassList().isEmpty()) {
size += 1;
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt32SizeNoTag(dataSize);
}
sealedSubclassMemoizedSerializedSize = dataSize;
}
size += unknownFields.size();
memoizedSerializedSize = size;
return size;
@@ -568,6 +637,8 @@ public final class IrClass extends
bitField0_ = (bitField0_ & ~0x00000020);
inlineClassRepresentation_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrInlineClassRepresentation.getDefaultInstance();
bitField0_ = (bitField0_ & ~0x00000040);
sealedSubclass_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000080);
return this;
}
@@ -622,6 +693,11 @@ public final class IrClass extends
to_bitField0_ |= 0x00000008;
}
result.inlineClassRepresentation_ = inlineClassRepresentation_;
if (((bitField0_ & 0x00000080) == 0x00000080)) {
sealedSubclass_ = java.util.Collections.unmodifiableList(sealedSubclass_);
bitField0_ = (bitField0_ & ~0x00000080);
}
result.sealedSubclass_ = sealedSubclass_;
result.bitField0_ = to_bitField0_;
return result;
}
@@ -670,6 +746,16 @@ public final class IrClass extends
if (other.hasInlineClassRepresentation()) {
mergeInlineClassRepresentation(other.getInlineClassRepresentation());
}
if (!other.sealedSubclass_.isEmpty()) {
if (sealedSubclass_.isEmpty()) {
sealedSubclass_ = other.sealedSubclass_;
bitField0_ = (bitField0_ & ~0x00000080);
} else {
ensureSealedSubclassIsMutable();
sealedSubclass_.addAll(other.sealedSubclass_);
}
}
setUnknownFields(
getUnknownFields().concat(other.unknownFields));
return this;
@@ -1262,6 +1348,72 @@ public final class IrClass extends
return this;
}
private java.util.List<java.lang.Long> sealedSubclass_ = java.util.Collections.emptyList();
private void ensureSealedSubclassIsMutable() {
if (!((bitField0_ & 0x00000080) == 0x00000080)) {
sealedSubclass_ = new java.util.ArrayList<java.lang.Long>(sealedSubclass_);
bitField0_ |= 0x00000080;
}
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public java.util.List<java.lang.Long>
getSealedSubclassList() {
return java.util.Collections.unmodifiableList(sealedSubclass_);
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public int getSealedSubclassCount() {
return sealedSubclass_.size();
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public long getSealedSubclass(int index) {
return sealedSubclass_.get(index);
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public Builder setSealedSubclass(
int index, long value) {
ensureSealedSubclassIsMutable();
sealedSubclass_.set(index, value);
return this;
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public Builder addSealedSubclass(long value) {
ensureSealedSubclassIsMutable();
sealedSubclass_.add(value);
return this;
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public Builder addAllSealedSubclass(
java.lang.Iterable<? extends java.lang.Long> values) {
ensureSealedSubclassIsMutable();
org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
values, sealedSubclass_);
return this;
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public Builder clearSealedSubclass() {
sealedSubclass_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000080);
return this;
}
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.backend.common.serialization.proto.IrClass)
}
@@ -83,4 +83,17 @@ public interface IrClassOrBuilder extends
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrInlineClassRepresentation inline_class_representation = 7;</code>
*/
org.jetbrains.kotlin.backend.common.serialization.proto.IrInlineClassRepresentation getInlineClassRepresentation();
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
java.util.List<java.lang.Long> getSealedSubclassList();
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
int getSealedSubclassCount();
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
long getSealedSubclass(int index);
}
@@ -137,6 +137,27 @@ public final class PirClassCarrier extends
break;
}
case 72: {
if (!((mutable_bitField0_ & 0x00000100) == 0x00000100)) {
sealedSubclasses_ = new java.util.ArrayList<java.lang.Long>();
mutable_bitField0_ |= 0x00000100;
}
sealedSubclasses_.add(input.readInt64());
break;
}
case 74: {
int length = input.readRawVarint32();
int limit = input.pushLimit(length);
if (!((mutable_bitField0_ & 0x00000100) == 0x00000100) && input.getBytesUntilLimit() > 0) {
sealedSubclasses_ = new java.util.ArrayList<java.lang.Long>();
mutable_bitField0_ |= 0x00000100;
}
while (input.getBytesUntilLimit() > 0) {
sealedSubclasses_.add(input.readInt64());
}
input.popLimit(limit);
break;
}
case 80: {
bitField0_ |= 0x00000020;
flags_ = input.readInt64();
break;
@@ -158,6 +179,9 @@ public final class PirClassCarrier extends
if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) {
superTypes_ = java.util.Collections.unmodifiableList(superTypes_);
}
if (((mutable_bitField0_ & 0x00000100) == 0x00000100)) {
sealedSubclasses_ = java.util.Collections.unmodifiableList(sealedSubclasses_);
}
try {
unknownFieldsCodedOutput.flush();
} catch (java.io.IOException e) {
@@ -338,16 +362,38 @@ public final class PirClassCarrier extends
return inlineClassRepresentation_;
}
public static final int FLAGS_FIELD_NUMBER = 9;
public static final int SEALEDSUBCLASSES_FIELD_NUMBER = 9;
private java.util.List<java.lang.Long> sealedSubclasses_;
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public java.util.List<java.lang.Long>
getSealedSubclassesList() {
return sealedSubclasses_;
}
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public int getSealedSubclassesCount() {
return sealedSubclasses_.size();
}
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public long getSealedSubclasses(int index) {
return sealedSubclasses_.get(index);
}
public static final int FLAGS_FIELD_NUMBER = 10;
private long flags_;
/**
* <code>optional int64 flags = 9 [default = 0];</code>
* <code>optional int64 flags = 10 [default = 0];</code>
*/
public boolean hasFlags() {
return ((bitField0_ & 0x00000020) == 0x00000020);
}
/**
* <code>optional int64 flags = 9 [default = 0];</code>
* <code>optional int64 flags = 10 [default = 0];</code>
*/
public long getFlags() {
return flags_;
@@ -362,6 +408,7 @@ public final class PirClassCarrier extends
typeParameters_ = java.util.Collections.emptyList();
superTypes_ = java.util.Collections.emptyList();
inlineClassRepresentation_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrInlineClassRepresentation.getDefaultInstance();
sealedSubclasses_ = java.util.Collections.emptyList();
flags_ = 0L;
}
private byte memoizedIsInitialized = -1;
@@ -417,8 +464,11 @@ public final class PirClassCarrier extends
if (((bitField0_ & 0x00000010) == 0x00000010)) {
output.writeMessage(8, inlineClassRepresentation_);
}
for (int i = 0; i < sealedSubclasses_.size(); i++) {
output.writeInt64(9, sealedSubclasses_.get(i));
}
if (((bitField0_ & 0x00000020) == 0x00000020)) {
output.writeInt64(9, flags_);
output.writeInt64(10, flags_);
}
output.writeRawBytes(unknownFields);
}
@@ -471,9 +521,18 @@ public final class PirClassCarrier extends
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(8, inlineClassRepresentation_);
}
{
int dataSize = 0;
for (int i = 0; i < sealedSubclasses_.size(); i++) {
dataSize += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt64SizeNoTag(sealedSubclasses_.get(i));
}
size += dataSize;
size += 1 * getSealedSubclassesList().size();
}
if (((bitField0_ & 0x00000020) == 0x00000020)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt64Size(9, flags_);
.computeInt64Size(10, flags_);
}
size += unknownFields.size();
memoizedSerializedSize = size;
@@ -585,8 +644,10 @@ public final class PirClassCarrier extends
bitField0_ = (bitField0_ & ~0x00000040);
inlineClassRepresentation_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrInlineClassRepresentation.getDefaultInstance();
bitField0_ = (bitField0_ & ~0x00000080);
flags_ = 0L;
sealedSubclasses_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000100);
flags_ = 0L;
bitField0_ = (bitField0_ & ~0x00000200);
return this;
}
@@ -645,7 +706,12 @@ public final class PirClassCarrier extends
to_bitField0_ |= 0x00000010;
}
result.inlineClassRepresentation_ = inlineClassRepresentation_;
if (((from_bitField0_ & 0x00000100) == 0x00000100)) {
if (((bitField0_ & 0x00000100) == 0x00000100)) {
sealedSubclasses_ = java.util.Collections.unmodifiableList(sealedSubclasses_);
bitField0_ = (bitField0_ & ~0x00000100);
}
result.sealedSubclasses_ = sealedSubclasses_;
if (((from_bitField0_ & 0x00000200) == 0x00000200)) {
to_bitField0_ |= 0x00000020;
}
result.flags_ = flags_;
@@ -700,6 +766,16 @@ public final class PirClassCarrier extends
if (other.hasInlineClassRepresentation()) {
mergeInlineClassRepresentation(other.getInlineClassRepresentation());
}
if (!other.sealedSubclasses_.isEmpty()) {
if (sealedSubclasses_.isEmpty()) {
sealedSubclasses_ = other.sealedSubclasses_;
bitField0_ = (bitField0_ & ~0x00000100);
} else {
ensureSealedSubclassesIsMutable();
sealedSubclasses_.addAll(other.sealedSubclasses_);
}
}
if (other.hasFlags()) {
setFlags(other.getFlags());
}
@@ -1192,33 +1268,99 @@ public final class PirClassCarrier extends
return this;
}
private long flags_ ;
/**
* <code>optional int64 flags = 9 [default = 0];</code>
*/
public boolean hasFlags() {
return ((bitField0_ & 0x00000100) == 0x00000100);
private java.util.List<java.lang.Long> sealedSubclasses_ = java.util.Collections.emptyList();
private void ensureSealedSubclassesIsMutable() {
if (!((bitField0_ & 0x00000100) == 0x00000100)) {
sealedSubclasses_ = new java.util.ArrayList<java.lang.Long>(sealedSubclasses_);
bitField0_ |= 0x00000100;
}
}
/**
* <code>optional int64 flags = 9 [default = 0];</code>
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public java.util.List<java.lang.Long>
getSealedSubclassesList() {
return java.util.Collections.unmodifiableList(sealedSubclasses_);
}
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public int getSealedSubclassesCount() {
return sealedSubclasses_.size();
}
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public long getSealedSubclasses(int index) {
return sealedSubclasses_.get(index);
}
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public Builder setSealedSubclasses(
int index, long value) {
ensureSealedSubclassesIsMutable();
sealedSubclasses_.set(index, value);
return this;
}
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public Builder addSealedSubclasses(long value) {
ensureSealedSubclassesIsMutable();
sealedSubclasses_.add(value);
return this;
}
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public Builder addAllSealedSubclasses(
java.lang.Iterable<? extends java.lang.Long> values) {
ensureSealedSubclassesIsMutable();
org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
values, sealedSubclasses_);
return this;
}
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public Builder clearSealedSubclasses() {
sealedSubclasses_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000100);
return this;
}
private long flags_ ;
/**
* <code>optional int64 flags = 10 [default = 0];</code>
*/
public boolean hasFlags() {
return ((bitField0_ & 0x00000200) == 0x00000200);
}
/**
* <code>optional int64 flags = 10 [default = 0];</code>
*/
public long getFlags() {
return flags_;
}
/**
* <code>optional int64 flags = 9 [default = 0];</code>
* <code>optional int64 flags = 10 [default = 0];</code>
*/
public Builder setFlags(long value) {
bitField0_ |= 0x00000100;
bitField0_ |= 0x00000200;
flags_ = value;
return this;
}
/**
* <code>optional int64 flags = 9 [default = 0];</code>
* <code>optional int64 flags = 10 [default = 0];</code>
*/
public Builder clearFlags() {
bitField0_ = (bitField0_ & ~0x00000100);
bitField0_ = (bitField0_ & ~0x00000200);
flags_ = 0L;
return this;
@@ -93,11 +93,24 @@ public interface PirClassCarrierOrBuilder extends
org.jetbrains.kotlin.backend.common.serialization.proto.IrInlineClassRepresentation getInlineClassRepresentation();
/**
* <code>optional int64 flags = 9 [default = 0];</code>
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
java.util.List<java.lang.Long> getSealedSubclassesList();
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
int getSealedSubclassesCount();
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
long getSealedSubclasses(int index);
/**
* <code>optional int64 flags = 10 [default = 0];</code>
*/
boolean hasFlags();
/**
* <code>optional int64 flags = 9 [default = 0];</code>
* <code>optional int64 flags = 10 [default = 0];</code>
*/
long getFlags();
}
@@ -0,0 +1,21 @@
// IGNORE_BACKEND: JVM
// !LANGUAGE: +JvmPermittedSubclassesAttributeForSealed
// ENABLE_JVM_PREVIEW
// FILE: javaExhaustiveWhenOnKotlinSealedClass.kt
sealed class KS
class KO : KS()
class KK : KS()
fun box(): String =
J.test(KO()) + J.test(KK())
// FILE: J.java
public class J {
public static String test(KS ks) {
return switch (ks) {
case KO ko -> "O";
case KK kk -> "K";
};
}
}
@@ -0,0 +1,29 @@
// IGNORE_BACKEND: JVM
// WITH_REFLECT
// !LANGUAGE: +JvmPermittedSubclassesAttributeForSealed
sealed class Base
class O : Base()
class K : Base()
sealed interface IBase
class X : IBase
class Y : IBase
fun box(): String {
val cBase = Base::class.java
if (!cBase.isSealed) return "Error: Base is not sealed"
val pBase = cBase.permittedSubclasses.mapTo(HashSet()) { it.simpleName ?: "???" }
if (pBase != setOf("O", "K")) {
return "Failed: $pBase"
}
val cIBase = IBase::class.java
if (!cIBase.isSealed) return "Error: IBase is not sealed"
val pIBase = cIBase.permittedSubclasses.mapTo(HashSet()) { it.simpleName ?: "???" }
if (pIBase != setOf("X", "Y")) {
return "Failed: $pIBase"
}
return "OK"
}
@@ -0,0 +1,26 @@
// IGNORE_BACKEND: JVM
// IGNORE_DEXING
// JVM_TARGET: 17
// !LANGUAGE: +JvmPermittedSubclassesAttributeForSealed
// FILE: Expr.kt
sealed interface Expr
class VarExpr(val name: String) : Expr
class ParensExpr(val arg: Expr) : Expr
// FILE: Literals.kt
class IntExpr(val value: Int) : Expr
class DoubleExpr(val value: Double) : Expr
// FILE: UnaryOperators.kt
sealed class UnaryExpr(val arg: Expr) : Expr
class UnaryPlusExpr(arg: Expr) : UnaryExpr(arg)
class UnaryMinusExpr(arg: Expr) : UnaryExpr(arg)
// FILE: BinaryOperators.kt
sealed class BinaryExpr(val arg1: Expr, val arg2: Expr) : Expr
class BinaryPlusExpr(arg1: Expr, arg2: Expr) : BinaryExpr(arg1, arg2)
class BinaryMinusExpr(arg1: Expr, arg2: Expr) : BinaryExpr(arg1, arg2)
class BinaryMulExpr(arg1: Expr, arg2: Expr) : BinaryExpr(arg1, arg2)
class BinaryDivExpr(arg1: Expr, arg2: Expr) : BinaryExpr(arg1, arg2)
@@ -0,0 +1,104 @@
@kotlin.Metadata
public final class BinaryDivExpr {
// source: 'BinaryOperators.kt'
public method <init>(@org.jetbrains.annotations.NotNull p0: Expr, @org.jetbrains.annotations.NotNull p1: Expr): void
}
@kotlin.Metadata
public abstract class BinaryExpr {
// source: 'BinaryOperators.kt'
private final @org.jetbrains.annotations.NotNull field arg1: Expr
private final @org.jetbrains.annotations.NotNull field arg2: Expr
private method <init>(p0: Expr, p1: Expr): void
public synthetic method <init>(p0: Expr, p1: Expr, p2: kotlin.jvm.internal.DefaultConstructorMarker): void
public final @org.jetbrains.annotations.NotNull method getArg1(): Expr
public final @org.jetbrains.annotations.NotNull method getArg2(): Expr
permittedSubclass: BinaryDivExpr
permittedSubclass: BinaryMinusExpr
permittedSubclass: BinaryMulExpr
permittedSubclass: BinaryPlusExpr
}
@kotlin.Metadata
public final class BinaryMinusExpr {
// source: 'BinaryOperators.kt'
public method <init>(@org.jetbrains.annotations.NotNull p0: Expr, @org.jetbrains.annotations.NotNull p1: Expr): void
}
@kotlin.Metadata
public final class BinaryMulExpr {
// source: 'BinaryOperators.kt'
public method <init>(@org.jetbrains.annotations.NotNull p0: Expr, @org.jetbrains.annotations.NotNull p1: Expr): void
}
@kotlin.Metadata
public final class BinaryPlusExpr {
// source: 'BinaryOperators.kt'
public method <init>(@org.jetbrains.annotations.NotNull p0: Expr, @org.jetbrains.annotations.NotNull p1: Expr): void
}
@kotlin.Metadata
public final class DoubleExpr {
// source: 'Literals.kt'
private final field value: double
public method <init>(p0: double): void
public final method getValue(): double
}
@kotlin.Metadata
public interface Expr {
// source: 'Expr.kt'
permittedSubclass: BinaryExpr
permittedSubclass: DoubleExpr
permittedSubclass: IntExpr
permittedSubclass: ParensExpr
permittedSubclass: UnaryExpr
permittedSubclass: VarExpr
}
@kotlin.Metadata
public final class IntExpr {
// source: 'Literals.kt'
private final field value: int
public method <init>(p0: int): void
public final method getValue(): int
}
@kotlin.Metadata
public final class ParensExpr {
// source: 'Expr.kt'
private final @org.jetbrains.annotations.NotNull field arg: Expr
public method <init>(@org.jetbrains.annotations.NotNull p0: Expr): void
public final @org.jetbrains.annotations.NotNull method getArg(): Expr
}
@kotlin.Metadata
public abstract class UnaryExpr {
// source: 'UnaryOperators.kt'
private final @org.jetbrains.annotations.NotNull field arg: Expr
private method <init>(p0: Expr): void
public synthetic method <init>(p0: Expr, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
public final @org.jetbrains.annotations.NotNull method getArg(): Expr
permittedSubclass: UnaryMinusExpr
permittedSubclass: UnaryPlusExpr
}
@kotlin.Metadata
public final class UnaryMinusExpr {
// source: 'UnaryOperators.kt'
public method <init>(@org.jetbrains.annotations.NotNull p0: Expr): void
}
@kotlin.Metadata
public final class UnaryPlusExpr {
// source: 'UnaryOperators.kt'
public method <init>(@org.jetbrains.annotations.NotNull p0: Expr): void
}
@kotlin.Metadata
public final class VarExpr {
// source: 'Expr.kt'
private final @org.jetbrains.annotations.NotNull field name: java.lang.String
public method <init>(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
public final @org.jetbrains.annotations.NotNull method getName(): java.lang.String
}
+4
View File
@@ -1,5 +1,9 @@
FILE fqName:<root> fileName:/sealedClasses.kt
CLASS CLASS name:Expr modality:SEALED visibility:public superTypes:[kotlin.Any]
sealedSubclasses:
CLASS CLASS name:Const modality:FINAL visibility:public superTypes:[<root>.Expr]
CLASS CLASS name:Sum modality:FINAL visibility:public superTypes:[<root>.Expr]
CLASS OBJECT name:NotANumber modality:FINAL visibility:public superTypes:[<root>.Expr]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Expr
CONSTRUCTOR visibility:protected <> () returnType:<root>.Expr [primary]
BLOCK_BODY
@@ -1,5 +1,7 @@
FILE fqName:<root> fileName:/expectedSealedClass.kt
CLASS CLASS name:Ops modality:SEALED visibility:public [expect] superTypes:[kotlin.Any]
sealedSubclasses:
CLASS CLASS name:Add modality:FINAL visibility:public superTypes:[<root>.Ops]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Ops
CONSTRUCTOR visibility:protected <> () returnType:<root>.Ops [primary,expect]
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
@@ -32,6 +34,8 @@ FILE fqName:<root> fileName:/expectedSealedClass.kt
public open fun toString (): kotlin.String [fake_override] declared in <root>.Ops
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:Ops modality:SEALED visibility:public superTypes:[kotlin.Any]
sealedSubclasses:
CLASS CLASS name:Add modality:FINAL visibility:public superTypes:[<root>.Ops]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Ops
CONSTRUCTOR visibility:protected <> () returnType:<root>.Ops [primary]
BLOCK_BODY
+5
View File
@@ -1,5 +1,9 @@
FILE fqName:<root> fileName:/ArrayMap.kt
CLASS CLASS name:ArrayMap modality:SEALED visibility:public superTypes:[kotlin.collections.Iterable<T of <root>.ArrayMap>]
sealedSubclasses:
CLASS OBJECT name:EmptyArrayMap modality:FINAL visibility:internal superTypes:[<root>.ArrayMap<kotlin.Nothing>]
CLASS CLASS name:OneElementArrayMap modality:FINAL visibility:internal superTypes:[<root>.ArrayMap<T of <root>.OneElementArrayMap>]
CLASS CLASS name:ArrayMapImpl modality:FINAL visibility:internal superTypes:[<root>.ArrayMap<T of <root>.ArrayMapImpl>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.ArrayMap<T of <root>.ArrayMap>
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any]
CONSTRUCTOR visibility:protected <> () returnType:<root>.ArrayMap<T of <root>.ArrayMap> [primary]
@@ -859,3 +863,4 @@ FILE fqName:<root> fileName:/ArrayMap.kt
overridden:
public open fun toString (): kotlin.String [fake_override] declared in <root>.ArrayMap
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
+2
View File
@@ -1,5 +1,7 @@
FILE fqName:<root> fileName:/kt45236.kt
CLASS CLASS name:NetRequestStatus modality:SEALED visibility:public superTypes:[kotlin.Any]
sealedSubclasses:
CLASS CLASS name:Error modality:FINAL visibility:public [data] superTypes:[<root>.NetRequestStatus<T of <root>.NetRequestStatus.Error>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.NetRequestStatus<T of <root>.NetRequestStatus>
TYPE_PARAMETER name:T index:0 variance:out superTypes:[kotlin.Any]
CONSTRUCTOR visibility:protected <> () returnType:<root>.NetRequestStatus<T of <root>.NetRequestStatus> [primary]
@@ -228,6 +228,12 @@ public class BlackBoxModernJdkCodegenTestGenerated extends AbstractBlackBoxCodeg
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/sealed/compiledJavaSealedInterface.kt");
}
@Test
@TestMetadata("javaExhaustiveWhenOnKotlinSealedClass.kt")
public void testJavaExhaustiveWhenOnKotlinSealedClass() throws Exception {
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/sealed/javaExhaustiveWhenOnKotlinSealedClass.kt");
}
@Test
@TestMetadata("javaRecordsViaKotlinReflection.kt")
public void testJavaRecordsViaKotlinReflection() throws Exception {
@@ -246,6 +252,12 @@ public class BlackBoxModernJdkCodegenTestGenerated extends AbstractBlackBoxCodeg
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/sealed/javaSealedInterface.kt");
}
@Test
@TestMetadata("permittedSubclassesOfSealedKotlinClass.kt")
public void testPermittedSubclassesOfSealedKotlinClass() throws Exception {
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/sealed/permittedSubclassesOfSealedKotlinClass.kt");
}
@Test
@TestMetadata("sealedJavaClassViaJavaReflection.kt")
public void testSealedJavaClassViaJavaReflection() throws Exception {
@@ -2142,6 +2142,12 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
runTest("compiler/testData/codegen/bytecodeListing/sealed/annotationsOnSealedConstructor.kt");
}
@Test
@TestMetadata("permittedSubclasses_1_7.kt")
public void testPermittedSubclasses_1_7() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/sealed/permittedSubclasses_1_7.kt");
}
@Test
@TestMetadata("sealedClassConstructor_1_4.kt")
public void testSealedClassConstructor_1_4() throws Exception {
@@ -246,6 +246,12 @@ public class IrBlackBoxModernJdkCodegenTestGenerated extends AbstractIrBlackBoxC
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/sealed/compiledJavaSealedInterface.kt");
}
@Test
@TestMetadata("javaExhaustiveWhenOnKotlinSealedClass.kt")
public void testJavaExhaustiveWhenOnKotlinSealedClass() throws Exception {
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/sealed/javaExhaustiveWhenOnKotlinSealedClass.kt");
}
@Test
@TestMetadata("javaRecordsViaKotlinReflection.kt")
public void testJavaRecordsViaKotlinReflection() throws Exception {
@@ -264,6 +270,12 @@ public class IrBlackBoxModernJdkCodegenTestGenerated extends AbstractIrBlackBoxC
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/sealed/javaSealedInterface.kt");
}
@Test
@TestMetadata("permittedSubclassesOfSealedKotlinClass.kt")
public void testPermittedSubclassesOfSealedKotlinClass() throws Exception {
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/sealed/permittedSubclassesOfSealedKotlinClass.kt");
}
@Test
@TestMetadata("sealedJavaClassViaJavaReflection.kt")
public void testSealedJavaClassViaJavaReflection() throws Exception {
@@ -2190,6 +2190,12 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
runTest("compiler/testData/codegen/bytecodeListing/sealed/annotationsOnSealedConstructor.kt");
}
@Test
@TestMetadata("permittedSubclasses_1_7.kt")
public void testPermittedSubclasses_1_7() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/sealed/permittedSubclasses_1_7.kt");
}
@Test
@TestMetadata("sealedClassConstructor_1_4.kt")
public void testSealedClassConstructor_1_4() throws Exception {
@@ -165,6 +165,12 @@ class BytecodeListingTextCollectingVisitor(
}
}
override fun visitPermittedSubclass(permittedSubclass: String?) {
if (permittedSubclass != null) {
declarationsInsideClass.add(Declaration("permittedSubclass: $permittedSubclass"))
}
}
override fun visitMethod(access: Int, name: String, desc: String, signature: String?, exceptions: Array<out String>?): MethodVisitor? {
if (!filter.shouldWriteMethod(access, name, desc)) {
return null
@@ -233,6 +233,7 @@ enum class LanguageFeature(
StopPropagatingDeprecationThroughOverrides(KOTLIN_1_7),
AbstractClassMemberNotImplementedWithIntermediateAbstractClass(KOTLIN_1_7, kind = BUG_FIX),
RefineTypeCheckingOnAssignmentsToJavaFields(KOTLIN_1_7),
JvmPermittedSubclassesAttributeForSealed(KOTLIN_1_7),
// Temporarily disabled, see KT-27084/KT-22379
SoundSmartcastFromLoopConditionForLoopAssignedVariables(sinceVersion = null, kind = BUG_FIX),