Skip to content

Replace should unimport replaced symbol instead of shadow #376

Open
@olafurpg

Description

@olafurpg

Reported by @xeno-by , the current scheme of inserting a named import and leaving wildcard imports unchanged can produce ambiguous imports, even if named imports have higher precedence

scala> object X { class C }
defined object X

scala> object Y { class C }
defined object Y

scala> locally { import X._; import Y.C; new C }
res0: Y.C = Y$C@5ac646b3

scala> locally { import Y.C; locally { import X._; new C } }
<console>:38: error: reference to C is ambiguous;
it is imported twice in the same scope by
import X._
and import Y.C
       locally { import Y.C; locally { import X._; new C } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions