Reimplement Return Value Warning #6
Labels
No Label
1
13
2
21
3
34
5
55
8
bug
core
could have
duplicate
enhancement
help wanted
must have
proc
question
should have
wont have
L
M
S
XL
bug
bugfix
discussion
documentation
feature
maintenance
postponed
refactoring
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: zdm/event-bus#6
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
While I understand not throwing a RuntimeException when a non-void return type has been supplied,
I'd argue that it is still useful to supply a warning in the Annotation Processor, as this return value will not be usable anyhow.
That's a good idea, however we have to find a way of suppressing the warning if a non-void return type actually has to be used, for example when retrofitting code to utilize event handling.
The problem with that is: If you really want to, you can return a
List<?>
(because you can have multiple listeners to the same event) but that seems not useful at all. I think it's much more useful to dissolve the return value silently.Agreed, but how would you go about suppressing the warning? Define a custom warning string to use in
@SuppressWarnings
, or just introduce parameters for the processor? I will have a look into that.If it is possible to add a custom warning for
SuppressWarnings
I'd prefer thatOh, I guess in that case you "simply" have to check whether the SuppressWarnings annotation is present and contains the value
unused-return
or something similar.The question is if there is a method to let Eclipse handle this for you…
The check is not the problem. The problem is, that Eclipse and probably other compilers as well would warn the user about the unhandled warning token, which would leave the user with yet another warning.
There isn't much information about that online, apart from this ancient Eclipse bug that doesn't appear to be solved.
I will try implementing this and get back to you with the results.
I have implemented it and it behaves exactly as I thought:
I can detect the
@SuppressWarnings("unused-return")
on the method and thus hide the warning, but simultaneously get an "Unsupported@SuppressWarnings("unused-return")
" from my compiler.A solution to this would be to change the problem severity on the compiler warnings, but that obviously affects more than just that specific annotation.
The
@SuppressWarnings
thing isn't easily solvable as of yet, so any user that wants to remove the warning should just suppress it from their IDE.