-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Named import shadows underscore value import #2212
Comments
This doesn't answer your question, but it seems like the package object for squants should also alias the object, not just the class: package object squants {
type Time = squants.time.Time
val Time = squants.time.Time
} |
Regarding the example, I notice that although |
Here is another example that I'm not sure is related but also involves types and values being imported separately import scala.math.BigDecimal.RoundingMode
import scala.math.BigDecimal.RoundingMode.RoundingMode
object Money {
def foo(round: RoundingMode = RoundingMode.HALF_EVEN): Int = ???
} Dotty reports the following errors -- [E008] Member Not Found Error: RoundingMode.scala ---------------------------
6 | def foo(round: RoundingMode = RoundingMode.HALF_EVEN): Int = ???
| ^^^^^^^^^^^^
|type `RoundingMode` is not a member of math.BigDecimal.type - did you mean `BigDecimal.RoundingMode`?
-- [E008] Member Not Found Error: RoundingMode.scala ---------------------------
6 | def foo(round: RoundingMode = RoundingMode.HALF_EVEN): Int = ???
| ^^^^^^^^^^^^
|value `RoundingMode` is not a member of math.BigDecimal.RoundingMode.type - did you mean `RoundingMode.RoundingMode`?
two errors found while scalac compiles OK. I can open a separate ticket, but thought I might add it here first to see if it's a duplicate. |
- Rewrite `apply = parse _` to `apply(x: Any) = parse(x)` - remove import on type alias that shadowed import on value, caused by scala/scala3#2212
Reported here: scala/scala3#2212 (comment)
Don't issue an error if when considering a named import that refers to a valoe or type which does not exist. Instead, disregard the import an continue.
Fix #2212: Avoid imports in the wrong namespace
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
Dotty reports "E008 member not found":
It seems that the import on the
Time
type alias shadows the underscore import on theTime
companion object. Commenting outimport 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.
The text was updated successfully, but these errors were encountered: