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

refactor: throw informative exception when sniper printing cannot be done #3764

Merged

Conversation

slarse
Copy link
Collaborator

@slarse slarse commented Jan 21, 2021

Fix #3760

See #3760 for a description of the problem. I think it's more work than it's worth to try to allow for sniper printing of a subset of a compilation unit's types. There's an initial problem in that DJPP clones the CU if it discovers that one is trying to print only a subset of the types (this is where the current crash described in #3760 comes from). Even working around that, there's still a bit of trickery involved in printing just a subset of the types. A couple more hours on this and I could probably solve it, but I just don't think it's worth it.

This PR just throws a more informative exception that looks like this:

java.lang.IllegalArgumentException: Can only sniper print exactly all declared types of the compilation unit. Given types: [MultipleTopLevelTypes]. Declared types: [OtherTopLevelType, MultipleTopLevelTypes, TopLevelInterface]

I'm not quite sure if "fix" is the correct label for this PR, feel free to re-label.

@slarse slarse changed the title wip: Throw more informative exception on sniper printing subset of a CU's types review: fix: Throw more informative exception on sniper printing subset of a CU's types Jan 21, 2021
@monperrus
Copy link
Collaborator

LGTM. Will merge.

@slarse
Copy link
Collaborator Author

slarse commented Jan 26, 2021

@monperrus Ping for merge? :)

@monperrus monperrus changed the title review: fix: Throw more informative exception on sniper printing subset of a CU's types refactor: throw informative exception when sniper printing cannot be done Jan 26, 2021
@monperrus monperrus merged commit 2ce73b8 into INRIA:master Jan 26, 2021
@monperrus
Copy link
Collaborator

Thanks Simon. Good informative exceptions are essential for a good user experience.

@slarse slarse deleted the issue/3760-sniper-print-subset-of-cu-types branch May 28, 2021 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Sniper printer crashes when trying to print subset of top-level types in compilation unit
2 participants