-
-
Notifications
You must be signed in to change notification settings - Fork 351
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
bug in printing of Implicit access to static field #913
bug in printing of Implicit access to static field #913
Conversation
Hi Martin, |
bce6f14
to
0653bdc
Compare
This solution is different. It does not try to use implicit access, but it instead forces to use qualified name in case of conflict of Class name and static field name. It has less impact on printed sources, so it is more compatible with existing tests. I see these remaining problems:
May be we can try to improve performance by replacing of CtTypeImpl.typeMembers list by a LinkedHashMap? |
The method on CtType.getDeclaredOrInheritedField would be nice, but the correct solution for the performance problem is to store set of all names of localy visible fields and methods in Printer context. Then we will resolve that list only once when we enter the scope of some class/interface and just check it whenever we need to print type access. |
getDeclaredOrInheritedField is very similar to CtTypeInformation#getAllFields(). |
merged #898.
can you rebase and measure again? |
Windows is bad system to measure performance... it does so many things on the background ... :-( #898 + this PR this PR without #898 Results:
|
} | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
} | ||
|
||
private static CtField<?> getDeclareddOrInheritedField(CtType<?> type, String fieldName) { |
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.
getDeclareddOrInheritedField -> getDeclaredOrInheritedField (double dd)
We agree to move it to CtType.
We must also handle fields from interfaces.
I just noticed there is new comment...
I agree |
You can keep getDeclareddOrInheritedField is long but it is explicit |
Do you agree that interface CtTypeReference {
CtFieldReference<?> getField(name);
CtFieldReference<?> getDeclaredOrInheritedField(name);
} because if we would ignore such fields, then bug #913 would be still reproducible on classes inherited from classes which are not part of the model. |
--Martin |
82496ed
to
62f7174
Compare
My latest changes fails because of bug #959. After this bug is fixed, then it should pass the tests too. |
62f7174
to
7b76054
Compare
It now performs well. It is back on 10s. The I am not using new method May be the new It still fails on bug #959 |
This is a bug, would you propose a PR? Thanks. |
Yes, you can remove it from here. However, I like the idea, we could you move it to another PR. |
e2162b0
to
b16ba96
Compare
The getDeclaredOrInheritedField is moved to #967 I had to fix |
Looks like might be merged after bug #959 is fixed |
According to @tdurieux 's comment, the only solution seems to be to make a minimal change to |
Unfortunately we cannot change testSpoonWithImports it tests some tricky access path in java. The solution is not removing the difficulties. |
b16ba96
to
d232f5a
Compare
your last commit makes sense. I would propose to also change |
OK, I did not know before, that "access path" is used to reference super type. But may be I have now an idea, how to fix that without need of deeper change of spoon model. |
issue or PR is perfect (PR is even better, you can start one with an |
Thanks for the tip with |
thanks a lot for this long and hard PR! |
You are welcome! |
Added test to reproduce bug in printing of Implicit access to static field