Skip to content

Inconsistent handling of shadowed imported name #8121

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

Closed
scabug opened this issue Jan 7, 2014 · 2 comments · Fixed by scala/scala#8753
Closed

Inconsistent handling of shadowed imported name #8121

scabug opened this issue Jan 7, 2014 · 2 comments · Fixed by scala/scala#8753
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Jan 7, 2014

Create the following source files:

A.scala:
package a
object Foo

B.scala:
package b
import a.Foo
class Foo

Then run

scalac -d ./classes A.scala B.scala

The compilation succeeds.

But if I compile A and B separately:

scalac -d ./classes1 A.scala
scalac -d ./classes2 -cp ./classes1 B.scala

I get "warning: imported `Foo' is permanently hidden by definition of class Foo in package b".

I also get this error if I replace "object Foo" with "class Foo" in A.scala.

I guess this is supposed to succeed, since objects are values, not types, and so live in a different namespaces? But in that case it should also succeed when the files are compiled separately.

@scabug
Copy link
Author

scabug commented Jan 7, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8121?orig=1
Reporter: Benjy Weinberger (benjyw)
Affected Versions: 2.10.2

@scabug
Copy link
Author

scabug commented Jan 8, 2014

@som-snytt said:
This is probably obvious to those who have looked at separate compilation, but under separate compilation you see the companion class a.Foo with static forwarders; that is the basis for the warning. I'm not sure about the use case where there is nothing to forward.

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

Successfully merging a pull request may close this issue.

3 participants