-
Notifications
You must be signed in to change notification settings - Fork 139
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
Incorrect unused import warning #1809
Conversation
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.
@srikanth-sankaran i understand your comment #1808 (comment) that the added test should fail. |
Fixes eclipse-jdt#1808 The issue happens for imports used in the permits clause when that import is - declared as a nested class - is used only in a permits clause The fix checks if member types are imported and marks the import as used. Signed-off-by: Snjezana Peco <[email protected]>
CopyMoveElementsTests.testCopyConstructorInDifferentProject passes locally. |
I'll take a look at this post 4.31 - this is too late for 4.31 anyway and I am also hard pressed for time right now. OK? |
Hello! This fix may work but does not look correct to me. What I mean by that is: I am first of all surprised that there is a new method I would expect existing code that handles import declarations and "serves" types should handle this - if it doesn't then the question is why not - I believe it is very likely permits clause is processed either in the wrong phase/time or in the wrong environment - In the "right solution", things should automatically "just work" - A sketch of the right solution would not call When permits clause is resolved we are outside the class declaration in the class header - the member types are not in scope - so we should not be calling |
The type should be "served" by the import and so the import should be seen to used - what the present PR is doing is the opposite of it - the type is served by scope (member type) and then we set the used bit on the import. The import should be first of all seen to be necessary to resolve/materialize the type. Not have a type and then set the import's used bit. Am I being clear ? :) Please let me know if this is urgently required - if not if you can wait till M3, I can work on it then, If it is super urgent I can try and squeeze in some time sooner. |
Also the changes in
because we fail to find B and not because we find B and then check the imports and not find it there! Finally, see that this code:
compiles on master and on javac but fails to compile with the patch because the new code in |
I suggest you debug this program:
to see what I mean by a type is served by an import. You see a warning on ArrayList import and not List import. Studying why would tell you how types are served by imports and how imports are seen to be used or not used. |
I have pushed a different fix. This PR may be closed without further action |
This PR is superseded by #2608 |
Fixes #1808
The issue happens for imports used in the permits clause when that import is