Skip to content

Commit

Permalink
Handle recursion in collectParts
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Jul 15, 2023
1 parent ca19b46 commit b65f689
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ trait ImplicitRunInfo:
private var parts: mutable.LinkedHashSet[Type] = _
private val partSeen = util.HashSet[Type]()

def traverse(t: Type) =
def traverse(t: Type) = try
if partSeen.contains(t) then ()
else if implicitScopeCache.contains(t) then parts += t
else
Expand Down Expand Up @@ -643,6 +643,7 @@ trait ImplicitRunInfo:
traverse(mt)
case t =>
traverseChildren(t)
catch case ex: Throwable => handleRecursive("collectParts of", t.show, ex)

def apply(tp: Type): collection.Set[Type] =
parts = mutable.LinkedHashSet()
Expand Down
10 changes: 10 additions & 0 deletions tests/neg/i18171.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
type BAZ[T] = T match
case Any => DFVal[BAZREC[T]]

type BAZREC[T] = T match
case NonEmptyTuple => Tuple.Map[T, BAZ]

trait DFVal[T]

def foo(relIdx: BAZ[Any]): Unit =
relIdx.bar // error

0 comments on commit b65f689

Please sign in to comment.