-
Notifications
You must be signed in to change notification settings - Fork 21
REPL doesn't compute import renames correctly #7953
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
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7953?orig=1 |
@paulp said: Having tried, I'll tell you it's harder than it looks to incrementally improve on the current approach, because it's tricky to be sure you can omit an import entirely. Wildcard imports with lower scope, implicits, renames, and then there is the little feature where a name might be shadowed in only one namespace, like this: object Foo {
class Bar
object Bar
}
object Quux {
class Bar
}
object Test {
import Foo.Bar
def main(args: Array[String]): Unit = {
import Quux.Bar
new Bar
Bar
}
} |
Li Haoyi (lihaoyi) said: @ object Foo { def bar = 7 }
defined object Foo
@ object Junk { val x = 7 }
defined object Junk
@ import Foo.{ bar => baz }
import Foo.{ bar => baz }
@ import Junk.{x=>baz}
import import Junk.{x=>baz}
@ baz
res24: Int = 7
@ object Foo { def bar = 7 }
defined object Foo
@ object Junk { val x = 8 }
defined object Junk
@ import Foo.{ bar => baz }
import Foo.{ bar => baz }
@ import Junk.{x=>baz}
import Junk.{x=>baz}
@ baz
res29: Int = 8
@ |
@paulp said: |
Closing as duplicate of linked ticket which fixed it. Hashtag fixit ticket. |
Imports have a source name and the name (possibly a rename) to bring into scope. The algo in REPL to decide what to import is tripped up by the import handler not distinguishing them correctly. In the sample, normally it would bump the first import to an outer scope (and let normal shadowing effectively eliminate it). (Open question whether that inefficiency has any benefit; it doesn't try to nuance anything.)
The text was updated successfully, but these errors were encountered: