mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Add K2 compose checker tests
So far, we ran smoke tests for compose checker on Android Studio, but now the compose compiler plugin is a part the upstream KT compiler, and we enabled it for the upstream IntelliJ as well. This commit adds similar smoke tests to IntelliJ. Since we will work on the compose support for KMP, I believe this new smock test helps us to detect some issues of enabling the compose compiler plugin checker. ^KTIJ-30601 GitOrigin-RevId: 6c461ac9435d180b5cdda2529a400a0da4b8aa6c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0a5b243b28
commit
28928ffed4
+37
@@ -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<String> = 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
+142
@@ -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");
|
||||
}
|
||||
}
|
||||
+7
@@ -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() }
|
||||
+7
@@ -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() }
|
||||
+7
@@ -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 <!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_EXPECTED] Functions which invoke @Composable functions must be marked with the @Composable annotation'")!>NC<!>() { <!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_INVOCATION] @Composable invocations can only happen from the context of a @Composable function'")!>C<!>() }
|
||||
+11
@@ -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()
|
||||
}
|
||||
}
|
||||
+11
@@ -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()
|
||||
}
|
||||
}
|
||||
+7
@@ -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()
|
||||
+7
@@ -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()
|
||||
+11
@@ -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()
|
||||
}
|
||||
}
|
||||
+11
@@ -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 {
|
||||
<!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_INVOCATION] @Composable invocations can only happen from the context of a @Composable function'")!>C<!>()
|
||||
}
|
||||
}
|
||||
+11
@@ -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()
|
||||
}
|
||||
}
|
||||
+11
@@ -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()
|
||||
}
|
||||
}
|
||||
+12
@@ -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()
|
||||
}
|
||||
}
|
||||
+12
@@ -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 {
|
||||
<!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_INVOCATION] @Composable invocations can only happen from the context of a @Composable function'")!>C<!>()
|
||||
}
|
||||
}
|
||||
+12
@@ -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()
|
||||
}
|
||||
}
|
||||
+12
@@ -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 {
|
||||
<!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_INVOCATION] @Composable invocations can only happen from the context of a @Composable function'")!>C<!>()
|
||||
}
|
||||
}
|
||||
+6
@@ -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()
|
||||
+6
@@ -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 <!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_EXPECTED] Functions which invoke @Composable functions must be marked with the @Composable annotation'")!>ncProp<!>: Int get() = <!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_INVOCATION] @Composable invocations can only happen from the context of a @Composable function'")!>C<!>()
|
||||
+14
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -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()
|
||||
}
|
||||
}
|
||||
+11
@@ -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 {
|
||||
<!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_INVOCATION] @Composable invocations can only happen from the context of a @Composable function'")!>C<!>()
|
||||
}
|
||||
}
|
||||
+6
@@ -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()
|
||||
+6
@@ -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 = <!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_INVOCATION] @Composable invocations can only happen from the context of a @Composable function'")!>C<!>()
|
||||
+15
@@ -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)
|
||||
}
|
||||
+15
@@ -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 = <!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_FUNCTION_REFERENCE] Function References of @Composable functions are not currently supported'"), HIGHLIGHTING("severity='ERROR'; descr='[INITIALIZER_TYPE_MISMATCH] Initializer type mismatch: expected 'kotlin.Function0<kotlin.Unit>', actual 'androidx.compose.runtime.internal.KComposableFunction0<kotlin.Unit>'.'")!>::A<!>
|
||||
val bCallable: @Composable () -> Unit = <!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_FUNCTION_REFERENCE] Function References of @Composable functions are not currently supported'")!>::A<!>
|
||||
val cCallable = <!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_FUNCTION_REFERENCE] Function References of @Composable functions are not currently supported'")!>::A<!>
|
||||
fun doSomething(fn: () -> Unit) { print(fn) }
|
||||
@Composable fun B(content: @Composable () -> Unit) {
|
||||
content()
|
||||
doSomething(::<!HIGHLIGHTING("severity='ERROR'; descr='[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): fun A(): Unit'")!>A<!>)
|
||||
B(<!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_FUNCTION_REFERENCE] Function References of @Composable functions are not currently supported'")!>::A<!>)
|
||||
}
|
||||
+8
@@ -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<String>) {
|
||||
print(args)
|
||||
}
|
||||
+8
@@ -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 <!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_FUN_MAIN] Composable main functions are not currently supported'")!>main<!>(args: Array<String>) {
|
||||
print(args)
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar
|
||||
// FILE: main.kt
|
||||
// ALLOW_ERRORS
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
fun <T> identity(value: T): T = value
|
||||
|
||||
// We should infer `ComposableFunction0<Unit>` for `T`
|
||||
val cl = identity(@Composable {})
|
||||
val l: () -> Unit = cl
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar
|
||||
// FILE: main.kt
|
||||
// ALLOW_ERRORS
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
fun <T> identity(value: T): T = value
|
||||
|
||||
// We should infer `ComposableFunction0<Unit>` for `T`
|
||||
val cl = identity(@Composable {})
|
||||
val l: () -> Unit = <!HIGHLIGHTING("severity='ERROR'; descr='[INITIALIZER_TYPE_MISMATCH] Initializer type mismatch: expected 'kotlin.Function0<kotlin.Unit>', actual 'androidx.compose.runtime.internal.ComposableFunction0<kotlin.Unit>'.'")!>cl<!>
|
||||
+32
@@ -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
|
||||
}
|
||||
+32
@@ -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 {
|
||||
<!HIGHLIGHTING("severity='ERROR'; descr='[CONFLICTING_OVERLOADS] Conflicting overloads: fun composableFunction(param: Boolean): Boolean fun composableFunction(param: Boolean): Boolean'")!>override fun composableFunction(param: Boolean)<!> = true
|
||||
<!HIGHLIGHTING("severity='ERROR'; descr='[CONFLICTING_OVERLOADS] Conflicting overloads: fun nonComposableFunction(param: Boolean): Boolean fun nonComposableFunction(param: Boolean): Boolean'")!>@Composable override fun nonComposableFunction(param: Boolean)<!> = true
|
||||
override val nonComposableProperty: Boolean <!HIGHLIGHTING("severity='ERROR'; descr='[CONFLICTING_OVERLOADS] Conflicting overloads: get(): Boolean get(): 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 {
|
||||
<!HIGHLIGHTING("severity='ERROR'; descr='[CONFLICTING_OVERLOADS] Conflicting overloads: fun composableFunction(param: Boolean): Boolean fun composableFunction(param: Boolean): Boolean'")!>override fun composableFunction(param: Boolean)<!> = true
|
||||
<!HIGHLIGHTING("severity='ERROR'; descr='[CONFLICTING_OVERLOADS] Conflicting overloads: get(): Boolean get(): Boolean'")!>override val composableProperty: Boolean<!> = true
|
||||
<!HIGHLIGHTING("severity='ERROR'; descr='[CONFLICTING_OVERLOADS] Conflicting overloads: fun nonComposableFunction(param: Boolean): Boolean fun nonComposableFunction(param: Boolean): Boolean'")!>@Composable override fun nonComposableFunction(param: Boolean)<!> = true
|
||||
override val nonComposableProperty: Boolean <!HIGHLIGHTING("severity='ERROR'; descr='[CONFLICTING_OVERLOADS] Conflicting overloads: get(): Boolean get(): Boolean'")!>@Composable get()<!> = true
|
||||
}
|
||||
+8
@@ -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() {}
|
||||
}
|
||||
+8
@@ -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 {
|
||||
<!HIGHLIGHTING("severity='ERROR'; descr='[CONFLICTING_OVERLOADS] Conflicting overloads: fun invoke(): Unit fun invoke(): R'")!>override fun invoke()<!> {}
|
||||
}
|
||||
+9
@@ -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) {}
|
||||
}
|
||||
+9
@@ -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 : <!HIGHLIGHTING("severity='ERROR'; descr='[MIXING_FUNCTIONAL_KINDS_IN_SUPERTYPES] Mixing supertypes of different functional kinds ([Function, @Composable]) is not allowed.'")!>() -> Unit, @Composable (Int) -> Unit<!> {
|
||||
<!HIGHLIGHTING("severity='ERROR'; descr='[CONFLICTING_OVERLOADS] Conflicting overloads: fun invoke(): Unit fun invoke(): R'")!>@Composable override fun invoke()<!> {}
|
||||
@Composable override fun invoke(p0: Int) {}
|
||||
}
|
||||
+7
@@ -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() }
|
||||
+7
@@ -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() }
|
||||
+15
@@ -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)
|
||||
}
|
||||
+15
@@ -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 = <!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_FUNCTION_REFERENCE] Function References of @Composable functions are not currently supported'")!>::A<!>
|
||||
val cCallable = ::A
|
||||
fun doSomething(fn: () -> Unit) { print(fn) }
|
||||
@Composable fun B(content: @Composable () -> Unit) {
|
||||
content()
|
||||
doSomething(::A)
|
||||
B(<!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_FUNCTION_REFERENCE] Function References of @Composable functions are not currently supported'")!>::A<!>)
|
||||
}
|
||||
+7
@@ -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
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// COMPILER_ARGUMENTS: -Xplugin=$TEST_DIR$/compose_fake_plugin.jar
|
||||
// FILE: main.kt
|
||||
// ALLOW_ERRORS
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
val <!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_PROPERTY_BACKING_FIELD] Composable properties are not able to have backing fields'")!>bar<!>: Int = 123
|
||||
@Composable get() = field
|
||||
+19
@@ -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() { })
|
||||
}
|
||||
+19
@@ -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 <!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_SUSPEND_FUN] Composable function cannot be annotated as suspend'")!>Foo<!>() {}
|
||||
|
||||
fun acceptSuspend(fn: suspend () -> Unit) { print(fn) }
|
||||
fun acceptComposableSuspend(fn: <!HIGHLIGHTING("severity='ERROR'; descr='[AMBIGUOUS_FUNCTION_TYPE_KIND] Multiple function type conversions are prohibited for a single type. Detected type conversions: [suspend, @Composable]'")!>@Composable suspend () -> Unit<!>) { print(fn.hashCode()) }
|
||||
|
||||
val foo: suspend () -> Unit = <!HIGHLIGHTING("severity='ERROR'; descr='[INITIALIZER_TYPE_MISMATCH] Initializer type mismatch: expected 'kotlin.coroutines.SuspendFunction0<kotlin.Unit>', actual 'androidx.compose.runtime.internal.ComposableFunction0<kotlin.Unit>'.'")!>@Composable {}<!>
|
||||
val bar: suspend () -> Unit = {}
|
||||
fun Test() {
|
||||
val composableLambda = @Composable {}
|
||||
acceptSuspend @Composable <!HIGHLIGHTING("severity='ERROR'; descr='[ARGUMENT_TYPE_MISMATCH] Argument type mismatch: actual type is 'androidx.compose.runtime.internal.ComposableFunction0<kotlin.Unit>', but 'kotlin.coroutines.SuspendFunction0<kotlin.Unit>' was expected.'")!>{}<!>
|
||||
acceptComposableSuspend @Composable {}
|
||||
acceptComposableSuspend(composableLambda)
|
||||
acceptSuspend(<!HIGHLIGHTING("severity='ERROR'; descr='[ARGUMENT_TYPE_MISMATCH] Argument type mismatch: actual type is 'kotlin.Function0<kotlin.Unit>', but 'kotlin.coroutines.SuspendFunction0<kotlin.Unit>' was expected.'")!><!HIGHLIGHTING("severity='ERROR'; descr='[COMPOSABLE_SUSPEND_FUN] Composable function cannot be annotated as suspend'")!>@Composable <!HIGHLIGHTING("severity='ERROR'; descr='[ANONYMOUS_SUSPEND_FUNCTION] Anonymous suspend functions are prohibited.'")!>suspend<!> fun()<!> { }<!>)
|
||||
}
|
||||
+8
@@ -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() {}
|
||||
}
|
||||
+8
@@ -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 {
|
||||
<!HIGHLIGHTING("severity='ERROR'; descr='[CONFLICTING_OVERLOADS] Conflicting overloads: fun invoke(): Unit fun invoke(): R'")!>@Composable override fun invoke()<!> {}
|
||||
}
|
||||
BIN
Binary file not shown.
+4
@@ -26,6 +26,10 @@ internal fun MutableTWorkspace.generateK2HighlighterTests() {
|
||||
model("highlighterMetaInfoWithBundledCompilerPlugins")
|
||||
}
|
||||
|
||||
testClass<AbstractK2ComposeCompilerPluginCheckerTest> {
|
||||
model("highlighterMetaInfoWithComposeCompilerCheckers")
|
||||
}
|
||||
|
||||
testClass<AbstractK2HighlightingMetaInfoWithExtensionTest> {
|
||||
model("highlighterMetaInfoWithExtension")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user