From 77fdf7aa7106d9fac5c525e90d31cc376c210495 Mon Sep 17 00:00:00 2001 From: Kirill Rakhman Date: Mon, 19 Aug 2024 10:24:12 +0200 Subject: [PATCH] [kotlin] Fix test data after #KT-70709 GitOrigin-RevId: 969c54e9ea4a43f49902d14f33cb510b933fa0ce --- ...tractK2ComposeCompilerPluginCheckerTest.kt | 7 +++- .../AbstractK2HighlightingMetaInfoTest.kt | 2 +- ...ngComposableOnOverride.kt.highlighting.fir | 32 +++++++++++++++++++ ...errideComposableLambda.kt.highlighting.fir | 8 +++++ ...MultipleOverrideLambda.kt.highlighting.fir | 9 ++++++ .../WrongOverrideLambda.kt.highlighting.fir | 8 +++++ .../mustBeInitializedOrBeFinalWarning.kt | 2 +- 7 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingComposableOnOverride.kt.highlighting.fir create mode 100644 plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingOverrideComposableLambda.kt.highlighting.fir create mode 100644 plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MultipleOverrideLambda.kt.highlighting.fir create mode 100644 plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/WrongOverrideLambda.kt.highlighting.fir diff --git a/plugins/kotlin/highlighting/highlighting-k2/test/org/jetbrains/kotlin/idea/k2/highlighting/AbstractK2ComposeCompilerPluginCheckerTest.kt b/plugins/kotlin/highlighting/highlighting-k2/test/org/jetbrains/kotlin/idea/k2/highlighting/AbstractK2ComposeCompilerPluginCheckerTest.kt index c7477bfa3434..8003d2818353 100644 --- a/plugins/kotlin/highlighting/highlighting-k2/test/org/jetbrains/kotlin/idea/k2/highlighting/AbstractK2ComposeCompilerPluginCheckerTest.kt +++ b/plugins/kotlin/highlighting/highlighting-k2/test/org/jetbrains/kotlin/idea/k2/highlighting/AbstractK2ComposeCompilerPluginCheckerTest.kt @@ -8,7 +8,12 @@ import org.jetbrains.kotlin.idea.test.ProjectDescriptorWithStdlibSources import java.io.File abstract class AbstractK2ComposeCompilerPluginCheckerTest : AbstractK2BundledCompilerPluginsHighlightingMetaInfoTest() { - override fun highlightingFileNameSuffix(testKtFile: File): String = HIGHLIGHTING_EXTENSION + override fun highlightingFileNameSuffix(testKtFile: File): String { + if (testKtFile.resolveSibling("${testKtFile.name}.$HIGHLIGHTING_FIR_EXTENSION").exists()) { + return HIGHLIGHTING_FIR_EXTENSION + } + return HIGHLIGHTING_EXTENSION + } override fun getDefaultProjectDescriptor(): ProjectDescriptorWithStdlibSources = ProjectDescriptorWithStdlibSourcesAndComposeRuntime diff --git a/plugins/kotlin/highlighting/highlighting-k2/test/org/jetbrains/kotlin/idea/k2/highlighting/AbstractK2HighlightingMetaInfoTest.kt b/plugins/kotlin/highlighting/highlighting-k2/test/org/jetbrains/kotlin/idea/k2/highlighting/AbstractK2HighlightingMetaInfoTest.kt index 7049269f8623..edabfb9d5981 100644 --- a/plugins/kotlin/highlighting/highlighting-k2/test/org/jetbrains/kotlin/idea/k2/highlighting/AbstractK2HighlightingMetaInfoTest.kt +++ b/plugins/kotlin/highlighting/highlighting-k2/test/org/jetbrains/kotlin/idea/k2/highlighting/AbstractK2HighlightingMetaInfoTest.kt @@ -23,7 +23,7 @@ import java.io.File abstract class AbstractK2HighlightingMetaInfoTest : AbstractHighlightingMetaInfoTest(), KMPTest { - private val HIGHLIGHTING_FIR_EXTENSION = "highlighting.fir" + protected val HIGHLIGHTING_FIR_EXTENSION = "highlighting.fir" override fun getDefaultProjectDescriptor() = ProjectDescriptorWithStdlibSources.getInstanceWithStdlibSources() diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingComposableOnOverride.kt.highlighting.fir b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingComposableOnOverride.kt.highlighting.fir new file mode 100644 index 000000000000..60466e54af4a --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingComposableOnOverride.kt.highlighting.fir @@ -0,0 +1,32 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.Composable + +interface Foo { + @Composable + fun composableFunction(param: Boolean): Boolean + fun nonComposableFunction(param: Boolean): Boolean + val nonComposableProperty: Boolean +} + +object FakeFoo : Foo { + override fun composableFunction(param: Boolean) = true + @Composable override fun nonComposableFunction(param: Boolean) = true + override val nonComposableProperty: Boolean @Composable get() = true +} + +interface Bar { + @Composable + fun composableFunction(param: Boolean): Boolean + @get:Composable val composableProperty: Boolean + fun nonComposableFunction(param: Boolean): Boolean + val nonComposableProperty: Boolean +} + +object FakeBar : Bar { + override fun composableFunction(param: Boolean) = true + override val composableProperty: Boolean = true + @Composable override fun nonComposableFunction(param: Boolean) = true + override val nonComposableProperty: Boolean @Composable get() = true +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingOverrideComposableLambda.kt.highlighting.fir b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingOverrideComposableLambda.kt.highlighting.fir new file mode 100644 index 000000000000..118535f224c4 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingOverrideComposableLambda.kt.highlighting.fir @@ -0,0 +1,8 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.Composable + +class Impl : @Composable () -> Unit { + override fun invoke() {} +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MultipleOverrideLambda.kt.highlighting.fir b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MultipleOverrideLambda.kt.highlighting.fir new file mode 100644 index 000000000000..be8857f9b889 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MultipleOverrideLambda.kt.highlighting.fir @@ -0,0 +1,9 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.Composable + +class Impl : () -> Unit, @Composable (Int) -> Unit { + @Composable override fun invoke() {} + @Composable override fun invoke(p0: Int) {} +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/WrongOverrideLambda.kt.highlighting.fir b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/WrongOverrideLambda.kt.highlighting.fir new file mode 100644 index 000000000000..031c4341428b --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/WrongOverrideLambda.kt.highlighting.fir @@ -0,0 +1,8 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.Composable + +class Impl : () -> Unit { + @Composable override fun invoke() {} +} diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addInitializer/mustBeInitializedOrBeFinalWarning.kt b/plugins/kotlin/idea/tests/testData/quickfix/addInitializer/mustBeInitializedOrBeFinalWarning.kt index 916d9963fda5..a2a332095d47 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/addInitializer/mustBeInitializedOrBeFinalWarning.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/addInitializer/mustBeInitializedOrBeFinalWarning.kt @@ -2,7 +2,7 @@ // ERROR: Val cannot be reassigned // COMPILER_ARGUMENTS: -XXLanguage:-ProhibitOpenValDeferredInitialization open class Foo { - open val foo: Int + open val foo: Int get() = field init {