-
-
Notifications
You must be signed in to change notification settings - Fork 352
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 a number of bugs related to handling of unnamed packages #705
Conversation
…revious version of this method does something nonsense and never works.
very interesting PR! can you add failing assertions that demonstrate the bug? |
I don't understand why tests are so unstable. Why they pass locally and fail in CI. Local results from-ide and from console via mvn test are also different. |
I maybe because your pull request does not contains all modification present in master. |
I pull our branch and got same errors than Travis, Jenkins or Appveyor. PR on your PR done here: leventov#5 |
@GerardPaligot please wait for a minute. I will try to put everything together. |
…t TypeReference-building factory methods return references with unnamed package rather than null package and null declaring type, to preserve invariant that either ref.getPackage() or ref.getDeclaringType() is not null, unless the type reference represent a primitive type class or void.class
@monperrus for unnamed package issues it would be difficult for me. For java.lang importing issues, demonstrating case is easy: declare a class clashing with some class in java.lang, i. e. com.mycompany.String, and use it from another class. It should stay fully-qualified when pretty-printed. Before this PR spoon imports it and uses unqualifed, and output is not compilable because java compiler doesn't know which class to use, com.mycompany.String or java.lang.String. |
if (importsContext.isImported(ref)) { | ||
// If java.lang.Something is imported, but we are in the context of a class which is | ||
// also called "Something", we should still use qualified version java.lang.Something | ||
if (ref.getPackage() != null && ref.getPackage().getSimpleName().equals("java.lang")) { |
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.
As an afterthought, this shouldn't probably be restricted with java.lang, but for any imported classes.
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.
what do you mean?
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.
Probably this should be checked for all classes, i. e. in terms of code, just remove ref.getPackage().getSimpleName().equals("java.lang")
condition
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.
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.
ok
Thanks. @GerardPaligot if you're also OK, do you merge? |
Thanks for this contribution @leventov! |
No description provided.