Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vm/ffi] Deprecate Pointer.cast()? #56214

Open
dcharkes opened this issue Jul 9, 2024 · 2 comments
Open

[vm/ffi] Deprecate Pointer.cast()? #56214

dcharkes opened this issue Jul 9, 2024 · 2 comments
Assignees
Labels
area-native-interop Used for native interop related issues, including FFI. library-ffi P3 A lower priority bug or feature request

Comments

@dcharkes
Copy link
Contributor

dcharkes commented Jul 9, 2024

Now that we no longer reify the type arguments of Pointer

we should consider whether .cast() can be replaced by simply as checks.

Currently, the runtime still have a type arguments vector at runtime

So if we use a normal cast, we could accidentally introduce runtime type checks if the compiler can't figure out that pointers are always instantiated with Never as type argument.

Conceptually speaking Pointer<T> should maybe be an extension type on PointerNever (now that we stopped reifying the type argument). But, we've introduced Pointers before extension types were added to Dart. Its probably not possible to now change Pointer to an extension type. 😄

Thanks @HosseinYousefi for the suggestion!

@dcharkes dcharkes added P3 A lower priority bug or feature request library-ffi area-native-interop Used for native interop related issues, including FFI. labels Jul 9, 2024
@dcharkes dcharkes changed the title [vm/ffi] Deprecate cast()? [vm/ffi] Deprecate Pointer.cast()? Jul 9, 2024
@HosseinYousefi
Copy link
Member

Its probably not possible to now change Pointer to an extension type.

  • Pointer is a final class so nothing can extend or implement it
  • Checking is Pointer<T> already returns true for all pointers
  • runtimeType.toString() would be "PointerNever" instead of "Pointer<Never>" but I don't think people should depend on that to begin with.

So maybe this change won't be breaking afterall!

@dcharkes
Copy link
Contributor Author

dcharkes commented Jul 9, 2024

If you want to get your hands dirty, feel free to give it a spin in the Dart SDK! 😄

@HosseinYousefi HosseinYousefi self-assigned this Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-native-interop Used for native interop related issues, including FFI. library-ffi P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

2 participants