Skip to content

Commit f90db50

Browse files
committed
Handle & avoid recursion in traverseTp2
1 parent 76ef630 commit f90db50

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -844,17 +844,17 @@ object TypeOps:
844844
val singletons = util.HashMap[Symbol, SingletonType]()
845845
val gadtSyms = new mutable.ListBuffer[Symbol]
846846

847-
def traverse(tp: Type) = {
847+
def traverse(tp: Type) = try
848848
val tpd = tp.dealias
849849
if tpd ne tp then traverse(tpd)
850850
else tp match
851-
case tp: ThisType if !tp.tref.symbol.isStaticOwner && !singletons.contains(tp.tref.symbol) =>
851+
case tp: ThisType if !singletons.contains(tp.tref.symbol) && !tp.tref.symbol.isStaticOwner =>
852852
singletons(tp.tref.symbol) = tp
853853
traverseChildren(tp.tref)
854854
case tp: TermRef if tp.symbol.is(Param) =>
855855
singletons(tp.typeSymbol) = tp
856856
traverseChildren(tp)
857-
case tp: TypeRef if tp.symbol.isAbstractOrParamType =>
857+
case tp: TypeRef if !gadtSyms.contains(tp.symbol) && tp.symbol.isAbstractOrParamType =>
858858
gadtSyms += tp.symbol
859859
traverseChildren(tp)
860860
// traverse abstract type infos, to add any singletons
@@ -863,7 +863,7 @@ object TypeOps:
863863
traverseChildren(tp.info)
864864
case _ =>
865865
traverseChildren(tp)
866-
}
866+
catch case ex: Throwable => handleRecursive("traverseTp2", tp.show, ex)
867867
TraverseTp2.traverse(tp2)
868868
val singletons = TraverseTp2.singletons
869869
val gadtSyms = TraverseTp2.gadtSyms.toList

0 commit comments

Comments
 (0)