@@ -551,22 +551,19 @@ 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)
568554
569- types.foreach(collector.traverse)
555+ def collect (tp : Type ): Unit = tp.foreachPart:
556+ case ref @ TypeParamRef (_ : PolyType , _) =>
557+ usedMethodTypeParamNames += ref.paramName
558+ case tp : TypeRef =>
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+ case _ =>
565+
566+ types.foreach(collect)
570567 (usedMethodTypeParamNames.toSet, usedClassTypeParams.toSet)
571568 end collectUsedTypeParams
572569}
0 commit comments