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 TypeName.get() on top-level error types #646
Conversation
One thing I noticed: if there's a type that can be resolved that has type parameters, javac seems to give a TypeMirror that's simple name is I imagine that that was never supported (I don't see any way to get out of that), but maybe that means we should throw on ErrorTypes? That would be a behavioral change though, and it's not clear to me that that's what we should do. |
default: | ||
throw new IllegalArgumentException("unexpected type nesting"); | ||
Element enclosingElement = element.getEnclosingElement(); | ||
if (enclosingElement instanceof PackageElement) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any way to do this without instanceof
? My read of the docs is that a single class is allowed to implement multiple types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I changed it to use a visitor. LMK if the visitUnknown
part looks weird though.
ErrorType errorType = | ||
new DeclaredTypeAsErrorType(getTypes().getDeclaredType(getElement(Set.class))); | ||
assertThat(TypeName.get(errorType)).isEqualTo(ClassName.get(Set.class)); | ||
@Test public void errorTypes() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌮 🥙
Will release as 1.11.1. |
Awesome thanks! |
No description provided.