- Notifications
You must be signed in to change notification settings - Fork1.2k
Add @SafeVarargs to findAncestor()#4632
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
bannmann commentedDec 7, 2024
- This avoids unchecked warnings at call sites.
- Seehttps://docs.oracle.com/javase/specs/jls/se21/html/jls-9.html#jls-9.6.4.7 for details.
- This avoids unchecked warnings at call sites.- Seehttps://docs.oracle.com/javase/specs/jls/se21/html/jls-9.html#jls-9.6.4.7 for details.
For information, JP is currently compiled in Java 8. |
Hm, it turns out Alternatively, one might add an overload that accepts a single ancestor class. That overload would not suffer from this problem. Come to think of it, having that overload might be a good idea anyway - the current Other APIs tackle this by having non-vararg overloads that combine a fixed argument with varargs. So instead of
When passing a single argument, the Java compiler would then prefer the first version, and use the second if there are more types. Most importantly, |
Oh, I didn't know that. Anyway, |