Skip to content

ambiguous references which aren't #3836

Closed
@scabug

Description

@scabug

I have pervasively utilized the import noise reduction available when one defines type aliases in a package object:

  type IOException    = java.io.IOException
  type InputStream    = java.io.InputStream

Unfortunately this interacts needlessly poorly with the rest of the world. One adds a seemingly compilable file from elsewhere to find:

[error] file.scala:44: reference to InputStream is ambiguous;
[error] it is both defined in trait Foo and imported subsequently by 
[error] import java.io.{InputStream, OutputStream}

scalac is perfectly well aware that these normalize to the same type. I have no problem with this being an error if they are not the same type, but this one is purely spurious, and it really hamstrings the otherwise boundless joy of aliasing commonly used types into one's package.

Addendum: it is particularly intrusive because even wildcard imports incur an ambiguity error, so for instance:

  // package wide
  type Settings = scala.tools.nsc.Settings
  // some new file
  import scala.tools.nsc._
  // and... error.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions