Skip to content

Commit b65f689

Browse files
committed
Handle recursion in collectParts
1 parent ca19b46 commit b65f689

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ trait ImplicitRunInfo:
604604
private var parts: mutable.LinkedHashSet[Type] = _
605605
private val partSeen = util.HashSet[Type]()
606606

607-
def traverse(t: Type) =
607+
def traverse(t: Type) = try
608608
if partSeen.contains(t) then ()
609609
else if implicitScopeCache.contains(t) then parts += t
610610
else
@@ -643,6 +643,7 @@ trait ImplicitRunInfo:
643643
traverse(mt)
644644
case t =>
645645
traverseChildren(t)
646+
catch case ex: Throwable => handleRecursive("collectParts of", t.show, ex)
646647

647648
def apply(tp: Type): collection.Set[Type] =
648649
parts = mutable.LinkedHashSet()

tests/neg/i18171.scala

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
type BAZ[T] = T match
2+
case Any => DFVal[BAZREC[T]]
3+
4+
type BAZREC[T] = T match
5+
case NonEmptyTuple => Tuple.Map[T, BAZ]
6+
7+
trait DFVal[T]
8+
9+
def foo(relIdx: BAZ[Any]): Unit =
10+
relIdx.bar // error

0 commit comments

Comments
 (0)