-
-
Notifications
You must be signed in to change notification settings - Fork 638
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
Add T[] Value.toJavaArray(T[])
#1582
Comments
Because of erasure I don't think it's possible to make this completely type-safe.
Doing it the @SuppressWarnings("unchecked")
Option<Integer>[] options = singletonList(Option.some(1)).toArray(new Option[0]);
System.out.println(options[0].get()); i.e you cannot call |
@paplorinc you are right - it makes no sense to have If an application of For now, we will not implement the unsafe case, I don't see the urge to do it. We have many other things to do. |
Unfortunately that's not true either: Array.of(1).toJavaArray(int.class); errs at run time with:
I still think the |
I'm not sure. Is it possible to fix our variant, e.g. by first checking I will play around a bit. Safety first. |
and throw a different kind of
I agree, but I don't think it's possible, because of type erasure, it's inherently unsafe :/ |
See #1585 |
(See #1578)
These are our options:
I think the first, unsafe variant is no viable solution.
Example:
The existing method
toJavaArray(Class<T>)
is still useful for non-generic types,we do not need to deprecate it.
The text was updated successfully, but these errors were encountered: