From 28ee61c57d67fbfb424361fba2b011afc5327898 Mon Sep 17 00:00:00 2001 From: Vladimir Sukharev Date: Wed, 22 Nov 2023 21:35:37 +0100 Subject: [PATCH] [K/N] Add diagnostic directives to test sources ^KT-61564 --- .../specialBackendChecks/README.md | 35 +++++++++---------- .../specialBackendChecks/cInterop/t11.kt | 2 +- .../specialBackendChecks/cInterop/t9.kt | 2 +- .../immutableBlobOf/t54.kt | 2 ++ .../immutableBlobOf/t55.kt | 2 ++ .../immutableBlobOf/t56.kt | 2 ++ .../immutableBlobOf/t57.kt | 2 ++ .../specialBackendChecks/objCInterop/t2.kt | 4 ++- .../specialBackendChecks/objCInterop/t61.kt | 1 + .../specialBackendChecks/objCInterop/t62.kt | 1 + .../specialBackendChecks/posix/t36.kt | 1 + .../specialBackendChecks/reflect/t59.kt | 2 +- 12 files changed, 34 insertions(+), 22 deletions(-) diff --git a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/README.md b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/README.md index 8d38836c26a..19ccf58a614 100644 --- a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/README.md +++ b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/README.md @@ -57,8 +57,7 @@ compiler/testData/diagnostics/nativeTests/specialBackendChecks/cInterop/t64.kt compiler/testData/diagnostics/nativeTests/specialBackendChecks/cInterop/t8.kt /tmp/t8.kt:8:5: error: type kotlin.Function0<*> of callback parameter 1 is not supported here: * as return type compiler/testData/diagnostics/nativeTests/specialBackendChecks/cInterop/t9.kt -/tmp/t41.kt:9:5: error: kotlinx.cinterop.staticCFunction must take an unbound, non-capturing function or lambda, but captures at: - /tmp/t41.kt:7:17: x +/tmp/t9.kt:8:5: error: type kotlin.Function0 of callback parameter 1 is not supported here: out-variance of return type compiler/testData/diagnostics/nativeTests/specialBackendChecks/concurrent/t48.kt /tmp/t48.kt:11:12: error: kotlin.native.concurrent.Worker.execute must take an unbound, non-capturing function or lambda, but captures at: /tmp/t48.kt:11:50 @@ -72,13 +71,13 @@ compiler/testData/diagnostics/nativeTests/specialBackendChecks/concurrent/t51.kt /tmp/t51.kt:10:28: error: kotlin.native.concurrent.Worker.execute must take an unbound, non-capturing function or lambda, but captures at: /tmp/t51.kt:10:66 compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t54.kt -/tmp/t54.kt:2:44: error: no spread elements allowed here +/tmp/t54.kt:4:44: error: no spread elements allowed here compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t55.kt -/tmp/t55.kt:2:37: error: all elements of binary blob must be constants +/tmp/t55.kt:4:37: error: all elements of binary blob must be constants compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t56.kt -/tmp/t56.kt:2:29: error: incorrect value for binary data: 1000 +/tmp/t56.kt:4:29: error: incorrect value for binary data: 1000 compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t57.kt -/tmp/t57.kt:2:13: error: expected at least one element +/tmp/t57.kt:4:13: error: expected at least one element compiler/testData/diagnostics/nativeTests/specialBackendChecks/nativeRef/t52.kt /tmp/t52.kt:6:5: error: kotlin.native.ref.createCleaner must take an unbound, non-capturing function or lambda, but captures at: /tmp/t52.kt:6:33: x @@ -94,7 +93,7 @@ compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t17.k compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t18.kt /tmp/t18.kt:8:19: error: super calls to Objective-C meta classes are not supported yet compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t2.kt -/tmp/t2.kt:6:5: error: 'handleFailureInFunction' overrides nothing. +/tmp/t2.kt:8:5: error: 'handleFailureInFunction' overrides nothing override fun handleFailureInFunction(functionName: String, file: String, lineNumber: NSInteger /* = Long */, description: String?, vararg args: Any?) { } ^ compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t20.kt @@ -108,14 +107,14 @@ compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t23.k compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t24.kt /tmp/t24.kt:6:1: error: only companion objects of subclasses of Objective-C classes can inherit from Objective-C metaclasses compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t25.kt -/tmp/t25.kt:7:5: error: can't override 'toString', override 'description' instead +/tmp/t25.kt:7:14: error: can't override 'toString', override 'description' instead compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t26.kt /tmp/t26.kt:11:9: error: @kotlinx.cinterop.ObjCAction method must not have extension receiver compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t27.kt /tmp/t27.kt:11:13: error: unexpected @kotlinx.cinterop.ObjCAction method parameter type: kotlin.String Only Objective-C object types are supported here compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t28.kt -/tmp/t28.kt:8:5: error: unexpected @kotlinx.cinterop.ObjCAction method return type: kotlin.Int +/tmp/t28.kt:10:5: error: unexpected @kotlinx.cinterop.ObjCAction method return type: kotlin.Int Only 'Unit' is supported here compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t29.kt /tmp/t29.kt:9:5: error: @kotlinx.cinterop.ObjCOutlet property must be var @@ -125,30 +124,30 @@ compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t31.k /tmp/t31.kt:8:5: error: unexpected @kotlinx.cinterop.ObjCOutlet type: kotlin.String Only Objective-C object types are supported here compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t32.kt -/tmp/t32.kt:8:5: error: constructor with @kotlinx.cinterop.ObjCObjectBase.OverrideInit doesn't override any super class constructor. +/tmp/t32.kt:10:5: error: constructor with @kotlinx.cinterop.ObjCObjectBase.OverrideInit doesn't override any super class constructor. It must completely match by parameter names and types. compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t33.kt -/tmp/t33.kt:8:5: error: constructor with @kotlinx.cinterop.ObjCObjectBase.OverrideInit overrides initializer that is already overridden explicitly +/tmp/t33.kt:10:5: error: constructor with @kotlinx.cinterop.ObjCObjectBase.OverrideInit overrides initializer that is already overridden explicitly compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t34.kt -/tmp/t34.kt:8:5: error: only 0, 1 or 2 parameters are supported here +/tmp/t34.kt:10:5: error: only 0, 1 or 2 parameters are supported here compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t35.kt /tmp/t35.kt:7:13: error: unable to call non-designated initializer as super constructor compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t4.kt /tmp/t4.kt:6:21: error: callable references to variadic Objective-C methods are not supported compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t5.kt -/tmp/t5.kt:6:82: error: passing String as variadic Objective-C argument is ambiguous; cast it to NSString or pass with '.cstr' as C string +/tmp/t5.kt:6:83: error: passing String as variadic Objective-C argument is ambiguous; cast it to NSString or pass with '.cstr' as C string compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t6.kt -/tmp/t6.kt:6:96: error: when calling variadic Objective-C methods spread operator is supported only for *arrayOf(...) +/tmp/t6.kt:6:97: error: when calling variadic Objective-C methods spread operator is supported only for *arrayOf(...) compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t61.kt -/tmp/t61.kt:4:5: error: only companion objects of subclasses of Objective-C classes can inherit from Objective-C metaclasses +/tmp/t61.kt:5:5: error: only companion objects of subclasses of Objective-C classes can inherit from Objective-C metaclasses compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t62.kt -/tmp/t62.kt:3:1: error: only companion objects of subclasses of Objective-C classes can inherit from Objective-C metaclasses +/tmp/t62.kt:4:1: error: only companion objects of subclasses of Objective-C classes can inherit from Objective-C metaclasses compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t7.kt -/tmp/t7.kt:6:40: error: when calling variadic C functions spread operator is supported only for *arrayOf(...) +/tmp/t7.kt:6:41: error: when calling variadic C functions spread operator is supported only for *arrayOf(...) compiler/testData/diagnostics/nativeTests/specialBackendChecks/posix/t3.kt /tmp/t3.kt:6:13: error: callable references to variadic C functions are not supported compiler/testData/diagnostics/nativeTests/specialBackendChecks/posix/t36.kt -/tmp/t36.kt:6:13: error: native interop types constructors must not be called directly +/tmp/t36.kt:7:13: error: native interop types constructors must not be called directly compiler/testData/diagnostics/nativeTests/specialBackendChecks/reflect/t58.kt /tmp/t58.kt:6:5: error: non-reified type parameters with recursive bounds are not supported yet: TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Comparable.foo>] reified:false compiler/testData/diagnostics/nativeTests/specialBackendChecks/reflect/t59.kt diff --git a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/cInterop/t11.kt b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/cInterop/t11.kt index be05209d754..0cbbda02468 100644 --- a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/cInterop/t11.kt +++ b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/cInterop/t11.kt @@ -1,7 +1,7 @@ // FIR_IDENTICAL import kotlinx.cinterop.* -fun foo(f: Function1) = f +fun foo(f: Function1<in Int, Int>) = f @OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) fun bar() { diff --git a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/cInterop/t9.kt b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/cInterop/t9.kt index 34ac706737f..f2ead080485 100644 --- a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/cInterop/t9.kt +++ b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/cInterop/t9.kt @@ -1,7 +1,7 @@ // FIR_IDENTICAL import kotlinx.cinterop.* -fun foo(f: Function0) = f +fun foo(f: Function0<out Int>) = f @OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) fun bar() { diff --git a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t54.kt b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t54.kt index a786eb0c092..47e67361a53 100644 --- a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t54.kt +++ b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t54.kt @@ -1,2 +1,4 @@ // FIR_IDENTICAL +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) +@Suppress("DEPRECATION") fun foo(arr: ShortArray) = immutableBlobOf(*arr) diff --git a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t55.kt b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t55.kt index aa5824c0ec1..30362e4e59d 100644 --- a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t55.kt +++ b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t55.kt @@ -1,2 +1,4 @@ // FIR_IDENTICAL +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) +@Suppress("DEPRECATION") fun foo(x: Short) = immutableBlobOf(x) diff --git a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t56.kt b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t56.kt index 74495021c15..9ecc28734e3 100644 --- a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t56.kt +++ b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t56.kt @@ -1,2 +1,4 @@ // FIR_IDENTICAL +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) +@Suppress("DEPRECATION") fun foo() = immutableBlobOf(1000) diff --git a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t57.kt b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t57.kt index 21f0c5d6b5d..8ce1befb4cf 100644 --- a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t57.kt +++ b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/immutableBlobOf/t57.kt @@ -1,2 +1,4 @@ // FIR_IDENTICAL +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) +@Suppress("DEPRECATION") fun foo() = immutableBlobOf() diff --git a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t2.kt b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t2.kt index 505300dd6e6..88fc0b89549 100644 --- a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t2.kt +++ b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t2.kt @@ -1,7 +1,9 @@ // FIR_IDENTICAL +// WITH_PLATFORM_LIBS import platform.darwin.* import platform.Foundation.* +// KT-42161, KT-63699: Must be not `NOTHING_TO_OVERRIDE` diagnostic, but `overriding variadic Objective-C methods is not supported` class Zzz : NSAssertionHandler() { - override fun handleFailureInFunction(functionName: String, file: String, lineNumber: NSInteger /* = Long */, description: String?, vararg args: Any?) { } + override fun handleFailureInFunction(functionName: String, file: String, lineNumber: NSInteger /* = Long */, description: String?, vararg args: Any?) { } } diff --git a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t61.kt b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t61.kt index ba692a7d9b0..1673522a176 100644 --- a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t61.kt +++ b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t61.kt @@ -1,4 +1,5 @@ // FIR_IDENTICAL +// WITH_PLATFORM_LIBS // KT-50109 class Foo { companion object : platform.darwin.NSObjectMeta() diff --git a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t62.kt b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t62.kt index 0939d185d3d..c056199638e 100644 --- a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t62.kt +++ b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/objCInterop/t62.kt @@ -1,3 +1,4 @@ // FIR_IDENTICAL +// WITH_PLATFORM_LIBS // KT-50109 class Foo : platform.darwin.NSObjectMeta() \ No newline at end of file diff --git a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/posix/t36.kt b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/posix/t36.kt index f5297289015..9172dd474ca 100644 --- a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/posix/t36.kt +++ b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/posix/t36.kt @@ -1,4 +1,5 @@ // FIR_IDENTICAL +// WITH_PLATFORM_LIBS import kotlinx.cinterop.* import platform.posix.* diff --git a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/reflect/t59.kt b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/reflect/t59.kt index bc13a35cfd8..6632ed9f05b 100644 --- a/compiler/testData/diagnostics/nativeTests/specialBackendChecks/reflect/t59.kt +++ b/compiler/testData/diagnostics/nativeTests/specialBackendChecks/reflect/t59.kt @@ -2,7 +2,7 @@ import kotlin.reflect.* @OptIn(kotlin.ExperimentalStdlibApi::class) -inline fun > foo() { +fun > foo() { typeOf>() }