Skip to content

Incorrect "did you mean" in the presence of shadowed root imports #24995

@SolalPirelli

Description

@SolalPirelli

It's probably because inScopeCandidates does not faithfully copy the logic in Typer.findMember: If the import is a root import (i.e. from scala, java.lang or Predef` then it shadows the synthesized root import at the beginning of the program. That should be fixed as well (either in this PR or another one).

In current main, when we compile

import Predef.{Map as _}
val xx: Mop[Int, Int] = Mop()

we see already:

~/workspace/dotty/tests/pos-custom-args/captures> sccs ../../new/test.scala 
-- [E006] Not Found Error: ../../new/test.scala:3:8 ----------------------------
3 |val xx: Mop[Int, Int] = Mop()
  |        ^^^
  |        Not found: type Mop - did you mean Map?
  |
  | longer explanation available when compiling with `-explain`
-- [E006] Not Found Error: ../../new/test.scala:3:24 ---------------------------
3 |val xx: Mop[Int, Int] = Mop()
  |                        ^^^
  |                        Not found: Mop - did you mean Map?
  |
  | longer explanation available when compiling with `-explain`

Those "did you mean" messages are also wrong.

Originally posted by @odersky in #24959 (comment)

Metadata

Metadata

Assignees

Labels

better-errorsIssues concerned with improving confusing/unhelpful diagnostic messages

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions