Skip to content

Commit

Permalink
Handle & avoid recursion in traverseTp2
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Dec 13, 2023
1 parent 76ef630 commit f90db50
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -844,17 +844,17 @@ object TypeOps:
val singletons = util.HashMap[Symbol, SingletonType]()
val gadtSyms = new mutable.ListBuffer[Symbol]

def traverse(tp: Type) = {
def traverse(tp: Type) = try
val tpd = tp.dealias
if tpd ne tp then traverse(tpd)
else tp match
case tp: ThisType if !tp.tref.symbol.isStaticOwner && !singletons.contains(tp.tref.symbol) =>
case tp: ThisType if !singletons.contains(tp.tref.symbol) && !tp.tref.symbol.isStaticOwner =>
singletons(tp.tref.symbol) = tp
traverseChildren(tp.tref)
case tp: TermRef if tp.symbol.is(Param) =>
singletons(tp.typeSymbol) = tp
traverseChildren(tp)
case tp: TypeRef if tp.symbol.isAbstractOrParamType =>
case tp: TypeRef if !gadtSyms.contains(tp.symbol) && tp.symbol.isAbstractOrParamType =>
gadtSyms += tp.symbol
traverseChildren(tp)
// traverse abstract type infos, to add any singletons
Expand All @@ -863,7 +863,7 @@ object TypeOps:
traverseChildren(tp.info)
case _ =>
traverseChildren(tp)
}
catch case ex: Throwable => handleRecursive("traverseTp2", tp.show, ex)
TraverseTp2.traverse(tp2)
val singletons = TraverseTp2.singletons
val gadtSyms = TraverseTp2.gadtSyms.toList
Expand Down

0 comments on commit f90db50

Please sign in to comment.