diff --git a/tests/ffi/static_checks/regress_44986_test.dart b/tests/ffi/static_checks/regress_44986_test.dart index 16cc1c33979e..eb647e2fc332 100644 --- a/tests/ffi/static_checks/regress_44986_test.dart +++ b/tests/ffi/static_checks/regress_44986_test.dart @@ -10,7 +10,10 @@ import "dart:ffi"; final class S2 extends Struct { external Pointer notEmpty; - external Null s; //# 01: compile-time error + external Null s; +// ^ +// [analyzer] COMPILE_TIME_ERROR.INVALID_FIELD_TYPE_IN_STRUCT +// [cfe] Field 's' contains type 'Null', which is not a valid type in a struct. } void main() { diff --git a/tests/ffi/static_checks/regress_46085_test.dart b/tests/ffi/static_checks/regress_46085_test.dart index 3dbe183739f2..2d79448eb6c3 100644 --- a/tests/ffi/static_checks/regress_46085_test.dart +++ b/tests/ffi/static_checks/regress_46085_test.dart @@ -10,11 +10,17 @@ import "dart:ffi"; final class MyStruct extends Struct { external Pointer notEmpty; - @Array.multi([]) //# 01: compile-time error - external Array a0; //# 01: compile-time error + @Array.multi([]) + external Array a0; +// ^^ +// [analyzer] COMPILE_TIME_ERROR.EMPTY_ARRAY_ANNOTATION +// [cfe] Array dimensions cannot be empty. - @Array.multi([1]) //# 02: compile-time error - external Array> a1; //# 02: compile-time error + @Array.multi([1]) + external Array> a1; +// ^^^^^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.NESTED_ARRAY_UNSUPPORTED +// [cfe] Nested arrays are not supported. } void main() { diff --git a/tests/ffi/static_checks/regress_47673_2_test.dart b/tests/ffi/static_checks/regress_47673_2_test.dart index 881f25e7d3f6..8d6c06ab5929 100644 --- a/tests/ffi/static_checks/regress_47673_2_test.dart +++ b/tests/ffi/static_checks/regress_47673_2_test.dart @@ -14,8 +14,11 @@ final class A extends Struct { external Array a; // This should not crash the FFI transform. - @Array.multi([16]) //# 1: compile-time error - external Array b; //# 1: compile-time error + @Array.multi([16]) + external Array b; +// ^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS +// [cfe] Type 'Unknown' not found. } main() {} diff --git a/tests/ffi/static_checks/regress_51041_test.dart b/tests/ffi/static_checks/regress_51041_test.dart index 52cbd04f4944..95ffaabee3fb 100644 --- a/tests/ffi/static_checks/regress_51041_test.dart +++ b/tests/ffi/static_checks/regress_51041_test.dart @@ -12,7 +12,10 @@ import 'package:ffi/ffi.dart'; final class Foo extends Struct { @Int32() external int // Force `?` to newline. - ? //# 1: compile-time error + ? +// ^ +// [analyzer] COMPILE_TIME_ERROR.NULLABLE_TYPE_IN_STRUCT +// [cfe] Struct fields cannot be nullable. x; } diff --git a/tests/ffi/static_checks/vmspecific_function_callbacks_negative_test.dart b/tests/ffi/static_checks/vmspecific_function_callbacks_negative_test.dart index 3db0ff02bccf..bc387fafd1e5 100644 --- a/tests/ffi/static_checks/vmspecific_function_callbacks_negative_test.dart +++ b/tests/ffi/static_checks/vmspecific_function_callbacks_negative_test.dart @@ -13,11 +13,26 @@ final testLibrary = DynamicLibrary.process(); // Correct type of exceptionalReturn argument to Pointer.fromFunction. double testExceptionalReturn() { - Pointer.fromFunction(returnVoid, null); //# 59: compile-time error - Pointer.fromFunction(returnVoid, 0); //# 60: compile-time error - Pointer.fromFunction(testExceptionalReturn, "abc"); //# 61: compile-time error - Pointer.fromFunction(testExceptionalReturn, 0); //# 62: compile-time error - Pointer.fromFunction(testExceptionalReturn); //# 63: compile-time error + Pointer.fromFunction(returnVoid, null); +// ^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE +// [cfe] The argument type 'void Function()' can't be assigned to the parameter type 'double Function()'. + Pointer.fromFunction(returnVoid, 0); +// ^ +// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE +// [cfe] The argument type 'int' can't be assigned to the parameter type 'void'. + Pointer.fromFunction(testExceptionalReturn, "abc"); +// ^^^^^ +// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE +// [cfe] The argument type 'String' can't be assigned to the parameter type 'double'. + Pointer.fromFunction(testExceptionalReturn, 0); +// ^ +// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE +// [cfe] The argument type 'int' can't be assigned to the parameter type 'double'. + Pointer.fromFunction(testExceptionalReturn); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.MISSING_REQUIRED_ARGUMENT +// [cfe] Required argument 'exceptionalReturn' must be provided. return 0.0; // not used } diff --git a/tests/ffi/static_checks/vmspecific_static_checks_varargs_test.dart b/tests/ffi/static_checks/vmspecific_static_checks_varargs_test.dart index c761a7c2d578..92b55f9a9416 100644 --- a/tests/ffi/static_checks/vmspecific_static_checks_varargs_test.dart +++ b/tests/ffi/static_checks/vmspecific_static_checks_varargs_test.dart @@ -15,12 +15,18 @@ void main() { final ffiTestFunctions = DynamicLibrary.process(); // Error: a named record field. - print(ffiTestFunctions.lookupFunction< //# 1: compile-time error - Void Function(Pointer, VarArgs<(Int32, Int32, {Int32 foo})>), //# 1: compile-time error - void Function(Pointer, int, int)>('PassObjectToC')); //# 1: compile-time error + print(ffiTestFunctions.lookupFunction< + Void Function(Pointer, VarArgs<(Int32, Int32, {Int32 foo})>), +// ^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.VARARGS_CANNOT_HAVE_NAMED_FIELDS +// [cfe] VarArgs cannot have named arguments. + void Function(Pointer, int, int)>('PassObjectToC')); // Error: VarArgs not last. - print(ffiTestFunctions.lookupFunction< //# 2: compile-time error - Void Function(Pointer, VarArgs<(Int32, Int32)>, Int32), //# 2: compile-time error - void Function(Pointer, int, int, int)>('PassObjectToC')); //# 2: compile-time error + print(ffiTestFunctions.lookupFunction< + Void Function(Pointer, VarArgs<(Int32, Int32)>, Int32), +// ^^^^^^^^^^^^^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.VARARGS_MUST_BE_LAST_PARAMETER +// [cfe] VarArgs must be the last parameter. + void Function(Pointer, int, int, int)>('PassObjectToC')); } diff --git a/tests/ffi/static_checks/vmspecific_variance_function_checks_test.dart b/tests/ffi/static_checks/vmspecific_variance_function_checks_test.dart index 1d6f3821eb82..6c04290c95f3 100644 --- a/tests/ffi/static_checks/vmspecific_variance_function_checks_test.dart +++ b/tests/ffi/static_checks/vmspecific_variance_function_checks_test.dart @@ -28,24 +28,33 @@ final DynamicLibrary ffiTestFunctions = final p1 = ffiTestFunctions.lookup>(paramOpName); -final nonInvariantBinding1 = //# 1: compile-time error - p1.asFunction(); //# 1: continued +final nonInvariantBinding1 = + p1.asFunction(); +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.MUST_BE_A_SUBTYPE +// [cfe] Expected type 'void Function(Pointer)' to be 'void Function(Pointer)'. final p2 = ffiTestFunctions.lookup>(returnOpName); -final nonInvariantBinding2 = //# 2: compile-time error - p2.asFunction(); //# 2: continued +final nonInvariantBinding2 = + p2.asFunction(); +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.MUST_BE_A_SUBTYPE +// [cfe] Expected type 'Pointer Function()' to be 'Pointer Function()'. final p3 = Pointer< NativeFunction< Pointer Function()>> Function()>>.fromAddress(0x1234); -final f3 = p3 //# 10: compile-time error - .asFunction< //# 10: continued - Pointer< //# 10: continued - NativeFunction< //# 10: continued - Pointer Function()>> //# 10: continued - Function()>(); //# 10: continued +final f3 = p3 + .asFunction< + Pointer< + NativeFunction< + Pointer Function()>> + Function()>(); +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.MUST_BE_A_SUBTYPE +// [cfe] Expected type 'Pointer Function()>> Function()' to be 'Pointer Function()>> Function()'. // =========================================================== // Test check on callbacks from native to Dart (fromFunction). @@ -59,11 +68,17 @@ Pointer naTyPointerReturnOp() { return Pointer.fromAddress(0x13370000); } -final implicitDowncast1 = //# 3: compile-time error - Pointer.fromFunction(//# 3: continued - naTyPointerParamOp); //# 3: continued -final implicitDowncast2 = //# 4: compile-time error - Pointer.fromFunction(//# 4: continued - naTyPointerReturnOp); //# 4: continued +final implicitDowncast1 = + Pointer.fromFunction( + naTyPointerParamOp); +// ^^^^^^^^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE +// [cfe] The argument type 'void Function(Pointer)' can't be assigned to the parameter type 'void Function(Pointer)'. +final implicitDowncast2 = + Pointer.fromFunction( + naTyPointerReturnOp); +// ^^^^^^^^^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE +// [cfe] The argument type 'Pointer Function()' can't be assigned to the parameter type 'Pointer Function()'. void main() {}