From 6cce5103194af640d2a6a7c85c8befaf456980c9 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 20 Jun 2023 12:34:28 +0200 Subject: [PATCH] Tests: tweak light analysis mode test filters Do not compare private and synthetic methods between full and light analysis modes, some private fields, and InnerClasses attributes. This is needed to prepare these tests for migration to JVM IR. --- .../kotlin/codegen/AbstractLightAnalysisModeTest.kt | 12 +++++++++--- .../codegen/BytecodeListingTextCollectingVisitor.kt | 10 ++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractLightAnalysisModeTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractLightAnalysisModeTest.kt index b50fab33e63..00db83958c0 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractLightAnalysisModeTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractLightAnalysisModeTest.kt @@ -112,10 +112,12 @@ abstract class AbstractLightAnalysisModeTest : CodegenTestCase() { } override fun shouldWriteMethod(access: Int, name: String, desc: String) = when { + access and ACC_SYNTHETIC != 0 -> false + access and ACC_PRIVATE != 0 -> false name == "" -> false name.contains("\$\$forInline") -> false AsmTypes.DEFAULT_CONSTRUCTOR_MARKER.descriptor in desc -> false - name.startsWith("access$") && (access and ACC_STATIC != 0) && (access and ACC_SYNTHETIC != 0) -> false + name.startsWith("access$") && (access and ACC_STATIC != 0) -> false else -> true } @@ -123,11 +125,15 @@ abstract class AbstractLightAnalysisModeTest : CodegenTestCase() { name == "\$assertionsDisabled" -> false name == "\$VALUES" && (access and ACC_PRIVATE != 0) && (access and ACC_FINAL != 0) && (access and ACC_SYNTHETIC != 0) -> false name == JvmAbi.DELEGATED_PROPERTIES_ARRAY_NAME && (access and ACC_SYNTHETIC != 0) -> false + name.endsWith("\$receiver") -> false + JvmAbi.DELEGATED_PROPERTY_NAME_SUFFIX in name -> false else -> true } - override fun shouldWriteInnerClass(name: String, outerName: String?, innerName: String?) = - outerName != null && innerName != null + // Generated InnerClasses attributes depend on which types are used in method bodies, so they can easily be non-equal + // among full and light analysis modes. + override fun shouldWriteInnerClass(name: String, outerName: String?, innerName: String?, access: Int): Boolean = + false override val shouldTransformAnonymousTypes: Boolean get() = true diff --git a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/BytecodeListingTextCollectingVisitor.kt b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/BytecodeListingTextCollectingVisitor.kt index 2e49adaf00e..9d73fbe483d 100644 --- a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/BytecodeListingTextCollectingVisitor.kt +++ b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/BytecodeListingTextCollectingVisitor.kt @@ -77,14 +77,14 @@ class BytecodeListingTextCollectingVisitor( fun shouldWriteClass(node: ClassNode): Boolean fun shouldWriteMethod(access: Int, name: String, desc: String): Boolean fun shouldWriteField(access: Int, name: String, desc: String): Boolean - fun shouldWriteInnerClass(name: String, outerName: String?, innerName: String?): Boolean + fun shouldWriteInnerClass(name: String, outerName: String?, innerName: String?, access: Int): Boolean val shouldTransformAnonymousTypes: Boolean object EMPTY : Filter { override fun shouldWriteClass(node: ClassNode) = true override fun shouldWriteMethod(access: Int, name: String, desc: String) = true override fun shouldWriteField(access: Int, name: String, desc: String) = true - override fun shouldWriteInnerClass(name: String, outerName: String?, innerName: String?) = true + override fun shouldWriteInnerClass(name: String, outerName: String?, innerName: String?, access: Int) = true override val shouldTransformAnonymousTypes: Boolean get() = false } @@ -92,7 +92,9 @@ class BytecodeListingTextCollectingVisitor( override fun shouldWriteClass(node: ClassNode): Boolean = !node.name.startsWith("helpers/") override fun shouldWriteMethod(access: Int, name: String, desc: String): Boolean = true override fun shouldWriteField(access: Int, name: String, desc: String): Boolean = true - override fun shouldWriteInnerClass(name: String, outerName: String?, innerName: String?): Boolean = !name.startsWith("helpers/") + override fun shouldWriteInnerClass(name: String, outerName: String?, innerName: String?, access: Int): Boolean = + !name.startsWith("helpers/") + override val shouldTransformAnonymousTypes: Boolean get() = false } } @@ -351,7 +353,7 @@ class BytecodeListingTextCollectingVisitor( } override fun visitInnerClass(name: String, outerName: String?, innerName: String?, access: Int) { - if (!filter.shouldWriteInnerClass(name, outerName, innerName)) { + if (!filter.shouldWriteInnerClass(name, outerName, innerName, access)) { return }