From 1ea4fa4464db1018b5883c7baa2d29fa8961fc07 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Tue, 2 Feb 2021 13:14:19 +0100 Subject: [PATCH] Fix android test with type annotations. Remove obsolete JVM 8 flavors Remove some new test cause their originals would be executed on JvmTarget6OnJvm8 --- .../android-tests/android-module/build.gradle | 8 --- .../tests/CodegenTestsOnAndroidGenerator.kt | 25 +++---- .../FirBlackBoxCodegenTestGenerated.java | 12 ---- .../callWithIncorrectNumberOfArguments_1_6.kt | 71 ------------------- .../annotations/onTypes/arrayKClass.kt | 1 - .../onTypes/classLiteralWithExpectedType.kt | 1 - .../box/super/interfaceHashCode_1_6.kt | 11 --- .../codegen/BlackBoxCodegenTestGenerated.java | 12 ---- .../IrBlackBoxCodegenTestGenerated.java | 12 ---- .../LightAnalysisModeTestGenerated.java | 10 --- 10 files changed, 10 insertions(+), 153 deletions(-) delete mode 100644 compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments_1_6.kt delete mode 100644 compiler/testData/codegen/box/super/interfaceHashCode_1_6.kt diff --git a/compiler/android-tests/android-module/build.gradle b/compiler/android-tests/android-module/build.gradle index 91bbd497f93..8536a0ca0b6 100644 --- a/compiler/android-tests/android-module/build.gradle +++ b/compiler/android-tests/android-module/build.gradle @@ -80,14 +80,6 @@ android { reflect0 { dimension "box" } - - jvm80 { - dimension "box" - } - - reflectjvm80 { - dimension "box" - } } } diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.kt b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.kt index 2cec04d83f9..d5ecd9425a6 100644 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.kt +++ b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.kt @@ -44,10 +44,8 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager //keep it globally to avoid test grouping on TC private val generatedTestNames = hashSetOf() - private val COMMON = FlavorConfig("common", 3); - private val REFLECT = FlavorConfig("reflect", 1); - private val JVM8 = FlavorConfig("jvm8", 1); - private val JVM8REFLECT = FlavorConfig("reflectjvm8", 1); + private val COMMON = FlavorConfig("common", 3) + private val REFLECT = FlavorConfig("reflect", 1) class FlavorConfig(private val prefix: String, val limit: Int) { @@ -100,7 +98,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager it.setExecutable(true) } } - File("./gradlew.bat").copyTo(File(projectRoot, "gradlew.bat")); + File("./gradlew.bat").copyTo(File(projectRoot, "gradlew.bat")) val file = File(target, "gradle-wrapper.properties") file.readLines().map { when { @@ -156,8 +154,6 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager COMMON.printStatistics() REFLECT.printStatistics() - JVM8.printStatistics() - JVM8REFLECT.printStatistics() } internal inner class FilesWriter( @@ -282,12 +278,13 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager if (fullFileText.contains("// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm")) continue if (fullFileText.contains("// ASSERTIONS_MODE: jvm")) continue val targets = InTextDirectivesUtils.findLinesWithPrefixesRemoved(fullFileText, "// JVM_TARGET:") - .also { it.remove(JvmTarget.JVM_1_6.description) } - val isJvm8Target = - if (targets.isEmpty()) false - else if (targets.contains(JvmTarget.JVM_1_8.description) && targets.size == 1) true - else continue //TODO: support other targets on Android + val isAtLeastJvm8Target = !targets.contains(JvmTarget.JVM_1_6.description) + + if (isAtLeastJvm8Target && fullFileText.contains("@Target(AnnotationTarget.TYPE)")) { + //TODO: type annotations supported on sdk 26 emulator + continue + } // TODO: support SKIP_JDK6 on new platforms if (fullFileText.contains("// SKIP_JDK6")) continue @@ -300,9 +297,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager KotlinBaseTest.updateConfigurationByDirectivesInTestFiles(testFiles, keyConfiguration) val key = ConfigurationKey(kind, jdkKind, keyConfiguration.toString()) - val compiler = if (isJvm8Target) { - if (kind.withReflection) JVM8REFLECT else JVM8 - } else if (kind.withReflection) REFLECT else COMMON + val compiler = if (kind.withReflection) REFLECT else COMMON val filesHolder = holders.getOrPut(key) { FilesWriter(compiler, KotlinTestUtils.newConfiguration(kind, jdkKind, KtTestUtil.getAnnotationsJar() diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 9900466ceb6..be48a63ee7a 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -14339,12 +14339,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments.kt"); } - @Test - @TestMetadata("callWithIncorrectNumberOfArguments_1_6.kt") - public void testCallWithIncorrectNumberOfArguments_1_6() throws Exception { - runTest("compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments_1_6.kt"); - } - @Test @TestMetadata("function255.kt") public void testFunction255() throws Exception { @@ -35924,12 +35918,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/super/interfaceHashCode.kt"); } - @Test - @TestMetadata("interfaceHashCode_1_6.kt") - public void testInterfaceHashCode_1_6() throws Exception { - runTest("compiler/testData/codegen/box/super/interfaceHashCode_1_6.kt"); - } - @Test @TestMetadata("kt14243.kt") public void testKt14243() throws Exception { diff --git a/compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments_1_6.kt b/compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments_1_6.kt deleted file mode 100644 index 37aa0ab9500..00000000000 --- a/compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments_1_6.kt +++ /dev/null @@ -1,71 +0,0 @@ -// !LANGUAGE: +FunctionTypesWithBigArity -// WITH_RUNTIME -// TARGET_BACKEND: JVM -// JVM_TARGET: 1.6 -// FILE: J.java - -// import kotlin.jvm.functions.Arity; -import kotlin.jvm.functions.FunctionN; -import kotlin.Unit; -import java.util.Arrays; - -public class J { - // TODO: uncomment arity as soon as Arity is introduced - public static void test(/* @Arity(30) */ FunctionN f) { - Object o = new Object(); - for (int i = 0; i < 42; i++) { - if (i == 30) continue; - - Object[] args = new Object[i]; - Arrays.fill(args, o); - try { - f.invoke(args); - } catch (IllegalArgumentException e) { - // OK - - if (!e.getMessage().contains("30")) { - throw new AssertionError("Exception must specify the expected number of arguments: " + e.getMessage(), e); - } - - continue; - } catch (Throwable e) { - throw new AssertionError( - "Incorrect exception (IllegalArgumentException expected): " + e.getClass().getName() + ", i = " + i, e - ); - } - throw new AssertionError("IllegalArgumentException expected, but nothing was thrown, i = " + i); - } - } -} - -// FILE: K.kt - -fun foo( - p00: Any?, p01: Any?, p02: Any?, p03: Any?, p04: Any?, p05: Any?, p06: Any?, p07: Any?, p08: Any?, p09: Any?, - p10: Any?, p11: Any?, p12: Any?, p13: Any?, p14: Any?, p15: Any?, p16: Any?, p17: Any?, p18: Any?, p19: Any?, - p20: Any?, p21: Any?, p22: Any?, p23: Any?, p24: Any?, p25: Any?, p26: Any?, p27: Any?, p28: Any?, p29: Any? -) {} - -class Fun : (Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, - Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?) -> Unit { - override fun invoke( - p00: Any?, p01: Any?, p02: Any?, p03: Any?, p04: Any?, p05: Any?, p06: Any?, p07: Any?, p08: Any?, p09: Any?, - p10: Any?, p11: Any?, p12: Any?, p13: Any?, p14: Any?, p15: Any?, p16: Any?, p17: Any?, p18: Any?, p19: Any?, - p20: Any?, p21: Any?, p22: Any?, p23: Any?, p24: Any?, p25: Any?, p26: Any?, p27: Any?, p28: Any?, p29: Any? - ) {} -} - -fun box(): String { - val lambda: Function30< - Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, - Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, - Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, - Unit> = { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ -> } - @Suppress("DEPRECATION_ERROR") - J.test(lambda as kotlin.jvm.functions.FunctionN) - @Suppress("DEPRECATION_ERROR") - J.test(::foo as kotlin.jvm.functions.FunctionN) - @Suppress("DEPRECATION_ERROR") - J.test(Fun() as kotlin.jvm.functions.FunctionN) - return "OK" -} diff --git a/compiler/testData/codegen/box/reflection/annotations/onTypes/arrayKClass.kt b/compiler/testData/codegen/box/reflection/annotations/onTypes/arrayKClass.kt index 3ba21ac9a59..0db0871261d 100644 --- a/compiler/testData/codegen/box/reflection/annotations/onTypes/arrayKClass.kt +++ b/compiler/testData/codegen/box/reflection/annotations/onTypes/arrayKClass.kt @@ -1,7 +1,6 @@ // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT -// JVM_TARGET: 1.6 import kotlin.reflect.KClass diff --git a/compiler/testData/codegen/box/reflection/annotations/onTypes/classLiteralWithExpectedType.kt b/compiler/testData/codegen/box/reflection/annotations/onTypes/classLiteralWithExpectedType.kt index 8f430ae0cd2..0e66c2c9f4b 100644 --- a/compiler/testData/codegen/box/reflection/annotations/onTypes/classLiteralWithExpectedType.kt +++ b/compiler/testData/codegen/box/reflection/annotations/onTypes/classLiteralWithExpectedType.kt @@ -1,7 +1,6 @@ // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT -// JVM_TARGET: 1.6 package test diff --git a/compiler/testData/codegen/box/super/interfaceHashCode_1_6.kt b/compiler/testData/codegen/box/super/interfaceHashCode_1_6.kt deleted file mode 100644 index 87bd1e88336..00000000000 --- a/compiler/testData/codegen/box/super/interfaceHashCode_1_6.kt +++ /dev/null @@ -1,11 +0,0 @@ -// TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR -// JVM_TARGET: 1.6 - -interface I -class C : I { fun foo() = super.hashCode() } - -fun box(): String { - C().foo() - return "OK" -} 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 f92f42b0b28..7efa77b468a 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 @@ -14339,12 +14339,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments.kt"); } - @Test - @TestMetadata("callWithIncorrectNumberOfArguments_1_6.kt") - public void testCallWithIncorrectNumberOfArguments_1_6() throws Exception { - runTest("compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments_1_6.kt"); - } - @Test @TestMetadata("function255.kt") public void testFunction255() throws Exception { @@ -36124,12 +36118,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/super/interfaceHashCode.kt"); } - @Test - @TestMetadata("interfaceHashCode_1_6.kt") - public void testInterfaceHashCode_1_6() throws Exception { - runTest("compiler/testData/codegen/box/super/interfaceHashCode_1_6.kt"); - } - @Test @TestMetadata("kt14243.kt") public void testKt14243() throws Exception { 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 43eaf5be18f..627208a5425 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 @@ -14339,12 +14339,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments.kt"); } - @Test - @TestMetadata("callWithIncorrectNumberOfArguments_1_6.kt") - public void testCallWithIncorrectNumberOfArguments_1_6() throws Exception { - runTest("compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments_1_6.kt"); - } - @Test @TestMetadata("function255.kt") public void testFunction255() throws Exception { @@ -35924,12 +35918,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/super/interfaceHashCode.kt"); } - @Test - @TestMetadata("interfaceHashCode_1_6.kt") - public void testInterfaceHashCode_1_6() throws Exception { - runTest("compiler/testData/codegen/box/super/interfaceHashCode_1_6.kt"); - } - @Test @TestMetadata("kt14243.kt") public void testKt14243() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index c32a754882c..872585a9061 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -12602,11 +12602,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments.kt"); } - @TestMetadata("callWithIncorrectNumberOfArguments_1_6.kt") - public void testCallWithIncorrectNumberOfArguments_1_6() throws Exception { - runTest("compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments_1_6.kt"); - } - @TestMetadata("function255.kt") public void testFunction255() throws Exception { runTest("compiler/testData/codegen/box/functions/bigArity/function255.kt"); @@ -29571,11 +29566,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/super/interfaceHashCode.kt"); } - @TestMetadata("interfaceHashCode_1_6.kt") - public void testInterfaceHashCode_1_6() throws Exception { - runTest("compiler/testData/codegen/box/super/interfaceHashCode_1_6.kt"); - } - @TestMetadata("kt14243.kt") public void testKt14243() throws Exception { runTest("compiler/testData/codegen/box/super/kt14243.kt");