-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Avoid loading compilation units twice #3461
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
Avoid loading compilation units twice #3461
Conversation
81202ad
to
efbe537
Compare
37587f3
to
a05eda7
Compare
a05eda7
to
957694c
Compare
} | ||
compilationUnits | ||
// Try to load it from the class, or else if the class is not present try to load it from the object with that name |
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.
I think this comment could be improved. I would say something like:
The TASTY section in a/b/C.class may either contain a class a.b.C, an object a.b.C, or both.
We first try to load the class and fallback to loading the object if the class doesn't exist.
Note that if both the class and the object are present, then loading the class will also load the object,
this is why we useorElse
here, otherwise we could load the object twice!
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.
Done
} | ||
compilationUnits | ||
// Try to load it from the class, or else if the class is not present try to load it from the object with that name | ||
compilationUnit(className).orElse(compilationUnit(className.moduleClassName)).toList |
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.
Return type should be an Option and not a List now I guess.
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.
Done. It was only IntelliJ that complained about the Option
in the flat map.
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.
Otherwise LGTM.
For some class name foo.Foo we need to try to load the tasty from the its class. If the class is not definded, we try load it from the obeject. Previously, if both the class and the object extists we were loading the compilation unit twice. Which would duplicate symbols and then fail with duplicated symbol definitions.
957694c
to
723993e
Compare
No description provided.