-
Notifications
You must be signed in to change notification settings - Fork 322
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
Refactor import resolver to allow for dynamic loading of modules. #1822
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.
Looks good to me.
I think error handling of failed module load should be more granular as indicated below, but I guess that can be further extended in future PRs.
Maybe this PR could at least change the return type of ensurePackageIsLoaded
into an Either[PackageLoadingError, Unit]
with only one variant defined for PackageLoadingError
which can then be later extended.
public List<Package<TruffleFile>> getPackages() { | ||
return packages; | ||
} |
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'd suggest renaming to getPreloadedPackages
or something like that and indicating in the doc comment that this will be removed in the next iteration. Just to avoid someone using it in a wrong place by mistake.
* @return `true` if the package was already loaded or successfully | ||
* downloaded. `false` otherwise. | ||
*/ | ||
def ensurePackageIsLoaded(namespace: String, name: String): Boolean |
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 would suggest extending this signature a bit, although I guess it is ok if it happens in future PRs.
I think we should here somehow differentiate various kinds of errors - for display purposes there should be a different error saying "package is not defined in the edition that you are using" versus "package could not be downloaded due to network problems" or "could not load the package due to insufficient filesystem permissions", as these are completely different error, so thay cannot be merged into a single false
return value.
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.
Fair!
After having a second look at the spec I have some doubts if everything is done - technically I guess all features are there, but I think there are things that could be done in this PR instead of the next one. For example, the I'm also not sure if we should keep |
@radeusgd honestly this is just an unblocker for "things in compiler use this, it is obvious where it should be replaced in case the API changes", such that further changes to the packaging logic don't need to propagate far into the compiler. Regarding moving the preloading logic into package repo – I decided against it on the basis of "what's the point moving code that will be removed by the next task?". There will be no preloading, so this whole logic will be removed. Regarding "module access should be mediated through the package repo" – interesting thought, it does have some problems, but may be more elegant. I'll think about it. |
Fair
That was my initial idea, I think that it reduces the chance of erroneously forgetting to call |
Pull Request Description
Fixes #1569
Closes #1768
Important Notes
Checklist
Please include the following checklist in your PR: