Skip to content
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

REPL: Import shadowing issue #5074

Open
allanrenucci opened this issue Sep 3, 2018 · 1 comment
Open

REPL: Import shadowing issue #5074

allanrenucci opened this issue Sep 3, 2018 · 1 comment

Comments

@allanrenucci
Copy link
Contributor

scala> object A { def f = 1 }                                                                                                                                                                                   
// defined object A

scala> import A._; def f = 2
def f: Int

scala> f                                                                                                                                                                                                        
val res0: Int = 1 // should be 2
@allanrenucci
Copy link
Contributor Author

This has to do with the way we handle user defined imports and wrap expression in an object:

When we evaluate an expression, we need to imports previously evaluated expressions:
https://github.com/lampepfl/dotty/blob/86c4e72e3a87aae12c57e2c887231b77717438a3/compiler/src/dotty/tools/repl/ReplCompiler.scala#L50-L66

We first import the wrapper object and then the user defined imports in it. So a user defined import might shadow a definition even if the import precedes the definition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant