JVM JVM_IR hide sealed class constructors

This commit is contained in:
Dmitry Petrov
2021-01-22 15:31:56 +03:00
parent ca3bb02897
commit 708e6914bd
27 changed files with 555 additions and 97 deletions
@@ -19,7 +19,6 @@ import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
import org.jetbrains.kotlin.resolve.InlineClassesUtilsKt;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.jvm.InlineClassManglingRulesKt;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind;
@@ -118,8 +117,9 @@ public class ConstructorCodegen {
}
private void registerAccessorForHiddenConstructorIfNeeded(ClassConstructorDescriptor descriptor) {
if (!InlineClassManglingRulesKt.shouldHideConstructorDueToInlineClassTypeValueParameters(descriptor)) return;
context.getAccessor(descriptor, AccessorKind.NORMAL, null, null);
if (DescriptorAsmUtil.isHiddenConstructor(descriptor)) {
context.getAccessor(descriptor, AccessorKind.NORMAL, null, null);
}
}
public void generateSecondaryConstructor(
@@ -371,11 +371,13 @@ public class ConstructorCodegen {
JvmMethodParameterKind delegatingKind = delegatingParameters.get(index).getKind();
if (delegatingKind == JvmMethodParameterKind.VALUE) {
assert index == parameters.size() || parameters.get(index).getKind() == JvmMethodParameterKind.VALUE:
"Delegating constructor has not enough implicit parameters";
"Delegating constructor has not enough implicit parameters: " + delegatingConstructor;
break;
}
assert index < parameters.size() && parameters.get(index).getKind() == delegatingKind :
"Constructors of the same class should have the same set of implicit arguments";
if (index >= parameters.size() || parameters.get(index).getKind() != delegatingKind) {
throw new AssertionError(
"Constructors of the same class should have the same set of implicit arguments: " + delegatingConstructor);
}
JvmMethodParameterSignature parameter = parameters.get(index);
iv.load(offset, parameter.getAsmType());
@@ -383,7 +385,7 @@ public class ConstructorCodegen {
}
assert index == parameters.size() || parameters.get(index).getKind() == JvmMethodParameterKind.VALUE :
"Delegating constructor has not enough parameters";
"Delegating constructor has not enough parameters: " + delegatingConstructor;
return new CallBasedArgumentGenerator(codegen, codegen.defaultCallGenerator, delegatingConstructor.getValueParameters(),
delegatingCallable.getValueParameterTypes());
@@ -61,7 +61,8 @@ import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvmInterface;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isInlineOnlyPrivateInBytecode;
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isInlineWithReified;
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.*;
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.JAVA_STRING_TYPE;
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE;
import static org.jetbrains.kotlin.resolve.jvm.annotations.JvmAnnotationUtilKt.hasJvmSyntheticAnnotation;
import static org.jetbrains.kotlin.types.TypeUtils.isNullableType;
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
@@ -368,6 +369,18 @@ public class DescriptorAsmUtil {
return ACC_PRIVATE;
}
// Sealed class constructors should be ACC_PRIVATE.
// In 1.4 and before, sealed class constructors had PRIVATE visibility, and were represented as private methods in bytecode.
// In 1.5 (+AllowSealedInheritorsInDifferentFilesOfSamePackage), sealed class constructors became INTERNAL,
// but still should be represented as private methods in bytecode in order to prevent inheriting from sealed classes on JVM.
if (memberDescriptor instanceof ConstructorDescriptor &&
!(memberDescriptor instanceof AccessorForConstructorDescriptor) &&
isSealedClass(((ConstructorDescriptor) memberDescriptor).getConstructedClass()) &&
memberDescriptor.getVisibility() != DescriptorVisibilities.PUBLIC
) {
return ACC_PRIVATE;
}
if (isInlineOnlyPrivateInBytecode(memberDescriptor)) {
return ACC_PRIVATE;
}
@@ -893,4 +906,19 @@ public class DescriptorAsmUtil {
//Trait always should have this descriptor
return kind != OwnerKind.DEFAULT_IMPLS && isStaticMethod(kind, descriptor) ? 0 : 1;
}
public static boolean isHiddenConstructor(FunctionDescriptor descriptor) {
if (!(descriptor instanceof ClassConstructorDescriptor)) return false;
ClassConstructorDescriptor classConstructorDescriptor = (ClassConstructorDescriptor) descriptor;
if (InlineClassManglingRulesKt.shouldHideConstructorDueToInlineClassTypeValueParameters(descriptor)) {
return true;
}
if (isSealedClass(classConstructorDescriptor.getConstructedClass()) &&
classConstructorDescriptor.getVisibility() != DescriptorVisibilities.PUBLIC
) {
return true;
}
return false;
}
}
@@ -2523,21 +2523,39 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
// $default method is not private, so you need no accessor to call it
return descriptor;
}
else if (InlineClassManglingRulesKt.shouldHideConstructorDueToInlineClassTypeValueParameters(descriptor.getOriginal())) {
// Constructors with inline class type value parameters should always be called using an accessor.
// NB this will require accessors even if the constructor itself is in a different module.
return new AccessorForConstructorDescriptor(
(ClassConstructorDescriptor) descriptor.getOriginal(),
descriptor.getContainingDeclaration(),
getSuperCallTarget(resolvedCall.getCall()),
AccessorKind.NORMAL
);
else if (shouldForceAccessorForConstructor(descriptor.getOriginal())) {
return createAccessorForHiddenConstructor(resolvedCall, descriptor);
}
else {
return context.accessibleDescriptor(descriptor, getSuperCallTarget(resolvedCall.getCall()));
}
}
private boolean shouldForceAccessorForConstructor(FunctionDescriptor descriptor) {
// Force using accessors on hidden constructors only
if (!isHiddenConstructor(descriptor)) {
return false;
}
// Don't use accessor when calling hidden constructor from the same class.
if (descriptor.getContainingDeclaration() == context.getContextDescriptor().getContainingDeclaration()) {
return false;
}
return true;
}
@NotNull
private AccessorForConstructorDescriptor createAccessorForHiddenConstructor(
@NotNull ResolvedCall<?> resolvedCall,
FunctionDescriptor descriptor
) {
return new AccessorForConstructorDescriptor(
(ClassConstructorDescriptor) descriptor.getOriginal(),
descriptor.getContainingDeclaration(),
getSuperCallTarget(resolvedCall.getCall()),
AccessorKind.NORMAL
);
}
@NotNull
public StackValue invokeFunction(@NotNull ResolvedCall<?> resolvedCall, @NotNull StackValue receiver) {
return invokeFunction(resolvedCall.getCall(), resolvedCall, receiver);
@@ -4906,12 +4906,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/classes/rightHandOverride.kt");
}
@Test
@TestMetadata("sealedInSameFile.kt")
public void testSealedInSameFile() throws Exception {
runTest("compiler/testData/codegen/box/classes/sealedInSameFile.kt");
}
@Test
@TestMetadata("selfcreate.kt")
public void testSelfcreate() throws Exception {
@@ -34494,6 +34488,18 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/sealed"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("constructorAnnotations.kt")
public void testConstructorAnnotations() throws Exception {
runTest("compiler/testData/codegen/box/sealed/constructorAnnotations.kt");
}
@Test
@TestMetadata("delegatingConstructor.kt")
public void testDelegatingConstructor() throws Exception {
runTest("compiler/testData/codegen/box/sealed/delegatingConstructor.kt");
}
@Test
@TestMetadata("multipleFiles_enabled.kt")
public void testMultipleFiles_enabled() throws Exception {
@@ -34506,6 +34512,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/sealed/objects.kt");
}
@Test
@TestMetadata("sealedInSameFile.kt")
public void testSealedInSameFile() throws Exception {
runTest("compiler/testData/codegen/box/sealed/sealedInSameFile.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
@@ -210,28 +210,46 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle
}
private val IrConstructor.isOrShouldBeHidden: Boolean
get() = this in context.hiddenConstructors || (
!DescriptorVisibilities.isPrivate(visibility) && !constructedClass.isInline && hasMangledParameters &&
origin != IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER &&
origin != JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR &&
origin != JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR_FOR_HIDDEN_CONSTRUCTOR)
get() {
if (this in context.hiddenConstructors)
return true
if (origin == IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER ||
origin == JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR ||
origin == JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR_FOR_HIDDEN_CONSTRUCTOR
) {
return false
}
val constructedClass = constructedClass
if (!DescriptorVisibilities.isPrivate(visibility) && !constructedClass.isInline && hasMangledParameters)
return true
if (visibility != DescriptorVisibilities.PUBLIC && constructedClass.modality == Modality.SEALED)
return true
return false
}
private fun handleHiddenConstructor(declaration: IrConstructor): IrConstructor {
require(declaration.isOrShouldBeHidden, declaration::render)
return context.hiddenConstructors.getOrPut(declaration) {
declaration.makeConstructorAccessor(JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR_FOR_HIDDEN_CONSTRUCTOR).also { accessor ->
// There's a special case in the JVM backend for serializing the metadata of hidden
// constructors - we serialize the descriptor of the original constructor, but the
// signature of the accessor. We implement this special case in the JVM IR backend by
// attaching the metadata directly to the accessor. We also have to move all annotations
// to the accessor. Parameter annotations are already moved by the copyTo method.
if (declaration.metadata != null) {
accessor.metadata = declaration.metadata
declaration.metadata = null
if (declaration.constructedClass.modality != Modality.SEALED) {
// There's a special case in the JVM backend for serializing the metadata of hidden
// constructors - we serialize the descriptor of the original constructor, but the
// signature of the accessor. We implement this special case in the JVM IR backend by
// attaching the metadata directly to the accessor. We also have to move all annotations
// to the accessor. Parameter annotations are already moved by the copyTo method.
if (declaration.metadata != null) {
accessor.metadata = declaration.metadata
declaration.metadata = null
}
accessor.annotations += declaration.annotations
declaration.annotations = emptyList()
declaration.valueParameters.forEach { it.annotations = emptyList() }
}
accessor.annotations += declaration.annotations
declaration.annotations = emptyList()
declaration.valueParameters.forEach { it.annotations = emptyList() }
}
}
}
@@ -263,6 +281,12 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle
accessor.copyTypeParametersFrom(source, JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR)
accessor.copyValueParametersToStatic(source, JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR)
if (source.constructedClass.modality == Modality.SEALED) {
for (accessorValueParameter in accessor.valueParameters) {
accessorValueParameter.annotations = emptyList()
}
}
accessor.returnType = source.returnType.remapTypeParameters(source, accessor)
accessor.addValueParameter(
@@ -0,0 +1,24 @@
// TARGET_BACKEND: JVM
// WITH_REFLECT
annotation class Ann
sealed class Test @Ann constructor(@Ann val x: String)
fun box(): String {
val testCtor = Test::class.constructors.single()
val testCtorAnnClasses = testCtor.annotations.map { it.annotationClass }
if (testCtorAnnClasses != listOf(Ann::class)) {
throw AssertionError("Annotations on constructor: $testCtorAnnClasses")
}
for (param in testCtor.parameters) {
val paramAnnClasses = param.annotations.map { it.annotationClass }
if (paramAnnClasses != listOf(Ann::class)) {
throw AssertionError("Annotations on constructor parameter $param: $paramAnnClasses")
}
}
return "OK"
}
@@ -0,0 +1,7 @@
sealed class Sealed(val value: String) {
constructor() : this("OK")
}
class Derived : Sealed()
fun box() = Derived().value
@@ -0,0 +1,13 @@
inline class Z(val x: Int)
class Test1(val z: Z)
class Test2(val x: String) {
constructor(z: Z) : this(z.toString())
}
class Test3(val z: Z = Z(0))
class Test4(val x: String) {
constructor(z: Z = Z(0)) : this(z.toString())
}
@@ -0,0 +1,58 @@
@kotlin.Metadata
public final class Test1 {
// source: 'hiddenConstructor.kt'
private final field z: int
private method <init>(p0: int): void
public synthetic method <init>(p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
public final method getZ-a_XrcN0(): int
}
@kotlin.Metadata
public final class Test2 {
// source: 'hiddenConstructor.kt'
private final @org.jetbrains.annotations.NotNull field x: java.lang.String
public method <init>(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
private method <init>(p0: int): void
public synthetic method <init>(p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
public final @org.jetbrains.annotations.NotNull method getX(): java.lang.String
}
@kotlin.Metadata
public final class Test3 {
// source: 'hiddenConstructor.kt'
private final field z: int
private method <init>(p0: int): void
public synthetic method <init>(p0: int, p1: int, p2: kotlin.jvm.internal.DefaultConstructorMarker): void
public synthetic method <init>(p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
public final method getZ-a_XrcN0(): int
}
@kotlin.Metadata
public final class Test4 {
// source: 'hiddenConstructor.kt'
private final @org.jetbrains.annotations.NotNull field x: java.lang.String
public method <init>(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
private method <init>(p0: int): void
public synthetic method <init>(p0: int, p1: int, p2: kotlin.jvm.internal.DefaultConstructorMarker): void
public synthetic method <init>(p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
public final @org.jetbrains.annotations.NotNull method getX(): java.lang.String
}
@kotlin.jvm.JvmInline
@kotlin.Metadata
public final class Z {
// source: 'hiddenConstructor.kt'
private final field x: int
private synthetic method <init>(p0: int): void
public synthetic final static method box-impl(p0: int): Z
public static method constructor-impl(p0: int): int
public method equals(p0: java.lang.Object): boolean
public static method equals-impl(p0: int, p1: java.lang.Object): boolean
public final static method equals-impl0(p0: int, p1: int): boolean
public final method getX(): int
public method hashCode(): int
public static method hashCode-impl(p0: int): int
public method toString(): java.lang.String
public static method toString-impl(p0: int): java.lang.String
public synthetic final method unbox-impl(): int
}
@@ -0,0 +1,3 @@
annotation class Ann
sealed class Sealed @Ann constructor(@Ann val x: String)
@@ -0,0 +1,14 @@
@java.lang.annotation.Retention
@kotlin.Metadata
public annotation class Ann {
// source: 'annotationsOnSealedConstructor.kt'
}
@kotlin.Metadata
public abstract class Sealed {
// source: 'annotationsOnSealedConstructor.kt'
private final @org.jetbrains.annotations.NotNull field x: java.lang.String
private @Ann method <init>(@Ann p0: java.lang.String): void
public synthetic method <init>(p0: java.lang.String, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
public final @org.jetbrains.annotations.NotNull method getX(): java.lang.String
}
@@ -0,0 +1,14 @@
// !LANGUAGE: -AllowSealedInheritorsInDifferentFilesOfSamePackage
sealed class TestNoSubclasses(val x: Int)
sealed class TestSubclassAfter(val x: Int)
class X1 : TestSubclassAfter(42)
sealed class TestNoSubclassesAllDefaults(val x: Int = 0)
sealed class TestSubclassAfterAllDefaults(val x: Int = 0)
class X3 : TestSubclassAfterAllDefaults()
class X4: TestSubclassBefore(1)
sealed class TestSubclassBefore(val x: Int)
@@ -0,0 +1,64 @@
@kotlin.Metadata
public abstract class TestNoSubclasses {
// source: 'sealedClassConstructor_1_4.kt'
private final field x: int
private method <init>(p0: int): void
public synthetic method <init>(p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
public final method getX(): int
}
@kotlin.Metadata
public abstract class TestNoSubclassesAllDefaults {
// source: 'sealedClassConstructor_1_4.kt'
private final field x: int
private method <init>(p0: int): void
synthetic method <init>(p0: int, p1: int, p2: kotlin.jvm.internal.DefaultConstructorMarker): void
public synthetic method <init>(p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
public final method getX(): int
}
@kotlin.Metadata
public abstract class TestSubclassAfter {
// source: 'sealedClassConstructor_1_4.kt'
private final field x: int
private method <init>(p0: int): void
public synthetic method <init>(p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
public final method getX(): int
}
@kotlin.Metadata
public abstract class TestSubclassAfterAllDefaults {
// source: 'sealedClassConstructor_1_4.kt'
private final field x: int
private method <init>(p0: int): void
synthetic method <init>(p0: int, p1: int, p2: kotlin.jvm.internal.DefaultConstructorMarker): void
public synthetic method <init>(p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
public final method getX(): int
}
@kotlin.Metadata
public abstract class TestSubclassBefore {
// source: 'sealedClassConstructor_1_4.kt'
private final field x: int
private method <init>(p0: int): void
public synthetic method <init>(p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
public final method getX(): int
}
@kotlin.Metadata
public final class X1 {
// source: 'sealedClassConstructor_1_4.kt'
public method <init>(): void
}
@kotlin.Metadata
public final class X3 {
// source: 'sealedClassConstructor_1_4.kt'
public method <init>(): void
}
@kotlin.Metadata
public final class X4 {
// source: 'sealedClassConstructor_1_4.kt'
public method <init>(): void
}
@@ -0,0 +1,14 @@
// !LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage
sealed class TestNoSubclasses(val x: Int)
sealed class TestSubclassAfter(val x: Int)
class X1 : TestSubclassAfter(42)
sealed class TestNoSubclassesAllDefaults(val x: Int = 0)
sealed class TestSubclassAfterAllDefaults(val x: Int = 0)
class X3 : TestSubclassAfterAllDefaults()
class X4: TestSubclassBefore(1)
sealed class TestSubclassBefore(val x: Int)
@@ -0,0 +1,64 @@
@kotlin.Metadata
public abstract class TestNoSubclasses {
// source: 'sealedClassConstructor_1_5.kt'
private final field x: int
private method <init>(p0: int): void
public synthetic method <init>(p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
public final method getX(): int
}
@kotlin.Metadata
public abstract class TestNoSubclassesAllDefaults {
// source: 'sealedClassConstructor_1_5.kt'
private final field x: int
private method <init>(p0: int): void
public synthetic method <init>(p0: int, p1: int, p2: kotlin.jvm.internal.DefaultConstructorMarker): void
public synthetic method <init>(p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
public final method getX(): int
}
@kotlin.Metadata
public abstract class TestSubclassAfter {
// source: 'sealedClassConstructor_1_5.kt'
private final field x: int
private method <init>(p0: int): void
public synthetic method <init>(p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
public final method getX(): int
}
@kotlin.Metadata
public abstract class TestSubclassAfterAllDefaults {
// source: 'sealedClassConstructor_1_5.kt'
private final field x: int
private method <init>(p0: int): void
public synthetic method <init>(p0: int, p1: int, p2: kotlin.jvm.internal.DefaultConstructorMarker): void
public synthetic method <init>(p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
public final method getX(): int
}
@kotlin.Metadata
public abstract class TestSubclassBefore {
// source: 'sealedClassConstructor_1_5.kt'
private final field x: int
private method <init>(p0: int): void
public synthetic method <init>(p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
public final method getX(): int
}
@kotlin.Metadata
public final class X1 {
// source: 'sealedClassConstructor_1_5.kt'
public method <init>(): void
}
@kotlin.Metadata
public final class X3 {
// source: 'sealedClassConstructor_1_5.kt'
public method <init>(): void
}
@kotlin.Metadata
public final class X4 {
// source: 'sealedClassConstructor_1_5.kt'
public method <init>(): void
}
@@ -1,3 +0,0 @@
// !LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage
sealed class Test(val x: Int = 0)
@@ -1,8 +0,0 @@
@kotlin.Metadata
public abstract class Test {
// source: 'sealedClassConstructorWithDefaultParams.kt'
private final field x: int
public method <init>(p0: int): void
public synthetic method <init>(p0: int, p1: int, p2: kotlin.jvm.internal.DefaultConstructorMarker): void
public final method getX(): int
}
@@ -4906,12 +4906,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/classes/rightHandOverride.kt");
}
@Test
@TestMetadata("sealedInSameFile.kt")
public void testSealedInSameFile() throws Exception {
runTest("compiler/testData/codegen/box/classes/sealedInSameFile.kt");
}
@Test
@TestMetadata("selfcreate.kt")
public void testSelfcreate() throws Exception {
@@ -34694,6 +34688,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/sealed"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@Test
@TestMetadata("constructorAnnotations.kt")
public void testConstructorAnnotations() throws Exception {
runTest("compiler/testData/codegen/box/sealed/constructorAnnotations.kt");
}
@Test
@TestMetadata("delegatingConstructor.kt")
public void testDelegatingConstructor() throws Exception {
runTest("compiler/testData/codegen/box/sealed/delegatingConstructor.kt");
}
@Test
@TestMetadata("multipleFiles_enabled.kt")
public void testMultipleFiles_enabled() throws Exception {
@@ -34706,6 +34712,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/sealed/objects.kt");
}
@Test
@TestMetadata("sealedInSameFile.kt")
public void testSealedInSameFile() throws Exception {
runTest("compiler/testData/codegen/box/sealed/sealedInSameFile.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
@@ -4906,12 +4906,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/classes/rightHandOverride.kt");
}
@Test
@TestMetadata("sealedInSameFile.kt")
public void testSealedInSameFile() throws Exception {
runTest("compiler/testData/codegen/box/classes/sealedInSameFile.kt");
}
@Test
@TestMetadata("selfcreate.kt")
public void testSelfcreate() throws Exception {
@@ -34494,6 +34488,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/sealed"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("constructorAnnotations.kt")
public void testConstructorAnnotations() throws Exception {
runTest("compiler/testData/codegen/box/sealed/constructorAnnotations.kt");
}
@Test
@TestMetadata("delegatingConstructor.kt")
public void testDelegatingConstructor() throws Exception {
runTest("compiler/testData/codegen/box/sealed/delegatingConstructor.kt");
}
@Test
@TestMetadata("multipleFiles_enabled.kt")
public void testMultipleFiles_enabled() throws Exception {
@@ -34506,6 +34512,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/sealed/objects.kt");
}
@Test
@TestMetadata("sealedInSameFile.kt")
public void testSealedInSameFile() throws Exception {
runTest("compiler/testData/codegen/box/sealed/sealedInSameFile.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
@@ -235,11 +235,6 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
runTest("compiler/testData/codegen/bytecodeListing/rawTypeInSignature.kt");
}
@TestMetadata("sealedClassConstructorWithDefaultParams.kt")
public void testSealedClassConstructorWithDefaultParams() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/sealedClassConstructorWithDefaultParams.kt");
}
@TestMetadata("strictfpFlag.kt")
public void testStrictfpFlag() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/strictfpFlag.kt");
@@ -1057,6 +1052,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/genericChild.kt");
}
@TestMetadata("hiddenConstructor.kt")
public void testHiddenConstructor() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/hiddenConstructor.kt");
}
@TestMetadata("inlineCharSequence.kt")
public void testInlineCharSequence() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCharSequence.kt");
@@ -1639,6 +1639,34 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
}
}
@TestMetadata("compiler/testData/codegen/bytecodeListing/sealed")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Sealed extends AbstractBytecodeListingTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInSealed() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/sealed"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("annotationsOnSealedConstructor.kt")
public void testAnnotationsOnSealedConstructor() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/sealed/annotationsOnSealedConstructor.kt");
}
@TestMetadata("sealedClassConstructor_1_4.kt")
public void testSealedClassConstructor_1_4() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/sealed/sealedClassConstructor_1_4.kt");
}
@TestMetadata("sealedClassConstructor_1_5.kt")
public void testSealedClassConstructor_1_5() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/sealed/sealedClassConstructor_1_5.kt");
}
}
@TestMetadata("compiler/testData/codegen/bytecodeListing/specialBridges")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -4284,11 +4284,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/classes/rightHandOverride.kt");
}
@TestMetadata("sealedInSameFile.kt")
public void testSealedInSameFile() throws Exception {
runTest("compiler/testData/codegen/box/classes/sealedInSameFile.kt");
}
@TestMetadata("selfcreate.kt")
public void testSelfcreate() throws Exception {
runTest("compiler/testData/codegen/box/classes/selfcreate.kt");
@@ -28314,6 +28309,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/sealed"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("constructorAnnotations.kt")
public void testConstructorAnnotations() throws Exception {
runTest("compiler/testData/codegen/box/sealed/constructorAnnotations.kt");
}
@TestMetadata("delegatingConstructor.kt")
public void testDelegatingConstructor() throws Exception {
runTest("compiler/testData/codegen/box/sealed/delegatingConstructor.kt");
}
@TestMetadata("multipleFiles_enabled.kt")
public void testMultipleFiles_enabled() throws Exception {
runTest("compiler/testData/codegen/box/sealed/multipleFiles_enabled.kt");
@@ -28324,6 +28329,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/sealed/objects.kt");
}
@TestMetadata("sealedInSameFile.kt")
public void testSealedInSameFile() throws Exception {
runTest("compiler/testData/codegen/box/sealed/sealedInSameFile.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/codegen/box/sealed/simple.kt");
@@ -235,11 +235,6 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
runTest("compiler/testData/codegen/bytecodeListing/rawTypeInSignature.kt");
}
@TestMetadata("sealedClassConstructorWithDefaultParams.kt")
public void testSealedClassConstructorWithDefaultParams() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/sealedClassConstructorWithDefaultParams.kt");
}
@TestMetadata("strictfpFlag.kt")
public void testStrictfpFlag() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/strictfpFlag.kt");
@@ -1057,6 +1052,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/genericChild.kt");
}
@TestMetadata("hiddenConstructor.kt")
public void testHiddenConstructor() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/hiddenConstructor.kt");
}
@TestMetadata("inlineCharSequence.kt")
public void testInlineCharSequence() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCharSequence.kt");
@@ -1639,6 +1639,34 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
}
}
@TestMetadata("compiler/testData/codegen/bytecodeListing/sealed")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Sealed extends AbstractIrBytecodeListingTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInSealed() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/sealed"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@TestMetadata("annotationsOnSealedConstructor.kt")
public void testAnnotationsOnSealedConstructor() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/sealed/annotationsOnSealedConstructor.kt");
}
@TestMetadata("sealedClassConstructor_1_4.kt")
public void testSealedClassConstructor_1_4() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/sealed/sealedClassConstructor_1_4.kt");
}
@TestMetadata("sealedClassConstructor_1_5.kt")
public void testSealedClassConstructor_1_5() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/sealed/sealedClassConstructor_1_5.kt");
}
}
@TestMetadata("compiler/testData/codegen/bytecodeListing/specialBridges")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -3414,11 +3414,6 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/classes/rightHandOverride.kt");
}
@TestMetadata("sealedInSameFile.kt")
public void testSealedInSameFile() throws Exception {
runTest("compiler/testData/codegen/box/classes/sealedInSameFile.kt");
}
@TestMetadata("selfcreate.kt")
public void testSelfcreate() throws Exception {
runTest("compiler/testData/codegen/box/classes/selfcreate.kt");
@@ -24565,6 +24560,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/sealed"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
}
@TestMetadata("delegatingConstructor.kt")
public void testDelegatingConstructor() throws Exception {
runTest("compiler/testData/codegen/box/sealed/delegatingConstructor.kt");
}
@TestMetadata("multipleFiles_enabled.kt")
public void testMultipleFiles_enabled() throws Exception {
runTest("compiler/testData/codegen/box/sealed/multipleFiles_enabled.kt");
@@ -24575,6 +24575,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/sealed/objects.kt");
}
@TestMetadata("sealedInSameFile.kt")
public void testSealedInSameFile() throws Exception {
runTest("compiler/testData/codegen/box/sealed/sealedInSameFile.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/codegen/box/sealed/simple.kt");
@@ -3414,11 +3414,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/classes/rightHandOverride.kt");
}
@TestMetadata("sealedInSameFile.kt")
public void testSealedInSameFile() throws Exception {
runTest("compiler/testData/codegen/box/classes/sealedInSameFile.kt");
}
@TestMetadata("selfcreate.kt")
public void testSelfcreate() throws Exception {
runTest("compiler/testData/codegen/box/classes/selfcreate.kt");
@@ -24565,6 +24560,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/sealed"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
@TestMetadata("delegatingConstructor.kt")
public void testDelegatingConstructor() throws Exception {
runTest("compiler/testData/codegen/box/sealed/delegatingConstructor.kt");
}
@TestMetadata("multipleFiles_enabled.kt")
public void testMultipleFiles_enabled() throws Exception {
runTest("compiler/testData/codegen/box/sealed/multipleFiles_enabled.kt");
@@ -24575,6 +24575,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/sealed/objects.kt");
}
@TestMetadata("sealedInSameFile.kt")
public void testSealedInSameFile() throws Exception {
runTest("compiler/testData/codegen/box/sealed/sealedInSameFile.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/codegen/box/sealed/simple.kt");
@@ -3414,11 +3414,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/classes/rightHandOverride.kt");
}
@TestMetadata("sealedInSameFile.kt")
public void testSealedInSameFile() throws Exception {
runTest("compiler/testData/codegen/box/classes/sealedInSameFile.kt");
}
@TestMetadata("selfcreate.kt")
public void testSelfcreate() throws Exception {
runTest("compiler/testData/codegen/box/classes/selfcreate.kt");
@@ -24530,6 +24525,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/sealed"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
}
@TestMetadata("delegatingConstructor.kt")
public void testDelegatingConstructor() throws Exception {
runTest("compiler/testData/codegen/box/sealed/delegatingConstructor.kt");
}
@TestMetadata("multipleFiles_enabled.kt")
public void testMultipleFiles_enabled() throws Exception {
runTest("compiler/testData/codegen/box/sealed/multipleFiles_enabled.kt");
@@ -24540,6 +24540,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/sealed/objects.kt");
}
@TestMetadata("sealedInSameFile.kt")
public void testSealedInSameFile() throws Exception {
runTest("compiler/testData/codegen/box/sealed/sealedInSameFile.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/codegen/box/sealed/simple.kt");
@@ -2315,11 +2315,6 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/classes/rightHandOverride.kt");
}
@TestMetadata("sealedInSameFile.kt")
public void testSealedInSameFile() throws Exception {
runTest("compiler/testData/codegen/box/classes/sealedInSameFile.kt");
}
@TestMetadata("selfcreate.kt")
public void testSelfcreate() throws Exception {
runTest("compiler/testData/codegen/box/classes/selfcreate.kt");
@@ -13064,6 +13059,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/sealed"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
@TestMetadata("delegatingConstructor.kt")
public void testDelegatingConstructor() throws Exception {
runTest("compiler/testData/codegen/box/sealed/delegatingConstructor.kt");
}
@TestMetadata("multipleFiles_enabled.kt")
public void testMultipleFiles_enabled() throws Exception {
runTest("compiler/testData/codegen/box/sealed/multipleFiles_enabled.kt");
@@ -13074,6 +13074,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/sealed/objects.kt");
}
@TestMetadata("sealedInSameFile.kt")
public void testSealedInSameFile() throws Exception {
runTest("compiler/testData/codegen/box/sealed/sealedInSameFile.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/codegen/box/sealed/simple.kt");