Closed
Description
There is 2 errors being thrown for this snippet
@Native<Void Function(Pointer<Void>)>(isLeaf: true)
external void myNative(Pointer<Void> buffer);
void main() {
final typedData = Int8List.fromList([1, 2]);
myNative(typedData.address);
}
Output of dart <thisfile.dart>
:
tests/ffi/static_checks/address_of_cast_test.dart:50:22: Error: The argument type 'Pointer<Int8>' can't be assigned to the parameter type 'Pointer<Void>'.
- 'Pointer' is from 'dart:ffi'.
- 'Int8' is from 'dart:ffi'.
- 'Void' is from 'dart:ffi'.
myNative(typedData.address);
^
tests/ffi/static_checks/address_of_cast_test.dart:50:22: Error: The '.address' expression can only be used as argument to a leaf native external call.
myNative(typedData.address);
The second error is not supposed to be thrown, and its not reported by analyzer (confirmed that by running dart analyze
and got only one error which is the first one)
I tested this on 3.5.0-292.0.dev, seems this is a existing behavior.
Originally posted by @codesculpture in #55971 (comment)