Skip to content

Adopt scala's scheme for root import hiding #1901

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

Merged
merged 1 commit into from
Jan 16, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jan 15, 2017

scalac hides a root import from Predef if there is an explicit Predef import.
We now do the same (previously we did this only if the overriding import undefined
something, using a x => _ syntax). To avoid cycles and races one had to be very careful
not to force import symbols too early, so we now compare the name before the symbol proper.

All this is likely temporary - the comment of ImportInfo#unimported points to a different,
more systematic solution.

Note: The difference in semantics showed up and caused problems for the current collection strawman.

scalac hides a root import from Predef if there is an eplicit Predef import.
We now do the same (previously we did this only if the overriding import undefined
something, using a `x => _` syntax). To avoid cycles and races one had to be very careful
not to force import symbols too early, so we now compare the name before the symbol proper.

All this is likely temporary - the comment of ImportInfo#unimported points to a different,
more systematic solution.
Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

*/
class ImportInfo(symf: => Symbol, val selectors: List[untpd.Tree], val isRootImport: Boolean = false)(implicit ctx: Context) {
class ImportInfo(symf: => Symbol, val selectors: List[untpd.Tree],
symNameOpt: Option[TermName], val isRootImport: Boolean = false)(implicit ctx: Context) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could put a if (isRootImport) assert(symNameOpt.isEmpty) here to enforce what the documentation says.

@odersky odersky merged commit eed4f2f into scala:master Jan 16, 2017
@allanrenucci allanrenucci deleted the change-predef-import branch December 14, 2017 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants