From 5dc882abf5727117d944fddeb934ecf92a8a4927 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 30 Jan 2023 23:04:38 +0100 Subject: [PATCH] Reflection: create synthetic classes instead of throwing UOE ... for Kotlin-generated classes which do not correspond to a "class" from the Kotlin language's point of view. For example, Kotlin lambdas, file facade classes, multifile class facade/part classes, WhenMappings, DefaultImpls. They can be distinguished from normal classes by the value of `KotlinClassHeader.Kind` (which is the same as `Metadata.kind`). Another theoretical option would be to throw exception at the point where the `::class` expression is used, if the expression's type on the left-hand side is a synthetic class. But we can't really do that since it'll affect performance of most `::class` expressions. So, construct a fake synthetic class instead, without any members except equals/hashCode/toString, and without any non-trivial modifiers. It kind of contradicts the general idea that kotlin-reflect presents anything exactly the same as the compiler sees it, but arguably it's worth it to avoid unexpected exceptions like in KT-41373. In the newly added test, Java lambda check is muted but it should work exactly the same as for Kotlin lambdas and other synthetic classes. It's fixed in a subsequent commit. #KT-41373 In Progress --- ...LightTreeBlackBoxCodegenTestGenerated.java | 16 +++ .../FirPsiBlackBoxCodegenTestGenerated.java | 16 +++ .../syntheticClasses/syntheticClasses.kt | 124 ++++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 16 +++ .../IrBlackBoxCodegenTestGenerated.java | 16 +++ ...kBoxCodegenWithIrInlinerTestGenerated.java | 16 +++ .../LightAnalysisModeTestGenerated.java | 18 +++ .../kotlin/reflect/jvm/internal/KClassImpl.kt | 48 ++++--- .../fir/FirJsCodegenBoxTestGenerated.java | 10 ++ .../test/ir/IrJsCodegenBoxTestGenerated.java | 10 ++ .../ir/IrJsES6CodegenBoxTestGenerated.java | 10 ++ .../FirNativeCodegenBoxTestGenerated.java | 13 ++ .../FirNativeCodegenBoxTestNoPLGenerated.java | 15 +++ .../NativeCodegenBoxTestGenerated.java | 12 ++ .../NativeCodegenBoxTestNoPLGenerated.java | 13 ++ .../test/FirWasmCodegenBoxTestGenerated.java | 10 ++ .../test/K1WasmCodegenBoxTestGenerated.java | 10 ++ 17 files changed, 356 insertions(+), 17 deletions(-) create mode 100644 compiler/testData/codegen/box/reflection/syntheticClasses/syntheticClasses.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index afd440468bc..3ea8ebc554e 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -46693,6 +46693,22 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr } } + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/syntheticClasses") + @TestDataPath("$PROJECT_ROOT") + public class SyntheticClasses { + @Test + public void testAllFilesPresentInSyntheticClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/syntheticClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("syntheticClasses.kt") + public void testSyntheticClasses() throws Exception { + runTest("compiler/testData/codegen/box/reflection/syntheticClasses/syntheticClasses.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/reflection/typeOf") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index 96a492a5baf..e0b558f65d5 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -46693,6 +46693,22 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo } } + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/syntheticClasses") + @TestDataPath("$PROJECT_ROOT") + public class SyntheticClasses { + @Test + public void testAllFilesPresentInSyntheticClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/syntheticClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("syntheticClasses.kt") + public void testSyntheticClasses() throws Exception { + runTest("compiler/testData/codegen/box/reflection/syntheticClasses/syntheticClasses.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/reflection/typeOf") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/testData/codegen/box/reflection/syntheticClasses/syntheticClasses.kt b/compiler/testData/codegen/box/reflection/syntheticClasses/syntheticClasses.kt new file mode 100644 index 00000000000..f7707ddb048 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/syntheticClasses/syntheticClasses.kt @@ -0,0 +1,124 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT +// JVM_TARGET: 1.8 +// FILE: syntheticClasses.kt + +package test + +import kotlin.reflect.* +import kotlin.test.* + +fun check(x: KClass<*>) { + assertEquals(setOf("equals", "hashCode", "toString"), x.members.mapTo(hashSetOf()) { it.name }) + + assertEquals(emptyList(), x.annotations) + assertEquals(emptyList(), x.constructors) + assertEquals(emptyList(), x.nestedClasses) + assertEquals(null, x.objectInstance) + assertEquals(listOf(typeOf()), x.supertypes) + assertEquals(emptyList(), x.sealedSubclasses) + + assertEquals(KVisibility.PUBLIC, x.visibility) + assertTrue(x.isFinal) + assertFalse(x.isOpen) + assertFalse(x.isAbstract) + assertFalse(x.isSealed) + assertFalse(x.isData) + assertFalse(x.isInner) + assertFalse(x.isCompanion) + assertFalse(x.isFun) + assertFalse(x.isValue) + + assertFalse(x.isInstance(42)) +} + +fun checkFileClass() { + val fileClass = Class.forName("test.SyntheticClassesKt").kotlin + assertEquals("SyntheticClassesKt", fileClass.simpleName) + assertEquals("test.SyntheticClassesKt", fileClass.qualifiedName) + check(fileClass) +} + +fun checkMultifileClass() { + val klass = Class.forName("test.MultifileClass").kotlin + assertEquals("MultifileClass", klass.simpleName) + assertEquals("test.MultifileClass", klass.qualifiedName) + check(klass) +} + +fun checkMultifileClassPart() { + val klass = Class.forName("test.MultifileClass__Multifile1Kt").kotlin + assertEquals("MultifileClass__Multifile1Kt", klass.simpleName) + assertEquals("test.MultifileClass__Multifile1Kt", klass.qualifiedName) + check(klass) +} + +fun checkKotlinLambda() { + // Annotate with @JvmSerializableLambda to prevent the lambda from being generated via invokedynamic. + val lambda = @JvmSerializableLambda {} + val klass = lambda::class + + // isAnonymousClass/simpleName behavior is different for Kotlin anonymous classes in JDK 1.8 and 9+, see KT-23072. + if (klass.java.isAnonymousClass) { + assertEquals(null, klass.simpleName) + } else { + assertEquals("lambda\$1", klass.simpleName) + } + + assertEquals(null, klass.qualifiedName) + check(klass) + + assertTrue(klass.isInstance(lambda)) + assertNotEquals(klass, (@JvmSerializableLambda {})::class) + val equals = klass.members.single { it.name == "equals" } as KFunction + assertTrue(equals.call(lambda, lambda)) +} + +fun checkJavaLambda() { + val lambda = JavaClass.lambda() + val klass = lambda::class + check(klass) + + assertTrue(klass.isInstance(lambda)) + assertNotEquals(klass, Runnable {}::class) + val equals = klass.members.single { it.name == "equals" } as KFunction + assertTrue(equals.call(lambda, lambda)) +} + +fun box(): String { + checkFileClass() + checkMultifileClass() + checkMultifileClassPart() + checkKotlinLambda() + + // TODO: fails with KotlinReflectionInternalError: Unresolved class: class JavaClass$$Lambda$1166/180251002 (kind = null) + // checkJavaLambda() + + return "OK" +} + +// FILE: JavaClass.java + +public class JavaClass { + public static Runnable lambda() { + return () -> {}; + } +} + +// FILE: Multifile1.kt + +@file:JvmName("MultifileClass") +@file:JvmMultifileClass + +package test + +fun f() {} + +// FILE: Multifile2.kt + +@file:JvmName("MultifileClass") +@file:JvmMultifileClass + +package test + +fun g() {} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index c750a7c1d7b..564b55ad641 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -43987,6 +43987,22 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/syntheticClasses") + @TestDataPath("$PROJECT_ROOT") + public class SyntheticClasses { + @Test + public void testAllFilesPresentInSyntheticClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/syntheticClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("syntheticClasses.kt") + public void testSyntheticClasses() throws Exception { + runTest("compiler/testData/codegen/box/reflection/syntheticClasses/syntheticClasses.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/reflection/typeOf") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 8bae8ffd1f6..4f0b0571680 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -46693,6 +46693,22 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/syntheticClasses") + @TestDataPath("$PROJECT_ROOT") + public class SyntheticClasses { + @Test + public void testAllFilesPresentInSyntheticClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/syntheticClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("syntheticClasses.kt") + public void testSyntheticClasses() throws Exception { + runTest("compiler/testData/codegen/box/reflection/syntheticClasses/syntheticClasses.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/reflection/typeOf") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java index 96931e37252..d222f6a220b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java @@ -46693,6 +46693,22 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack } } + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/syntheticClasses") + @TestDataPath("$PROJECT_ROOT") + public class SyntheticClasses { + @Test + public void testAllFilesPresentInSyntheticClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/syntheticClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("syntheticClasses.kt") + public void testSyntheticClasses() throws Exception { + runTest("compiler/testData/codegen/box/reflection/syntheticClasses/syntheticClasses.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/reflection/typeOf") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 9756c62bf02..e8295817e77 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -37258,6 +37258,24 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } + @TestMetadata("compiler/testData/codegen/box/reflection/syntheticClasses") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SyntheticClasses extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInSyntheticClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/syntheticClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("syntheticClasses.kt") + public void testSyntheticClasses() throws Exception { + runTest("compiler/testData/codegen/box/reflection/syntheticClasses/syntheticClasses.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/reflection/typeOf") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt index 17449a072a6..5b9876b8db6 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt @@ -20,7 +20,10 @@ import org.jetbrains.kotlin.builtins.CompanionObjectMapping import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.isMappedIntrinsicCompanionObject import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl +import org.jetbrains.kotlin.descriptors.impl.EmptyPackageFragmentDescriptor import org.jetbrains.kotlin.descriptors.runtime.components.ReflectKotlinClass +import org.jetbrains.kotlin.descriptors.runtime.components.RuntimeModuleData import org.jetbrains.kotlin.descriptors.runtime.structure.functionClassArity import org.jetbrains.kotlin.descriptors.runtime.structure.wrapperByPrimitive import org.jetbrains.kotlin.incremental.components.NoLookupLocation @@ -32,6 +35,7 @@ import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns +import org.jetbrains.kotlin.resolve.scopes.GivenFunctionsMemberScope import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.serialization.deserialization.MemberDeserializer import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor @@ -49,6 +53,7 @@ internal class KClassImpl( val descriptor: ClassDescriptor by ReflectProperties.lazySoft { val classId = classId val moduleData = data.value.moduleData + val module = moduleData.module val descriptor = if (classId.isLocal && jClass.isAnnotationPresent(Metadata::class.java)) { @@ -56,10 +61,10 @@ internal class KClassImpl( // `module.findClassAcrossModuleDependencies`. moduleData.deserialization.deserializeClass(classId) } else { - moduleData.module.findClassAcrossModuleDependencies(classId) + module.findClassAcrossModuleDependencies(classId) } - descriptor ?: reportUnresolvedClass() + descriptor ?: createSyntheticClassOrFail(classId, moduleData) } val annotations: List by ReflectProperties.lazySoft { descriptor.computeAnnotations() } @@ -310,29 +315,38 @@ internal class KClassImpl( } } - private fun reportUnresolvedClass(): Nothing { + private fun createSyntheticClassOrFail(classId: ClassId, moduleData: RuntimeModuleData): ClassDescriptor { when (val kind = ReflectKotlinClass.create(jClass)?.classHeader?.kind) { - KotlinClassHeader.Kind.FILE_FACADE, KotlinClassHeader.Kind.MULTIFILE_CLASS, KotlinClassHeader.Kind.MULTIFILE_CLASS_PART -> { - throw UnsupportedOperationException( - "Packages and file facades are not yet supported in Kotlin reflection. " + - "Meanwhile please use Java reflection to inspect this class: $jClass" - ) - } - KotlinClassHeader.Kind.SYNTHETIC_CLASS -> { - throw UnsupportedOperationException( - "This class is an internal synthetic class generated by the Kotlin compiler, such as an anonymous class " + - "for a lambda, a SAM wrapper, a callable reference, etc. It's not a Kotlin class or interface, so the reflection " + - "library has no idea what declarations it has. Please use Java reflection to inspect this class: $jClass" - ) - } + KotlinClassHeader.Kind.FILE_FACADE, + KotlinClassHeader.Kind.MULTIFILE_CLASS, + KotlinClassHeader.Kind.MULTIFILE_CLASS_PART, + KotlinClassHeader.Kind.SYNTHETIC_CLASS -> + return createSyntheticClass(classId, moduleData) KotlinClassHeader.Kind.UNKNOWN -> { // Should not happen since ABI-related exception must have happened earlier throw KotlinReflectionInternalError("Unknown class: $jClass (kind = $kind)") } KotlinClassHeader.Kind.CLASS, null -> { // Should not happen since a proper Kotlin- or Java-class must have been resolved - throw KotlinReflectionInternalError("Unresolved class: $jClass") + throw KotlinReflectionInternalError("Unresolved class: $jClass (kind = $kind)") } } } + + private fun createSyntheticClass(classId: ClassId, moduleData: RuntimeModuleData): ClassDescriptor = + ClassDescriptorImpl( + EmptyPackageFragmentDescriptor(moduleData.module, classId.packageFqName), + classId.shortClassName, + Modality.FINAL, + ClassKind.CLASS, + listOf(moduleData.module.builtIns.any.defaultType), + SourceElement.NO_SOURCE, + false, + moduleData.deserialization.storageManager, + ).also { descriptor -> + descriptor.initialize(object : GivenFunctionsMemberScope(moduleData.deserialization.storageManager, descriptor) { + // Don't declare any functions in this class descriptor, only inherit equals/hashCode/toString from Any. + override fun computeDeclaredFunctions(): List = emptyList() + }, emptySet(), null) + } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java index 00a7f931ebb..9d0d14fc792 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java @@ -32779,6 +32779,16 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/syntheticClasses") + @TestDataPath("$PROJECT_ROOT") + public class SyntheticClasses { + @Test + public void testAllFilesPresentInSyntheticClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/syntheticClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/reflection/typeOf") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index 081a87d3fdd..70be6e21f92 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -32779,6 +32779,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/syntheticClasses") + @TestDataPath("$PROJECT_ROOT") + public class SyntheticClasses { + @Test + public void testAllFilesPresentInSyntheticClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/syntheticClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/reflection/typeOf") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java index e29804c9b49..a228793438c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java @@ -32779,6 +32779,16 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes } } + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/syntheticClasses") + @TestDataPath("$PROJECT_ROOT") + public class SyntheticClasses { + @Test + public void testAllFilesPresentInSyntheticClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/syntheticClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/reflection/typeOf") @TestDataPath("$PROJECT_ROOT") diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java index 8e5ee65134c..b3533a3a561 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java @@ -36186,6 +36186,19 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe } } + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/syntheticClasses") + @TestDataPath("$PROJECT_ROOT") + @Tag("frontend-fir") + @FirPipeline() + @UseExtTestCaseGroupProvider() + public class SyntheticClasses { + @Test + public void testAllFilesPresentInSyntheticClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/syntheticClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/reflection/typeOf") @TestDataPath("$PROJECT_ROOT") diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java index c4d2a92afcc..5128defa531 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java @@ -37102,6 +37102,21 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB } } + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/syntheticClasses") + @TestDataPath("$PROJECT_ROOT") + @Tag("frontend-fir") + @FirPipeline() + @UseExtTestCaseGroupProvider() + @UsePartialLinkage(mode = Mode.DISABLED) + @Tag("no-partial-linkage-may-be-skipped") + public class SyntheticClasses { + @Test + public void testAllFilesPresentInSyntheticClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/syntheticClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/reflection/typeOf") @TestDataPath("$PROJECT_ROOT") diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index 88ddbf30679..c26cf94fb62 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -35729,6 +35729,18 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest } } + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/syntheticClasses") + @TestDataPath("$PROJECT_ROOT") + @UseExtTestCaseGroupProvider() + @DisabledTestsIfProperty(sourceLocations = { "compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt", "compiler/testData/codegen/box/multiplatform/defaultArguments/*.kt", "compiler/testData/codegen/box/multiplatform/migratedOldTests/*.kt", "compiler/testData/codegen/boxInline/multiplatform/defaultArguments/receiversAndParametersInLambda.kt" }, property = ClassLevelProperty.TEST_MODE, propertyValue = "ONE_STAGE_MULTI_MODULE") + public class SyntheticClasses { + @Test + public void testAllFilesPresentInSyntheticClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/syntheticClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/reflection/typeOf") @TestDataPath("$PROJECT_ROOT") diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java index 71378a17ae2..75e61689359 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java @@ -36187,6 +36187,19 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT } } + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/syntheticClasses") + @TestDataPath("$PROJECT_ROOT") + @UseExtTestCaseGroupProvider() + @UsePartialLinkage(mode = Mode.DISABLED) + @Tag("no-partial-linkage-may-be-skipped") + public class SyntheticClasses { + @Test + public void testAllFilesPresentInSyntheticClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/syntheticClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/reflection/typeOf") @TestDataPath("$PROJECT_ROOT") diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java index 96793456cc6..6a97debd666 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java @@ -32587,6 +32587,16 @@ public class FirWasmCodegenBoxTestGenerated extends AbstractFirWasmCodegenBoxTes } } + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/syntheticClasses") + @TestDataPath("$PROJECT_ROOT") + public class SyntheticClasses { + @Test + public void testAllFilesPresentInSyntheticClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/syntheticClasses"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/reflection/typeOf") @TestDataPath("$PROJECT_ROOT") diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java index 99ca0a53e0d..58f1bb96510 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java @@ -32587,6 +32587,16 @@ public class K1WasmCodegenBoxTestGenerated extends AbstractK1WasmCodegenBoxTest } } + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/syntheticClasses") + @TestDataPath("$PROJECT_ROOT") + public class SyntheticClasses { + @Test + public void testAllFilesPresentInSyntheticClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/syntheticClasses"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/reflection/typeOf") @TestDataPath("$PROJECT_ROOT")