You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Another day, another noclasspath bug :). For once, this bug is pretty simple. Sometimes when an unqualified type access is in the code to a type that is not on the classpath, Spoon will make the type/package explicit. The case where this messed things up for me was with static imports.
Here, SOMETHING is clearly entirely unqualified, yet it will get parsed into Constants.SOMETHING, where Constants will be explicit. This causes compile errors for me as the class Constants is not itself imported.
Remove that static import, and it instead becomes a qualified pkg.SOMETHING, which is arguably incorrect as it doesn't really make sense for accessing a constant, but if SOMETHING was a type or something like that instead then it would be correct. Perhaps we want to fix that, too, but now I'm mainly out to fix the implicitness.
As this is a SingleNameReference, any qualification attached to it should be made implicit as far as I can gather. Yet, anything that can be scrounged up from the imports is attached without abandon:
Hello!
Another day, another noclasspath bug :). For once, this bug is pretty simple. Sometimes when an unqualified type access is in the code to a type that is not on the classpath, Spoon will make the type/package explicit. The case where this messed things up for me was with static imports.
Here,
SOMETHING
is clearly entirely unqualified, yet it will get parsed intoConstants.SOMETHING
, whereConstants
will be explicit. This causes compile errors for me as the classConstants
is not itself imported.Remove that static import, and it instead becomes a qualified
pkg.SOMETHING
, which is arguably incorrect as it doesn't really make sense for accessing a constant, but ifSOMETHING
was a type or something like that instead then it would be correct. Perhaps we want to fix that, too, but now I'm mainly out to fix the implicitness.The problem lies here:
spoon/src/main/java/spoon/support/compiler/jdt/JDTTreeBuilderHelper.java
Lines 635 to 644 in 37b100a
As this is a
SingleNameReference
, any qualification attached to it should be made implicit as far as I can gather. Yet, anything that can be scrounged up from the imports is attached without abandon:spoon/src/main/java/spoon/support/compiler/jdt/JDTTreeBuilderHelper.java
Line 642 in 37b100a
I have a PR in the works, the fix seems to be as straightforward as simply making any reference found from the imports implicit.
The text was updated successfully, but these errors were encountered: