diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java index f221a7f6fec..236bf9384ad 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java @@ -926,6 +926,24 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeParameters.kt"); } + @Test + @TestMetadata("typeUsage.kt") + public void testTypeUsage() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsage.kt"); + } + + @Test + @TestMetadata("typeUsageWithImplicitType.kt") + public void testTypeUsageWithImplicitType() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsageWithImplicitType.kt"); + } + + @Test + @TestMetadata("typeUsageWithUnresolvedReference.kt") + public void testTypeUsageWithUnresolvedReference() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsageWithUnresolvedReference.kt"); + } + @Test @TestMetadata("typealias.kt") public void testTypealias() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java index 73c77db0eb3..1d26dffe897 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java @@ -926,6 +926,24 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeParameters.kt"); } + @Test + @TestMetadata("typeUsage.kt") + public void testTypeUsage() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsage.kt"); + } + + @Test + @TestMetadata("typeUsageWithImplicitType.kt") + public void testTypeUsageWithImplicitType() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsageWithImplicitType.kt"); + } + + @Test + @TestMetadata("typeUsageWithUnresolvedReference.kt") + public void testTypeUsageWithUnresolvedReference() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsageWithUnresolvedReference.kt"); + } + @Test @TestMetadata("typealias.kt") public void testTypealias() throws Exception { diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/checkDiagnosticFullText.diag.txt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/checkDiagnosticFullText.diag.txt index 1234847d2cc..cc6557e8733 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/checkDiagnosticFullText.diag.txt +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/checkDiagnosticFullText.diag.txt @@ -1,36 +1,35 @@ // -- Module: -- // -- Module: -- -/jvm.kt:44:14: warning: annotation `@Ann` is missing on actual declaration. +/jvm.kt:47:14: warning: annotation `@Ann` is missing on actual declaration. All annotations from expect `class OnClass defined in root package in file common.kt` must be present with the same arguments on actual `class OnClass defined in root package in file jvm.kt`, otherwise they might behave incorrectly. actual class OnClass ^ -/jvm.kt:47:16: warning: annotation `@Ann` is missing on actual declaration. +/jvm.kt:50:16: warning: annotation `@Ann` is missing on actual declaration. All annotations from expect `fun onMember(): Unit defined in OnMember` must be present with the same arguments on actual `fun onMember(): Unit defined in OnMember`, otherwise they might behave incorrectly. actual fun onMember() {} ^ -/jvm.kt:52:18: warning: annotation `@Ann` is missing on actual declaration. +/jvm.kt:55:18: warning: annotation `@Ann` is missing on actual declaration. All annotations from expect `class ViaTypealias defined in root package in file common.kt` must be present with the same arguments on actual `class ViaTypealiasImpl defined in root package in file jvm.kt`, otherwise they might behave incorrectly. actual typealias ViaTypealias = ViaTypealiasImpl ^ -/jvm.kt:57:18: warning: annotation `@Ann` is missing on actual declaration. +/jvm.kt:60:18: warning: annotation `@Ann` is missing on actual declaration. All annotations from expect `fun foo(): Unit defined in MemberScopeViaTypealias` must be present with the same arguments on actual `fun foo(): Unit defined in MemberScopeViaTypealiasImpl`, otherwise they might behave incorrectly. actual typealias MemberScopeViaTypealias = MemberScopeViaTypealiasImpl ^ -/jvm.kt:60:12: warning: annotation `@WithArg(s = "str")` has different arguments on actual declaration: `@WithArg(s = "other str")`. +/jvm.kt:63:12: warning: annotation `@WithArg(s = "str")` has different arguments on actual declaration: `@WithArg(s = "other str")`. All annotations from expect `fun withDifferentArg(): Unit defined in root package in file common.kt` must be present with the same arguments on actual `fun withDifferentArg(): Unit defined in root package in file jvm.kt`, otherwise they might behave incorrectly. actual fun withDifferentArg() {} ^ -/jvm.kt:62:12: warning: annotation `@Ann` is missing on actual declaration. +/jvm.kt:65:12: warning: annotation `@Ann` is missing on actual declaration. All annotations from expect `fun inValueParam(arg: String): Unit defined in root package in file common.kt` must be present with the same arguments on actual `fun inValueParam(arg: String): Unit defined in root package in file jvm.kt`, otherwise they might behave incorrectly. actual fun inValueParam(arg: String) {} ^ -/jvm.kt:64:16: warning: annotation `@Ann` is missing on actual declaration. +/jvm.kt:67:16: warning: annotation `@Ann` is missing on actual declaration. All annotations from expect `fun inTypeParam(): Unit defined in root package in file common.kt` must be present with the same arguments on actual `fun inTypeParam(): Unit defined in root package in file jvm.kt`, otherwise they might behave incorrectly. actual fun inTypeParam() {} ^ -/jvm.kt:66:12: warning: annotation `@Ann` is missing on actual declaration. +/jvm.kt:69:12: warning: annotation `@Ann` is missing on actual declaration. All annotations from expect `val onGetter: String defined in root package in file common.kt` must be present with the same arguments on actual `val onGetter: String defined in root package in file jvm.kt`, otherwise they might behave incorrectly. actual val onGetter: String = "" ^ - diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/checkDiagnosticFullText.fir.diag.txt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/checkDiagnosticFullText.fir.diag.txt index bfa8e6991e1..9680cbcd606 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/checkDiagnosticFullText.fir.diag.txt +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/checkDiagnosticFullText.fir.diag.txt @@ -1,23 +1,23 @@ -/jvm.kt:(103,110): warning: Annotation `@Ann()` is missing on actual declaration. +/jvm.kt:(106,113): warning: Annotation `@Ann()` is missing on actual declaration. All annotations from expect 'class OnClass : Any' must be present with the same arguments on actual 'class OnClass : Any', otherwise they might behave incorrectly. -/jvm.kt:(151,159): warning: Annotation `@Ann()` is missing on actual declaration. +/jvm.kt:(154,162): warning: Annotation `@Ann()` is missing on actual declaration. All annotations from expect 'fun onMember(): Unit' must be present with the same arguments on actual 'fun onMember(): Unit', otherwise they might behave incorrectly. -/jvm.kt:(209,221): warning: Annotation `@Ann()` is missing on actual declaration. +/jvm.kt:(212,224): warning: Annotation `@Ann()` is missing on actual declaration. All annotations from expect 'class ViaTypealias : Any' must be present with the same arguments on actual 'class ViaTypealiasImpl : Any', otherwise they might behave incorrectly. -/jvm.kt:(314,337): warning: Annotation `@Ann()` is missing on actual declaration. +/jvm.kt:(317,340): warning: Annotation `@Ann()` is missing on actual declaration. All annotations from expect 'fun foo(): Unit' must be present with the same arguments on actual 'fun foo(): Unit', otherwise they might behave incorrectly. -/jvm.kt:(402,418): warning: Annotation `@WithArg(s = String(str))` has different arguments on actual declaration: `@WithArg(s = String(other str))`. +/jvm.kt:(405,421): warning: Annotation `@WithArg(s = String(str))` has different arguments on actual declaration: `@WithArg(s = String(other str))`. All annotations from expect 'fun withDifferentArg(): Unit' must be present with the same arguments on actual 'fun withDifferentArg(): Unit', otherwise they might behave incorrectly. -/jvm.kt:(436,448): warning: Annotation `@Ann()` is missing on actual declaration. +/jvm.kt:(439,451): warning: Annotation `@Ann()` is missing on actual declaration. All annotations from expect 'fun inValueParam(arg: String): Unit' must be present with the same arguments on actual 'fun inValueParam(arg: String): Unit', otherwise they might behave incorrectly. -/jvm.kt:(481,492): warning: Annotation `@Ann()` is missing on actual declaration. +/jvm.kt:(484,495): warning: Annotation `@Ann()` is missing on actual declaration. All annotations from expect 'fun inTypeParam(): Unit' must be present with the same arguments on actual 'fun inTypeParam(): Unit', otherwise they might behave incorrectly. -/jvm.kt:(510,518): warning: Annotation `@PROPERTY_GETTER:Ann()` is missing on actual declaration. +/jvm.kt:(513,521): warning: Annotation `@PROPERTY_GETTER:Ann()` is missing on actual declaration. All annotations from expect 'val onGetter: String get(): String' must be present with the same arguments on actual 'val onGetter: String get(): String', otherwise they might behave incorrectly. diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/checkDiagnosticFullText.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/checkDiagnosticFullText.fir.kt index def0ae243d9..ec82512a911 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/checkDiagnosticFullText.fir.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/checkDiagnosticFullText.fir.kt @@ -8,6 +8,7 @@ AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, + AnnotationTarget.TYPE, ) annotation class Ann @@ -39,6 +40,8 @@ expect fun <@Ann T> inTypeParam() @get:Ann expect val onGetter: String +expect fun onType(param: @Ann Any) + // MODULE: m1-jvm()()(m1-common) // FILE: jvm.kt actual class OnClass @@ -64,3 +67,5 @@ actual fun withDifferentArg() {} actual fun inTypeParam() {} actual val onGetter: String = "" + +actual fun onType(param: Any) {} diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/checkDiagnosticFullText.kt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/checkDiagnosticFullText.kt index 5b808165880..49f8a5457da 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/checkDiagnosticFullText.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/checkDiagnosticFullText.kt @@ -8,6 +8,7 @@ AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, + AnnotationTarget.TYPE, ) annotation class Ann @@ -39,6 +40,8 @@ expect fun <@Ann T> inTypeParam() @get:Ann expect val onGetter: String +expect fun onType(param: @Ann Any) + // MODULE: m1-jvm()()(m1-common) // FILE: jvm.kt actual class OnClass @@ -64,3 +67,5 @@ actual fun inValueParam(arg: String) { actual fun inTypeParam() {} actual val onGetter: String = "" + +actual fun onType(param: Any) {} diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsage.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsage.fir.kt new file mode 100644 index 00000000000..33c907ec194 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsage.fir.kt @@ -0,0 +1,106 @@ +// WITH_STDLIB +// MODULE: m1-common +// FILE: common.kt +@Target(AnnotationTarget.TYPE) +annotation class Ann + +expect fun valueParameterType(arg: @Ann String) + +expect fun returnType(): @Ann String + +expect fun methodTypeParamBound() + +expect class OnClassTypeParamBound + +expect fun typeParamBoundInWhere() where T : @Ann Any + +interface I1 +interface I2 + +expect fun severalBounds() where T : I1, T : @Ann I2 + +expect fun severalBoundsDifferentOrder() where T : I2, T : @Ann I1 + +expect fun lessTypeParamBoundsOnActual() where T : I1, T : @Ann I2 + +expect fun @Ann Any.onReceiver() + +expect class OnClassSuper : @Ann I1 + +expect class OnClassSuperDifferentOrder : I1, @Ann I2 + +expect class OnClassSuperMoreOnActual : @Ann I2 + +interface I3 + +expect class OnClassSuperTypeParams : I3<@Ann T> + +expect fun deepInParamsTypes(arg: I3>) + +interface I4 + +expect fun starProjection(arg: I4<*, @Ann Any>) + +expect fun typeArgWithVariance(t: I3) + +class WithNested { + inner class Nested +} + +expect fun qualifierPartsMatching(arg: WithNested.Nested<@Ann String>) + +expect fun qualifierPartsNonMatching(arg: WithNested.Nested<@Ann String>) + +expect fun funTypeVsUserType(arg: () -> @Ann String) + +expect fun funcTypeReturnType(arg: () -> @Ann Any) + +expect fun funcTypeReceiverType(arg: @Ann Any.() -> Unit) + +expect fun funcTypeArgType(arg: (arg: @Ann Any) -> Unit) + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt +actual fun valueParameterType(arg: String) {} + +actual fun returnType(): String = "" + +actual fun methodTypeParamBound() {} + +actual class OnClassTypeParamBound + +actual fun typeParamBoundInWhere() where T : Any {} + +actual fun severalBounds() where T : I1, T : I2 {} + +actual fun severalBoundsDifferentOrder() where T : @Ann I1, T : I2 {} + +actual fun lessTypeParamBoundsOnActual() where T : @Ann I2 {} + +actual fun Any.onReceiver() {} + +actual class OnClassSuper : I1 + +actual class OnClassSuperDifferentOrder : @Ann I2, I1 + +actual class OnClassSuperMoreOnActual : I1, I2 + +actual class OnClassSuperTypeParams : I3 + +actual fun deepInParamsTypes(arg: I3>) {} + +actual fun starProjection(arg: I4<*, Any>) {} + +actual fun typeArgWithVariance(t: I3) {} + +actual fun qualifierPartsMatching(arg: WithNested.Nested<@Ann String>) {} + +actual fun qualifierPartsNonMatching(arg: WithNested<@Ann String>.Nested) {} + +actual fun funTypeVsUserType(arg: kotlin.jvm.functions.Function0) {} + +actual fun funcTypeReturnType(arg: () -> Any) {} + +actual fun funcTypeReceiverType(arg: Any.() -> Unit) {} + +actual fun funcTypeArgType(arg: (arg: Any) -> Unit) {} diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsage.kt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsage.kt new file mode 100644 index 00000000000..6f528003e8b --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsage.kt @@ -0,0 +1,106 @@ +// WITH_STDLIB +// MODULE: m1-common +// FILE: common.kt +@Target(AnnotationTarget.TYPE) +annotation class Ann + +expect fun valueParameterType(arg: @Ann String) + +expect fun returnType(): @Ann String + +expect fun methodTypeParamBound() + +expect class OnClassTypeParamBound + +expect fun typeParamBoundInWhere() where T : @Ann Any + +interface I1 +interface I2 + +expect fun severalBounds() where T : I1, T : @Ann I2 + +expect fun severalBoundsDifferentOrder() where T : I2, T : @Ann I1 + +expect fun lessTypeParamBoundsOnActual() where T : I1, T : @Ann I2 + +expect fun @Ann Any.onReceiver() + +expect class OnClassSuper : @Ann I1 + +expect class OnClassSuperDifferentOrder : I1, @Ann I2 + +expect class OnClassSuperMoreOnActual : @Ann I2 + +interface I3 + +expect class OnClassSuperTypeParams : I3<@Ann T> + +expect fun deepInParamsTypes(arg: I3>) + +interface I4 + +expect fun starProjection(arg: I4<*, @Ann Any>) + +expect fun typeArgWithVariance(t: I3) + +class WithNested { + inner class Nested +} + +expect fun qualifierPartsMatching(arg: WithNested.Nested<@Ann String>) + +expect fun qualifierPartsNonMatching(arg: WithNested.Nested<@Ann String>) + +expect fun funTypeVsUserType(arg: () -> @Ann String) + +expect fun funcTypeReturnType(arg: () -> @Ann Any) + +expect fun funcTypeReceiverType(arg: @Ann Any.() -> Unit) + +expect fun funcTypeArgType(arg: (arg: @Ann Any) -> Unit) + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt +actual fun valueParameterType(arg: String) {} + +actual fun returnType(): String = "" + +actual fun methodTypeParamBound() {} + +actual class OnClassTypeParamBound + +actual fun typeParamBoundInWhere() where T : Any {} + +actual fun severalBounds() where T : I1, T : I2 {} + +actual fun severalBoundsDifferentOrder() where T : @Ann I1, T : I2 {} + +actual fun lessTypeParamBoundsOnActual() where T : @Ann I2 {} + +actual fun Any.onReceiver() {} + +actual class OnClassSuper : I1 + +actual class OnClassSuperDifferentOrder : @Ann I2, I1 + +actual class OnClassSuperMoreOnActual : I1, I2 + +actual class OnClassSuperTypeParams : I3 + +actual fun deepInParamsTypes(arg: I3>) {} + +actual fun starProjection(arg: I4<*, Any>) {} + +actual fun typeArgWithVariance(t: I3) {} + +actual fun qualifierPartsMatching(arg: WithNested.Nested<@Ann String>) {} + +actual fun qualifierPartsNonMatching(arg: WithNested<@Ann String>.Nested) {} + +actual fun funTypeVsUserType(arg: kotlin.jvm.functions.Function0) {} + +actual fun funcTypeReturnType(arg: () -> Any) {} + +actual fun funcTypeReceiverType(arg: Any.() -> Unit) {} + +actual fun funcTypeArgType(arg: (arg: Any) -> Unit) {} diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsageWithImplicitType.kt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsageWithImplicitType.kt new file mode 100644 index 00000000000..6db09169331 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsageWithImplicitType.kt @@ -0,0 +1,11 @@ +// FIR_IDENTICAL +// MODULE: m1-common +// FILE: common.kt +@Target(AnnotationTarget.TYPE) +annotation class Ann + +expect fun foo(): @Ann Int + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt +actual fun foo() = 1 diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsageWithUnresolvedReference.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsageWithUnresolvedReference.fir.kt new file mode 100644 index 00000000000..19206683a65 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsageWithUnresolvedReference.fir.kt @@ -0,0 +1,10 @@ +// MODULE: m1-common +// FILE: common.kt +@Target(AnnotationTarget.TYPE) +annotation class Ann + +expect fun foo() + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt +actual fun Unresolved> foo() {} diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsageWithUnresolvedReference.kt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsageWithUnresolvedReference.kt new file mode 100644 index 00000000000..4ae375cc766 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsageWithUnresolvedReference.kt @@ -0,0 +1,10 @@ +// MODULE: m1-common +// FILE: common.kt +@Target(AnnotationTarget.TYPE) +annotation class Ann + +expect fun foo() + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt +actual fun Unresolved> foo() {} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index c7108e444d0..551a657b4b6 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -24101,6 +24101,24 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeParameters.kt"); } + @Test + @TestMetadata("typeUsage.kt") + public void testTypeUsage() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsage.kt"); + } + + @Test + @TestMetadata("typeUsageWithImplicitType.kt") + public void testTypeUsageWithImplicitType() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsageWithImplicitType.kt"); + } + + @Test + @TestMetadata("typeUsageWithUnresolvedReference.kt") + public void testTypeUsageWithUnresolvedReference() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typeUsageWithUnresolvedReference.kt"); + } + @Test @TestMetadata("typealias.kt") public void testTypealias() throws Exception {