@@ -551,22 +551,18 @@ object GenericSignatures {
551551 private def collectUsedTypeParams (types : List [Type ], initialSymbol : Symbol )(using Context ): (Set [Name ], Set [Symbol ]) =
552552 val usedMethodTypeParamNames = collection.mutable.Set .empty[Name ]
553553 val usedClassTypeParams = collection.mutable.Set .empty[Symbol ]
554- val collector = new TypeTraverser :
555- def traverse (tp : Type ) = tp.dealias match
556- case ref @ TypeParamRef (_ : PolyType , _) =>
557- usedMethodTypeParamNames += ref.paramName
558- case TypeRef (pre, _) =>
559- val sym = tp.typeSymbol
560- if isTypeParameterInMethSig(sym, initialSymbol) then
561- usedMethodTypeParamNames += sym.name
562- else if sym.isTypeParam && sym.isContainedIn(initialSymbol.topLevelClass) then
563- usedClassTypeParams += sym
564- else
565- traverse(pre)
566- case _ =>
567- traverseChildren(tp)
554+ def collector (tp : Type ): Unit = tp.foreachPart:
555+ case ref@ TypeParamRef (_ : PolyType , _) =>
556+ usedMethodTypeParamNames += ref.paramName
557+ case TypeRef (pre, _) =>
558+ val sym = tp.typeSymbol
559+ if isTypeParameterInMethSig(sym, initialSymbol) then
560+ usedMethodTypeParamNames += sym.name
561+ else if sym.isTypeParam && sym.isContainedIn(initialSymbol.topLevelClass) then
562+ usedClassTypeParams += sym
563+ case _ =>
568564
569- types.foreach(collector.traverse )
565+ types.foreach(collector)
570566 (usedMethodTypeParamNames.toSet, usedClassTypeParams.toSet)
571567 end collectUsedTypeParams
572568}
0 commit comments