Skip to content

Commit 7dbb5eb

Browse files
committed
Limit depth by Symbols instead of TermRefs in suggestionRoots
1 parent 4b23ff9 commit 7dbb5eb

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

compiler/src/dotty/tools/dotc/typer/ImportSuggestions.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ trait ImportSuggestions:
5757
* skipped as an optimization, since they won't contain implicits anyway.
5858
*/
5959
private def suggestionRoots(using Context) =
60-
val seen = mutable.Set[TermRef]()
60+
val seen = mutable.Set[Symbol]()
6161

6262
def lookInside(root: Symbol)(using Context): Boolean =
6363
explore {
@@ -103,10 +103,10 @@ trait ImportSuggestions:
103103
.toList
104104

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

112112
def rootsOnPath(tp: Type)(using Context): List[TermRef] = tp match

tests/neg/22145c.check

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- [E008] Not Found Error: tests/neg/22145c.scala:2:35 -----------------------------------------------------------------
2+
2 | def bar(base: Collection) = base.foo // error
3+
| ^^^^^^^^
4+
| value foo is not a member of Collection

tests/neg/22145c.scala

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
trait Collection:
2+
def bar(base: Collection) = base.foo // error
3+
object a extends Collection:
4+
def foo: Int = 0
5+
object b extends Collection:
6+
def foo: Int = 1

0 commit comments

Comments
 (0)