-
-
Notifications
You must be signed in to change notification settings - Fork 353
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
Static field access sometimes get target as CtThisAccess instead of CtTypeAccess (noclasspath) #3329
Comments
After some research, I figured out that despite being in noclasspath mode spoon still loads spoon/src/main/java/spoon/support/compiler/jdt/JDTImportBuilder.java Lines 150 to 154 in 1de9318
The thing is there is no |
Great, thanks @Egor18 @monperrus |
Hello!
I've encountered some bugs with statically accessed variables. This was the most easily reproducible one, I'll try to reproduce the other ones later.
Anyway, my problem is that sometimes when a static field is accessed from a class for which the source is not available, the target of the field read is a
CtThisAccess
instead of aCtTypeAccess
. This results in some pretty gnarly problems for me. I found this old issue discussing something similar: #346Here's an example:
Here, I expect the target of the
logger
field read to be a type access to theLauncher
type. But it's aCtThisAccess
. So if I just parse this and immediately print it, this is what I get.A this access in a static context doesn't make sense to begin with, and what makes even less sense is that the target of the
CtThisAccess
is theLauncher
type. So it's a strange cross-type this access in a static context. The problem persists in a non-static methods as well.If I add a
Launcher
class in the same file, as shown below, then it correctly resolves a type access instead of a this access.I'll have a PR with this test case up in a few minutes.
The text was updated successfully, but these errors were encountered: