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

fix(3984): Retain simply qualified name of throwable type #555

Merged

Conversation

slarse
Copy link
Collaborator

@slarse slarse commented Jun 2, 2021

Fix #554

This PR fixes a problem where the UnusedThrowableProcessor always creates a fully qualified name for the throwable, even when a simply qualified name is used initially. I.e. the repair looks like so:

-new IllegalArgumentException();
+throw new java.lang.IllegalArgumentException();

With this fix, the repair looks as intended:

-new IllegalArgumentException();
+throw new IllegalArgumentException();

In doing the exact match test to check that the printed reference is indeed simply qualified, I also discovered that comments on the thrown expression must be moved to the CtThrow, otherwise they are printed like this before the semicolon:

throw new IllegalArgumentException()// here's a comment
;

And that just looks very strange.

@fermadeiral
Copy link
Collaborator

Nice fix, thank you @slarse.

@fermadeiral fermadeiral merged commit f3a3225 into master Jun 2, 2021
@fermadeiral fermadeiral deleted the issue/554-UnusedThrowableProcessor-qualified-name branch June 2, 2021 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

UnusedThrowableProcessor creates fully qualified reference
2 participants