Skip to content

Commit db4ab67

Browse files
authored
Backport "Handle recursion in collectParts" to LTS (#19116)
Backports #18214 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents 66f8992 + 69032ea commit db4ab67

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
@@ -606,7 +606,7 @@ trait ImplicitRunInfo:
606606
private var parts: mutable.LinkedHashSet[Type] = _
607607
private val partSeen = util.HashSet[Type]()
608608

609-
def traverse(t: Type) =
609+
def traverse(t: Type) = try
610610
if partSeen.contains(t) then ()
611611
else if implicitScopeCache.contains(t) then parts += t
612612
else
@@ -638,6 +638,7 @@ trait ImplicitRunInfo:
638638
traverseChildren(t)
639639
case t =>
640640
traverseChildren(t)
641+
catch case ex: Throwable => handleRecursive("collectParts of", t.show, ex)
641642

642643
def apply(tp: Type): collection.Set[Type] =
643644
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)