Skip to content

Inconsistent handling of shadowed imported name #8121

Closed
scala/scala
#8753
@scabug

Description

@scabug

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions