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 new file mode 100644 index 000000000000..c7477bfa3434 --- /dev/null +++ b/plugins/kotlin/highlighting/highlighting-k2/test/org/jetbrains/kotlin/idea/k2/highlighting/AbstractK2ComposeCompilerPluginCheckerTest.kt @@ -0,0 +1,37 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package org.jetbrains.kotlin.idea.k2.highlighting + +import com.intellij.openapi.module.Module +import com.intellij.openapi.roots.ModifiableRootModel +import com.intellij.testFramework.fixtures.MavenDependencyUtil +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 getDefaultProjectDescriptor(): ProjectDescriptorWithStdlibSources = + ProjectDescriptorWithStdlibSourcesAndComposeRuntime +} + +/** + * A Kotlin project descriptor with STDLIB sources and compose runtime libraries required for testing the compose compiler plugin. + * + * We reuse a single instance of project descriptor so that the module and project configuration can + * be effectively cached and reused between tests by the test infrastructure. + */ +private object ProjectDescriptorWithStdlibSourcesAndComposeRuntime : ProjectDescriptorWithStdlibSources() { + + private val composeRuntimeMavenLibraries: List = listOf( + // annotations for Compose compiler plugin + "org.jetbrains.compose.runtime:runtime-desktop:1.5.0", + ) + + override fun configureModule(module: Module, model: ModifiableRootModel) { + super.configureModule(module, model) + + for (library in composeRuntimeMavenLibraries) { + MavenDependencyUtil.addFromMaven(model, library) + } + } +} \ No newline at end of file diff --git a/plugins/kotlin/highlighting/highlighting-k2/test/org/jetbrains/kotlin/idea/k2/highlighting/K2ComposeCompilerPluginCheckerTestGenerated.java b/plugins/kotlin/highlighting/highlighting-k2/test/org/jetbrains/kotlin/idea/k2/highlighting/K2ComposeCompilerPluginCheckerTestGenerated.java new file mode 100644 index 000000000000..4ab59e293a14 --- /dev/null +++ b/plugins/kotlin/highlighting/highlighting-k2/test/org/jetbrains/kotlin/idea/k2/highlighting/K2ComposeCompilerPluginCheckerTestGenerated.java @@ -0,0 +1,142 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. + +package org.jetbrains.kotlin.idea.k2.highlighting; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.idea.base.plugin.KotlinPluginMode; +import org.jetbrains.kotlin.idea.base.test.TestRoot; +import org.jetbrains.kotlin.idea.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.idea.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +/** + * This class is generated by {@link org.jetbrains.kotlin.testGenerator.generator.TestGenerator}. + * DO NOT MODIFY MANUALLY. + */ +@SuppressWarnings("all") +@TestRoot("highlighting/highlighting-k2") +@TestDataPath("$CONTENT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +@TestMetadata("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers") +public class K2ComposeCompilerPluginCheckerTestGenerated extends AbstractK2ComposeCompilerPluginCheckerTest { + @java.lang.Override + @org.jetbrains.annotations.NotNull + public final KotlinPluginMode getPluginMode() { + return KotlinPluginMode.K2; + } + + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + @TestMetadata("CfromNC.kt") + public void testCfromNC() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CfromNC.kt"); + } + + @TestMetadata("CinCLambdaArg.kt") + public void testCinCLambdaArg() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCLambdaArg.kt"); + } + + @TestMetadata("CinCPropGetter.kt") + public void testCinCPropGetter() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCPropGetter.kt"); + } + + @TestMetadata("CinCrossinlineNCLambdaArg.kt") + public void testCinCrossinlineNCLambdaArg() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCrossinlineNCLambdaArg.kt"); + } + + @TestMetadata("CinInlinedNCLambdaArg.kt") + public void testCinInlinedNCLambdaArg() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinInlinedNCLambdaArg.kt"); + } + + @TestMetadata("CinLambdaArgOfC.kt") + public void testCinLambdaArgOfC() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinLambdaArgOfC.kt"); + } + + @TestMetadata("CinLambdaArgOfNC.kt") + public void testCinLambdaArgOfNC() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinLambdaArgOfNC.kt"); + } + + @TestMetadata("CinNCPropGetter.kt") + public void testCinNCPropGetter() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNCPropGetter.kt"); + } + + @TestMetadata("CinNestedInlinedNCLambdaArg.kt") + public void testCinNestedInlinedNCLambdaArg() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNestedInlinedNCLambdaArg.kt"); + } + + @TestMetadata("CinNoinlineNCLambdaArg.kt") + public void testCinNoinlineNCLambdaArg() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNoinlineNCLambdaArg.kt"); + } + + @TestMetadata("CinTopLevelInitializer.kt") + public void testCinTopLevelInitializer() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinTopLevelInitializer.kt"); + } + + @TestMetadata("ComposableFunctionReferences.kt") + public void testComposableFunctionReferences() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/ComposableFunctionReferences.kt"); + } + + @TestMetadata("ComposableMainFun.kt") + public void testComposableMainFun() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/ComposableMainFun.kt"); + } + + @TestMetadata("GenericComposableInference1.kt") + public void testGenericComposableInference1() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/GenericComposableInference1.kt"); + } + + @TestMetadata("MissingComposableOnOverride.kt") + public void testMissingComposableOnOverride() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingComposableOnOverride.kt"); + } + + @TestMetadata("MissingOverrideComposableLambda.kt") + public void testMissingOverrideComposableLambda() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingOverrideComposableLambda.kt"); + } + + @TestMetadata("MultipleOverrideLambda.kt") + public void testMultipleOverrideLambda() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MultipleOverrideLambda.kt"); + } + + @TestMetadata("NCfromC.kt") + public void testNCfromC() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/NCfromC.kt"); + } + + @TestMetadata("NonComposableFunctionReferences.kt") + public void testNonComposableFunctionReferences() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/NonComposableFunctionReferences.kt"); + } + + @TestMetadata("PropertyWithInitializer.kt") + public void testPropertyWithInitializer() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/PropertyWithInitializer.kt"); + } + + @TestMetadata("SuspendComposable.kt") + public void testSuspendComposable() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/SuspendComposable.kt"); + } + + @TestMetadata("WrongOverrideLambda.kt") + public void testWrongOverrideLambda() throws Exception { + runTest("../../idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/WrongOverrideLambda.kt"); + } +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CfromC.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CfromC.kt.highlighting new file mode 100644 index 000000000000..c567ad7f8c34 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CfromC.kt.highlighting @@ -0,0 +1,7 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* + +@Composable fun C() {} +@Composable fun C2() { C() } diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CfromNC.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CfromNC.kt new file mode 100644 index 000000000000..48a1ea778011 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CfromNC.kt @@ -0,0 +1,7 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* + +@Composable fun C() {} +fun NC() { C() } diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CfromNC.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CfromNC.kt.highlighting new file mode 100644 index 000000000000..a903b4e71dc1 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CfromNC.kt.highlighting @@ -0,0 +1,7 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* + +@Composable fun C() {} +fun NC() { C() } diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCLambdaArg.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCLambdaArg.kt new file mode 100644 index 000000000000..5e671c8d644f --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCLambdaArg.kt @@ -0,0 +1,11 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* +@Composable fun C() { } +@Composable fun C2(lambda: @Composable () -> Unit) { lambda() } +@Composable fun C3() { + C2 { + C() + } +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCLambdaArg.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCLambdaArg.kt.highlighting new file mode 100644 index 000000000000..5e671c8d644f --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCLambdaArg.kt.highlighting @@ -0,0 +1,11 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* +@Composable fun C() { } +@Composable fun C2(lambda: @Composable () -> Unit) { lambda() } +@Composable fun C3() { + C2 { + C() + } +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCPropGetter.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCPropGetter.kt new file mode 100644 index 000000000000..36f8f3ee2770 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCPropGetter.kt @@ -0,0 +1,7 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS + +import androidx.compose.runtime.* +@Composable fun C(): Int { return 123 } +val cProp: Int @Composable get() = C() diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCPropGetter.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCPropGetter.kt.highlighting new file mode 100644 index 000000000000..36f8f3ee2770 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCPropGetter.kt.highlighting @@ -0,0 +1,7 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS + +import androidx.compose.runtime.* +@Composable fun C(): Int { return 123 } +val cProp: Int @Composable get() = C() diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCrossinlineNCLambdaArg.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCrossinlineNCLambdaArg.kt new file mode 100644 index 000000000000..22dc445f0f52 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCrossinlineNCLambdaArg.kt @@ -0,0 +1,11 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* +@Composable fun C() { } +inline fun CrossinlineNC(crossinline lambda: () -> Unit) { lambda() } +@Composable fun C3() { + CrossinlineNC { + C() + } +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCrossinlineNCLambdaArg.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCrossinlineNCLambdaArg.kt.highlighting new file mode 100644 index 000000000000..4d9391c5f917 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinCrossinlineNCLambdaArg.kt.highlighting @@ -0,0 +1,11 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* +@Composable fun C() { } +inline fun CrossinlineNC(crossinline lambda: () -> Unit) { lambda() } +@Composable fun C3() { + CrossinlineNC { + C() + } +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinInlinedNCLambdaArg.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinInlinedNCLambdaArg.kt new file mode 100644 index 000000000000..5699d147579b --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinInlinedNCLambdaArg.kt @@ -0,0 +1,11 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* +@Composable fun C() { } +inline fun InlineNC(lambda: () -> Unit) { lambda() } +@Composable fun C3() { + InlineNC { + C() + } +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinInlinedNCLambdaArg.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinInlinedNCLambdaArg.kt.highlighting new file mode 100644 index 000000000000..5699d147579b --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinInlinedNCLambdaArg.kt.highlighting @@ -0,0 +1,11 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* +@Composable fun C() { } +inline fun InlineNC(lambda: () -> Unit) { lambda() } +@Composable fun C3() { + InlineNC { + C() + } +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinLambdaArgOfC.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinLambdaArgOfC.kt new file mode 100644 index 000000000000..4c2ac2764dd3 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinLambdaArgOfC.kt @@ -0,0 +1,12 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS + +import androidx.compose.runtime.* +@Composable fun C() { } +@Composable fun C2(lambda: () -> Unit) { lambda() } +@Composable fun C3() { + C2 { + C() + } +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinLambdaArgOfC.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinLambdaArgOfC.kt.highlighting new file mode 100644 index 000000000000..e1a53f50ae39 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinLambdaArgOfC.kt.highlighting @@ -0,0 +1,12 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS + +import androidx.compose.runtime.* +@Composable fun C() { } +@Composable fun C2(lambda: () -> Unit) { lambda() } +@Composable fun C3() { + C2 { + C() + } +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinLambdaArgOfNC.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinLambdaArgOfNC.kt new file mode 100644 index 000000000000..a2e0258fd77d --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinLambdaArgOfNC.kt @@ -0,0 +1,12 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS + +import androidx.compose.runtime.* +@Composable fun C() { } +fun NC(lambda: () -> Unit) { lambda() } +@Composable fun C3() { + NC { + C() + } +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinLambdaArgOfNC.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinLambdaArgOfNC.kt.highlighting new file mode 100644 index 000000000000..1cc888c6c831 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinLambdaArgOfNC.kt.highlighting @@ -0,0 +1,12 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS + +import androidx.compose.runtime.* +@Composable fun C() { } +fun NC(lambda: () -> Unit) { lambda() } +@Composable fun C3() { + NC { + C() + } +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNCPropGetter.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNCPropGetter.kt new file mode 100644 index 000000000000..32ec54d7f82a --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNCPropGetter.kt @@ -0,0 +1,6 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* +@Composable fun C(): Int { return 123 } +val ncProp: Int get() = C() diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNCPropGetter.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNCPropGetter.kt.highlighting new file mode 100644 index 000000000000..01d06990d2fc --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNCPropGetter.kt.highlighting @@ -0,0 +1,6 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* +@Composable fun C(): Int { return 123 } +val ncProp: Int get() = C() diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNestedInlinedNCLambdaArg.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNestedInlinedNCLambdaArg.kt new file mode 100644 index 000000000000..69cf925305ed --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNestedInlinedNCLambdaArg.kt @@ -0,0 +1,14 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS + +import androidx.compose.runtime.* +@Composable fun C() { } +inline fun InlineNC(lambda: () -> Unit) { lambda() } +@Composable fun C3() { + InlineNC { + InlineNC { + C() + } + } +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNestedInlinedNCLambdaArg.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNestedInlinedNCLambdaArg.kt.highlighting new file mode 100644 index 000000000000..69cf925305ed --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNestedInlinedNCLambdaArg.kt.highlighting @@ -0,0 +1,14 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS + +import androidx.compose.runtime.* +@Composable fun C() { } +inline fun InlineNC(lambda: () -> Unit) { lambda() } +@Composable fun C3() { + InlineNC { + InlineNC { + C() + } + } +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNoinlineNCLambdaArg.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNoinlineNCLambdaArg.kt new file mode 100644 index 000000000000..67fbc420f1ff --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNoinlineNCLambdaArg.kt @@ -0,0 +1,11 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* +@Composable fun C() { } +inline fun NoinlineNC(noinline lambda: () -> Unit) { lambda() } +@Composable fun C3() { + NoinlineNC { + C() + } +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNoinlineNCLambdaArg.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNoinlineNCLambdaArg.kt.highlighting new file mode 100644 index 000000000000..e9e050e39526 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinNoinlineNCLambdaArg.kt.highlighting @@ -0,0 +1,11 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* +@Composable fun C() { } +inline fun NoinlineNC(noinline lambda: () -> Unit) { lambda() } +@Composable fun C3() { + NoinlineNC { + C() + } +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinTopLevelInitializer.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinTopLevelInitializer.kt new file mode 100644 index 000000000000..75b4e0fe7f7f --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinTopLevelInitializer.kt @@ -0,0 +1,6 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* +@Composable fun C(): Int { return 123 } +val ncProp: Int = C() diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinTopLevelInitializer.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinTopLevelInitializer.kt.highlighting new file mode 100644 index 000000000000..f29a050aa2bb --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/CinTopLevelInitializer.kt.highlighting @@ -0,0 +1,6 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* +@Composable fun C(): Int { return 123 } +val ncProp: Int = C() diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/ComposableFunctionReferences.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/ComposableFunctionReferences.kt new file mode 100644 index 000000000000..48f2799f10a2 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/ComposableFunctionReferences.kt @@ -0,0 +1,15 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.Composable + +@Composable fun A() {} +val aCallable: () -> Unit = ::A +val bCallable: @Composable () -> Unit = ::A +val cCallable = ::A +fun doSomething(fn: () -> Unit) { print(fn) } +@Composable fun B(content: @Composable () -> Unit) { + content() + doSomething(::A) + B(::A) +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/ComposableFunctionReferences.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/ComposableFunctionReferences.kt.highlighting new file mode 100644 index 000000000000..c156788f4167 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/ComposableFunctionReferences.kt.highlighting @@ -0,0 +1,15 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.Composable + +@Composable fun A() {} +val aCallable: () -> Unit = ', actual 'androidx.compose.runtime.internal.KComposableFunction0'.'")!>::A +val bCallable: @Composable () -> Unit = ::A +val cCallable = ::A +fun doSomething(fn: () -> Unit) { print(fn) } +@Composable fun B(content: @Composable () -> Unit) { + content() + doSomething(::A) + B(::A) +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/ComposableMainFun.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/ComposableMainFun.kt new file mode 100644 index 000000000000..2c33f42ce0de --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/ComposableMainFun.kt @@ -0,0 +1,8 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.Composable + +@Composable fun main(args: Array) { + print(args) +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/ComposableMainFun.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/ComposableMainFun.kt.highlighting new file mode 100644 index 000000000000..4019afb42608 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/ComposableMainFun.kt.highlighting @@ -0,0 +1,8 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.Composable + +@Composable fun main(args: Array) { + print(args) +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/GenericComposableInference1.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/GenericComposableInference1.kt new file mode 100644 index 000000000000..d460af78dd61 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/GenericComposableInference1.kt @@ -0,0 +1,10 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.Composable + +fun identity(value: T): T = value + +// We should infer `ComposableFunction0` for `T` +val cl = identity(@Composable {}) +val l: () -> Unit = cl diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/GenericComposableInference1.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/GenericComposableInference1.kt.highlighting new file mode 100644 index 000000000000..714277f6d930 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/GenericComposableInference1.kt.highlighting @@ -0,0 +1,10 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.Composable + +fun identity(value: T): T = value + +// We should infer `ComposableFunction0` for `T` +val cl = identity(@Composable {}) +val l: () -> Unit = ', actual 'androidx.compose.runtime.internal.ComposableFunction0'.'")!>cl diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingComposableOnOverride.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingComposableOnOverride.kt new file mode 100644 index 000000000000..d90f846415b3 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingComposableOnOverride.kt @@ -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/MissingComposableOnOverride.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingComposableOnOverride.kt.highlighting new file mode 100644 index 000000000000..ddbc0da47a75 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingComposableOnOverride.kt.highlighting @@ -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 b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingOverrideComposableLambda.kt new file mode 100644 index 000000000000..7f13d58cb0ed --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingOverrideComposableLambda.kt @@ -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/MissingOverrideComposableLambda.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingOverrideComposableLambda.kt.highlighting new file mode 100644 index 000000000000..d9640eedf2be --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MissingOverrideComposableLambda.kt.highlighting @@ -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 b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MultipleOverrideLambda.kt new file mode 100644 index 000000000000..dac7d8a1cfdd --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MultipleOverrideLambda.kt @@ -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/MultipleOverrideLambda.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MultipleOverrideLambda.kt.highlighting new file mode 100644 index 000000000000..9e2baf28cb33 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/MultipleOverrideLambda.kt.highlighting @@ -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/NCfromC.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/NCfromC.kt new file mode 100644 index 000000000000..45ebed68ebc8 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/NCfromC.kt @@ -0,0 +1,7 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* + +fun NC() {} +@Composable fun C() { NC() } diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/NCfromC.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/NCfromC.kt.highlighting new file mode 100644 index 000000000000..45ebed68ebc8 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/NCfromC.kt.highlighting @@ -0,0 +1,7 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.* + +fun NC() {} +@Composable fun C() { NC() } diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/NonComposableFunctionReferences.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/NonComposableFunctionReferences.kt new file mode 100644 index 000000000000..a0cd9662df93 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/NonComposableFunctionReferences.kt @@ -0,0 +1,15 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.Composable + +fun A() {} +val aCallable: () -> Unit = ::A +val bCallable: @Composable () -> Unit = ::A +val cCallable = ::A +fun doSomething(fn: () -> Unit) { print(fn) } +@Composable fun B(content: @Composable () -> Unit) { + content() + doSomething(::A) + B(::A) +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/NonComposableFunctionReferences.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/NonComposableFunctionReferences.kt.highlighting new file mode 100644 index 000000000000..c8ab4cf91f1a --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/NonComposableFunctionReferences.kt.highlighting @@ -0,0 +1,15 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.Composable + +fun A() {} +val aCallable: () -> Unit = ::A +val bCallable: @Composable () -> Unit = ::A +val cCallable = ::A +fun doSomething(fn: () -> Unit) { print(fn) } +@Composable fun B(content: @Composable () -> Unit) { + content() + doSomething(::A) + B(::A) +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/PropertyWithInitializer.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/PropertyWithInitializer.kt new file mode 100644 index 000000000000..1d321571714e --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/PropertyWithInitializer.kt @@ -0,0 +1,7 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.Composable + +val bar: Int = 123 + @Composable get() = field diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/PropertyWithInitializer.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/PropertyWithInitializer.kt.highlighting new file mode 100644 index 000000000000..62164facf2b5 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/PropertyWithInitializer.kt.highlighting @@ -0,0 +1,7 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.Composable + +val bar: Int = 123 + @Composable get() = field diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/SuspendComposable.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/SuspendComposable.kt new file mode 100644 index 000000000000..f077613720ba --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/SuspendComposable.kt @@ -0,0 +1,19 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.Composable + +@Composable suspend fun Foo() {} + +fun acceptSuspend(fn: suspend () -> Unit) { print(fn) } +fun acceptComposableSuspend(fn: @Composable suspend () -> Unit) { print(fn.hashCode()) } + +val foo: suspend () -> Unit = @Composable {} +val bar: suspend () -> Unit = {} +fun Test() { + val composableLambda = @Composable {} + acceptSuspend @Composable {} + acceptComposableSuspend @Composable {} + acceptComposableSuspend(composableLambda) + acceptSuspend(@Composable suspend fun() { }) +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/SuspendComposable.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/SuspendComposable.kt.highlighting new file mode 100644 index 000000000000..2cade2877123 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/SuspendComposable.kt.highlighting @@ -0,0 +1,19 @@ +// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar +// FILE: main.kt +// ALLOW_ERRORS +import androidx.compose.runtime.Composable + +@Composable suspend fun Foo() {} + +fun acceptSuspend(fn: suspend () -> Unit) { print(fn) } +fun acceptComposableSuspend(fn: @Composable suspend () -> Unit) { print(fn.hashCode()) } + +val foo: suspend () -> Unit = ', actual 'androidx.compose.runtime.internal.ComposableFunction0'.'")!>@Composable {} +val bar: suspend () -> Unit = {} +fun Test() { + val composableLambda = @Composable {} + acceptSuspend @Composable ', but 'kotlin.coroutines.SuspendFunction0' was expected.'")!>{} + acceptComposableSuspend @Composable {} + acceptComposableSuspend(composableLambda) + acceptSuspend(', but 'kotlin.coroutines.SuspendFunction0' was expected.'")!>@Composable suspend fun() { }) +} diff --git a/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/WrongOverrideLambda.kt b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/WrongOverrideLambda.kt new file mode 100644 index 000000000000..8c2a27be68b1 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/WrongOverrideLambda.kt @@ -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/highlighterMetaInfoWithComposeCompilerCheckers/WrongOverrideLambda.kt.highlighting b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/WrongOverrideLambda.kt.highlighting new file mode 100644 index 000000000000..68d341a13187 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/WrongOverrideLambda.kt.highlighting @@ -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/highlighterMetaInfoWithComposeCompilerCheckers/compose_fake_plugin.jar b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/compose_fake_plugin.jar new file mode 100644 index 000000000000..c2c28998a323 Binary files /dev/null and b/plugins/kotlin/idea/tests/testData/highlighterMetaInfoWithComposeCompilerCheckers/compose_fake_plugin.jar differ diff --git a/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/GenerateK2HighlighterTests.kt b/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/GenerateK2HighlighterTests.kt index 344b6ab0a9ab..1e65ebaa949b 100644 --- a/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/GenerateK2HighlighterTests.kt +++ b/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/GenerateK2HighlighterTests.kt @@ -26,6 +26,10 @@ internal fun MutableTWorkspace.generateK2HighlighterTests() { model("highlighterMetaInfoWithBundledCompilerPlugins") } + testClass { + model("highlighterMetaInfoWithComposeCompilerCheckers") + } + testClass { model("highlighterMetaInfoWithExtension") }