From 2b6f294f4acd92b251fe209d922ceef378fb2b86 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Wed, 24 Jul 2024 21:29:26 +0200 Subject: [PATCH] KTIJ-30581 [kotlin] Adjust refactorings and J2K testdata to the new Import Optimizer implementation There are some improvements and some degradations. Most notably, there is a "kotlin.concurrent.Volatile" annotation replacement in J2K, which happens because K2 references have problems with type aliases (see KTIJ-25346 as one of the tracking issues). GitOrigin-RevId: 8bf9a6a65d34fc335897e8209d09dedf350abc6c --- .../shortenCompanionObject2/after/b/boo.k2.kt | 18 ------------------ .../after/onDemandImport.k2.kt | 2 -- .../after/a/onDemandImport.k2.kt | 1 - .../comments/generatedImportsWithPackage.k2.kt | 9 +++++++++ .../testData/newJ2k/field/volatileCommon.k2.kt | 6 ++++++ .../field/volatileTransientAndStrictFp.kt | 2 -- .../newJ2k/postProcessing/SortModifiers.k2.kt | 6 ------ .../field/volatileTransientAndStrictFp.kt | 2 +- 8 files changed, 16 insertions(+), 30 deletions(-) delete mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveTopLevel/kotlin/shortenCompanionObject2/after/b/boo.k2.kt create mode 100644 plugins/kotlin/j2k/shared/tests/testData/newJ2k/comments/generatedImportsWithPackage.k2.kt create mode 100644 plugins/kotlin/j2k/shared/tests/testData/newJ2k/field/volatileCommon.k2.kt delete mode 100644 plugins/kotlin/j2k/shared/tests/testData/newJ2k/postProcessing/SortModifiers.k2.kt diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveTopLevel/kotlin/shortenCompanionObject2/after/b/boo.k2.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveTopLevel/kotlin/shortenCompanionObject2/after/b/boo.k2.kt deleted file mode 100644 index 9eace15a4929..000000000000 --- a/plugins/kotlin/idea/tests/testData/refactoring/moveTopLevel/kotlin/shortenCompanionObject2/after/b/boo.k2.kt +++ /dev/null @@ -1,18 +0,0 @@ -package b - -import b.Factory.Companion.invoke -import java.util.function.IntPredicate - -interface Factory { - operator fun invoke(i: Int): IntPredicate - - companion object { - inline operator fun invoke(crossinline f: (Int) -> IntPredicate) = object : Factory { - override fun invoke(i: Int) = f(i) - } - } -} - -fun foo(): Factory = Factory { k -> - IntPredicate { n -> n % k == 0 } -} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveTopLevelToInner/java/moveTopLevelClassToTopLevelClass/after/onDemandImport.k2.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveTopLevelToInner/java/moveTopLevelClassToTopLevelClass/after/onDemandImport.k2.kt index 4a7bff89c82b..bca84ba26c83 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/moveTopLevelToInner/java/moveTopLevelClassToTopLevelClass/after/onDemandImport.k2.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveTopLevelToInner/java/moveTopLevelClassToTopLevelClass/after/onDemandImport.k2.kt @@ -1,5 +1,3 @@ -import B.* - fun bar() { val t: B.A = B.A() } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveTopLevelToInner/java/moveTopLevelClassToTopLevelClassOfAnotherPackage/after/a/onDemandImport.k2.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveTopLevelToInner/java/moveTopLevelClassToTopLevelClassOfAnotherPackage/after/a/onDemandImport.k2.kt index c328d3902312..d4bf3fda7924 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/moveTopLevelToInner/java/moveTopLevelClassToTopLevelClassOfAnotherPackage/after/a/onDemandImport.k2.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveTopLevelToInner/java/moveTopLevelClassToTopLevelClassOfAnotherPackage/after/a/onDemandImport.k2.kt @@ -1,7 +1,6 @@ package a import b.B -import b.B.* fun bar() { val t: B.A = B.A() diff --git a/plugins/kotlin/j2k/shared/tests/testData/newJ2k/comments/generatedImportsWithPackage.k2.kt b/plugins/kotlin/j2k/shared/tests/testData/newJ2k/comments/generatedImportsWithPackage.k2.kt new file mode 100644 index 000000000000..4ffd67458359 --- /dev/null +++ b/plugins/kotlin/j2k/shared/tests/testData/newJ2k/comments/generatedImportsWithPackage.k2.kt @@ -0,0 +1,9 @@ +package p + +// comment +// comment 2 + +internal class A { + @Volatile + var field: Int = 0 +} diff --git a/plugins/kotlin/j2k/shared/tests/testData/newJ2k/field/volatileCommon.k2.kt b/plugins/kotlin/j2k/shared/tests/testData/newJ2k/field/volatileCommon.k2.kt new file mode 100644 index 000000000000..c86d64d4bd32 --- /dev/null +++ b/plugins/kotlin/j2k/shared/tests/testData/newJ2k/field/volatileCommon.k2.kt @@ -0,0 +1,6 @@ +// API_VERSION: 1.9 +// COMPILER_ARGUMENTS: -opt-in=kotlin.ExperimentalStdlibApi +internal class A { + @Volatile + var field1: Int = 0 +} diff --git a/plugins/kotlin/j2k/shared/tests/testData/newJ2k/field/volatileTransientAndStrictFp.kt b/plugins/kotlin/j2k/shared/tests/testData/newJ2k/field/volatileTransientAndStrictFp.kt index ddd9ea4adf51..d2068d46e060 100644 --- a/plugins/kotlin/j2k/shared/tests/testData/newJ2k/field/volatileTransientAndStrictFp.kt +++ b/plugins/kotlin/j2k/shared/tests/testData/newJ2k/field/volatileTransientAndStrictFp.kt @@ -1,6 +1,4 @@ // ERROR: This annotation is not applicable to target 'member property with backing field'. -import kotlin.concurrent.Volatile - internal class A { @Deprecated("") @Volatile diff --git a/plugins/kotlin/j2k/shared/tests/testData/newJ2k/postProcessing/SortModifiers.k2.kt b/plugins/kotlin/j2k/shared/tests/testData/newJ2k/postProcessing/SortModifiers.k2.kt deleted file mode 100644 index 93d2b5a6c3b9..000000000000 --- a/plugins/kotlin/j2k/shared/tests/testData/newJ2k/postProcessing/SortModifiers.k2.kt +++ /dev/null @@ -1,6 +0,0 @@ -import TestInnerClasses.Base - -class TestInnerClasses { - open inner class Base - inner class Derived : Base() -} diff --git a/plugins/kotlin/j2k/shared/tests/testData/partialConverter/field/volatileTransientAndStrictFp.kt b/plugins/kotlin/j2k/shared/tests/testData/partialConverter/field/volatileTransientAndStrictFp.kt index 1e387a192ec1..551c13e4c0b3 100644 --- a/plugins/kotlin/j2k/shared/tests/testData/partialConverter/field/volatileTransientAndStrictFp.kt +++ b/plugins/kotlin/j2k/shared/tests/testData/partialConverter/field/volatileTransientAndStrictFp.kt @@ -1,5 +1,5 @@ // ERROR: This annotation is not applicable to target 'member property with backing field'. -import kotlin.concurrent.Volatile + internal class A { @Deprecated("")