Skip to content

Named import shadows underscore value import #2212

@olafurpg

Description

@olafurpg

I am not sure if this is a bug or intentional behavior. I bumped into this while compiling squants with Dotty.

The following snippet compiles with scalac but not Dotty

package object squants {
  type Time = squants.time.Time
}
package squants.time {
  class Time
  object Time { def x = 2 }
}
package squants.velocity {
  import squants.Time // <-- imports  type alias
  import squants.time._  // <-- imports `Time` value
  object Velocity { Time.x }
}

Dotty reports "E008 member not found":

-- [E008] Member Not Found Error: package.scala --------------------------------
11 |  object Velocity { Time.x }
   |                    ^^^^
   |value `Time` is not a member of squants.type - did you mean `squants.time`?

one error found

It seems that the import on the Time type alias shadows the underscore import on the Time companion object. Commenting out import squants.Time (import on type alias) removes the error.

Commit to reproduce issue in the dotty repo: 2487e78

FWIW, the Dotty behavior feels somewhat more intuitive to me since named imports have a higher precedence.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions