Skip to content

Commit

Permalink
Limit depth by Symbols instead of TermRefs in suggestionRoots
Browse files Browse the repository at this point in the history
  • Loading branch information
mbovel committed Jan 14, 2025
1 parent 4b23ff9 commit 7dbb5eb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/typer/ImportSuggestions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ trait ImportSuggestions:
* skipped as an optimization, since they won't contain implicits anyway.
*/
private def suggestionRoots(using Context) =
val seen = mutable.Set[TermRef]()
val seen = mutable.Set[Symbol]()

def lookInside(root: Symbol)(using Context): Boolean =
explore {
Expand Down Expand Up @@ -103,10 +103,10 @@ trait ImportSuggestions:
.toList

def rootsIn(ref: TermRef)(using Context): List[TermRef] =
if seen.contains(ref) then Nil
if seen.contains(ref.termSymbol) then Nil
else
implicitsDetailed.println(i"search for suggestions in ${ref.symbol.fullName}")
seen += ref
seen += ref.termSymbol
ref :: rootsStrictlyIn(ref)

def rootsOnPath(tp: Type)(using Context): List[TermRef] = tp match
Expand Down
4 changes: 4 additions & 0 deletions tests/neg/22145c.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- [E008] Not Found Error: tests/neg/22145c.scala:2:35 -----------------------------------------------------------------
2 | def bar(base: Collection) = base.foo // error
| ^^^^^^^^
| value foo is not a member of Collection
6 changes: 6 additions & 0 deletions tests/neg/22145c.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
trait Collection:
def bar(base: Collection) = base.foo // error
object a extends Collection:
def foo: Int = 0
object b extends Collection:
def foo: Int = 1

0 comments on commit 7dbb5eb

Please sign in to comment.