[FIR] Add tests for plugins compatibility
^KT-57140
This commit is contained in:
committed by
Space Team
parent
a705bfe2cd
commit
01fc84ee3a
+1
-2
@@ -34,8 +34,7 @@ annotation class SupertypeWithTypeArgument(val kClass: KClass<*>)
|
||||
|
||||
annotation class MetaSupertype
|
||||
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.TYPE, AnnotationTarget.EXPRESSION)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.TYPE)
|
||||
annotation class MyComposable
|
||||
|
||||
annotation class AllPropertiesConstructor
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.plugin
|
||||
|
||||
class Box<T>(val value: T)
|
||||
|
||||
fun produceComposableFunction(): @MyComposable () -> Unit = null!!
|
||||
fun consumeComposableFunction(@Suppress("UNUSED_PARAMETER") block: @MyComposable () -> Unit) {}
|
||||
|
||||
fun produceBoxedComposableFunction(): Box<@MyComposable () -> Unit> = Box(produceComposableFunction())
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.plugin
|
||||
|
||||
fun producePositiveInt(): @Positive Int = 1
|
||||
fun consumePositiveInt(@Suppress("UNUSED_PARAMETER") x: @Positive Int) {}
|
||||
|
||||
fun produceBoxedPositiveInt(): Box<@Positive Int> = Box(1)
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
FILE: dependencyWithoutAttributePlugin.kt
|
||||
public final fun takePositive(x: R|@Positive kotlin/Number|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun takeNegative(x: R|@Negative kotlin/Number|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun takeAny(x: R|kotlin/Number|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun test_1(positiveInt: R|@Positive kotlin/Int|, negativeInt: R|@Negative kotlin/Int|, someInt: R|kotlin/Int|): R|kotlin/Unit| {
|
||||
R|org/jetbrains/kotlin/fir/plugin/consumePositiveInt|(R|<local>/positiveInt|)
|
||||
R|org/jetbrains/kotlin/fir/plugin/consumePositiveInt|(R|<local>/negativeInt|)
|
||||
R|org/jetbrains/kotlin/fir/plugin/consumePositiveInt|(R|<local>/someInt|)
|
||||
}
|
||||
public final fun test_2(): R|kotlin/Unit| {
|
||||
lval x: R|@R|org/jetbrains/kotlin/fir/plugin/Positive|() kotlin/Int| = R|org/jetbrains/kotlin/fir/plugin/producePositiveInt|()
|
||||
R|/takePositive|(R|<local>/x|)
|
||||
R|/takeNegative|(R|<local>/x|)
|
||||
R|/takeAny|(R|<local>/x|)
|
||||
}
|
||||
public final fun test_3(): R|kotlin/Unit| {
|
||||
lval x: R|@R|org/jetbrains/kotlin/fir/plugin/Positive|() kotlin/Int| = R|org/jetbrains/kotlin/fir/plugin/produceBoxedPositiveInt|().R|SubstitutionOverride<org/jetbrains/kotlin/fir/plugin/Box.value: R|@R|org/jetbrains/kotlin/fir/plugin/Positive|() kotlin/Int|>|
|
||||
R|/takePositive|(R|<local>/x|)
|
||||
R|/takeNegative|(R|<local>/x|)
|
||||
R|/takeAny|(R|<local>/x|)
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
import org.jetbrains.kotlin.fir.plugin.*
|
||||
|
||||
fun takePositive(x: @Positive Number) {}
|
||||
fun takeNegative(x: @Negative Number) {}
|
||||
fun takeAny(x: Number) {}
|
||||
|
||||
fun test_1(
|
||||
positiveInt: @Positive Int,
|
||||
negativeInt: @Negative Int,
|
||||
someInt: Int
|
||||
) {
|
||||
consumePositiveInt(positiveInt)
|
||||
consumePositiveInt(negativeInt) // should be error
|
||||
consumePositiveInt(someInt) // should be error
|
||||
}
|
||||
|
||||
fun test_2() {
|
||||
val x = producePositiveInt()
|
||||
takePositive(<!ILLEGAL_NUMBER_SIGN!>x<!>)
|
||||
takeNegative(<!ILLEGAL_NUMBER_SIGN!>x<!>) // should be error
|
||||
takeAny(x)
|
||||
}
|
||||
|
||||
fun test_3() {
|
||||
val x = produceBoxedPositiveInt().value
|
||||
takePositive(<!ILLEGAL_NUMBER_SIGN!>x<!>)
|
||||
takeNegative(<!ILLEGAL_NUMBER_SIGN!>x<!>) // should be error
|
||||
takeAny(x)
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
FILE: dependencyWithoutFunctionalKindPlugin.kt
|
||||
public final fun consumeRegularFunction(block: R|() -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun consumeSuspendFunction(block: R|suspend () -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun consumeOurComposableFunction(block: R|@R|org/jetbrains/kotlin/fir/plugin/MyComposable|() some/MyComposableFunction0<kotlin/Unit>|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun test_1(block: R|() -> kotlin/Unit|, composableBlock: R|@R|org/jetbrains/kotlin/fir/plugin/MyComposable|() some/MyComposableFunction0<kotlin/Unit>|, suspendBlock: R|suspend () -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
R|org/jetbrains/kotlin/fir/plugin/consumeComposableFunction|(R|<local>/block|)
|
||||
R|org/jetbrains/kotlin/fir/plugin/consumeComposableFunction<Inapplicable(INAPPLICABLE): org/jetbrains/kotlin/fir/plugin/consumeComposableFunction>#|(R|<local>/composableBlock|)
|
||||
R|org/jetbrains/kotlin/fir/plugin/consumeComposableFunction<Inapplicable(INAPPLICABLE): org/jetbrains/kotlin/fir/plugin/consumeComposableFunction>#|(R|<local>/suspendBlock|)
|
||||
}
|
||||
public final fun test_2(): R|kotlin/Unit| {
|
||||
lval block: R|() -> kotlin/Unit| = R|org/jetbrains/kotlin/fir/plugin/produceComposableFunction|()
|
||||
R|/consumeRegularFunction|(R|<local>/block|)
|
||||
R|/consumeSuspendFunction|(R|<local>/block|)
|
||||
R|/consumeOurComposableFunction|(R|<local>/block|)
|
||||
R|org/jetbrains/kotlin/fir/plugin/consumeComposableFunction|(R|<local>/block|)
|
||||
}
|
||||
public final fun test_3(): R|kotlin/Unit| {
|
||||
lval block: R|() -> kotlin/Unit| = R|org/jetbrains/kotlin/fir/plugin/produceBoxedComposableFunction|().R|SubstitutionOverride<org/jetbrains/kotlin/fir/plugin/Box.value: R|() -> kotlin/Unit|>|
|
||||
R|/consumeRegularFunction|(R|<local>/block|)
|
||||
R|/consumeSuspendFunction|(R|<local>/block|)
|
||||
R|/consumeOurComposableFunction|(R|<local>/block|)
|
||||
R|org/jetbrains/kotlin/fir/plugin/consumeComposableFunction|(R|<local>/block|)
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import org.jetbrains.kotlin.fir.plugin.*
|
||||
|
||||
fun consumeRegularFunction(block: () -> Unit) {}
|
||||
fun consumeSuspendFunction(block: suspend () -> Unit) {}
|
||||
fun consumeOurComposableFunction(block: @MyComposable () -> Unit) {}
|
||||
|
||||
fun test_1(
|
||||
block: () -> Unit,
|
||||
composableBlock: @MyComposable () -> Unit,
|
||||
suspendBlock: suspend () -> Unit,
|
||||
) {
|
||||
consumeComposableFunction(block)
|
||||
consumeComposableFunction(<!ARGUMENT_TYPE_MISMATCH!>composableBlock<!>)
|
||||
consumeComposableFunction(<!ARGUMENT_TYPE_MISMATCH!>suspendBlock<!>) // should be error
|
||||
}
|
||||
|
||||
fun test_2() {
|
||||
val block = produceComposableFunction()
|
||||
consumeRegularFunction(block) // should be error
|
||||
consumeSuspendFunction(block) // should be error
|
||||
consumeOurComposableFunction(block)
|
||||
consumeComposableFunction(block)
|
||||
}
|
||||
|
||||
fun test_3() {
|
||||
val block = produceBoxedComposableFunction().value
|
||||
consumeRegularFunction(block) // should be error
|
||||
consumeSuspendFunction(block) // should be error
|
||||
consumeOurComposableFunction(block)
|
||||
consumeComposableFunction(block)
|
||||
}
|
||||
+12
@@ -33,6 +33,12 @@ public class FirPsiPluginDiagnosticTestGenerated extends AbstractFirPsiPluginDia
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/fir-plugin-prototype/testData/diagnostics/checkers"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dependencyWithoutAttributePlugin.kt")
|
||||
public void testDependencyWithoutAttributePlugin() throws Exception {
|
||||
runTest("plugins/fir-plugin-prototype/testData/diagnostics/checkers/dependencyWithoutAttributePlugin.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("signedNumbersCheckers.kt")
|
||||
public void testSignedNumbersCheckers() throws Exception {
|
||||
@@ -61,6 +67,12 @@ public class FirPsiPluginDiagnosticTestGenerated extends AbstractFirPsiPluginDia
|
||||
runTest("plugins/fir-plugin-prototype/testData/diagnostics/functionalTypes/ambigousKinds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dependencyWithoutFunctionalKindPlugin.kt")
|
||||
public void testDependencyWithoutFunctionalKindPlugin() throws Exception {
|
||||
runTest("plugins/fir-plugin-prototype/testData/diagnostics/functionalTypes/dependencyWithoutFunctionalKindPlugin.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inference.kt")
|
||||
public void testInference() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user