@@ -460,12 +460,6 @@ object GenericSignatures {
460460 (initialSymbol.is(Method ) && initialSymbol.typeParams.contains(sym))
461461 )
462462
463- private def isTypeParameterInMethSig (sym : Symbol , initialSymbol : Symbol )(using Context ) =
464- ! sym.maybeOwner.isTypeParam &&
465- sym.isTypeParam && (
466- (initialSymbol.is(Method ) && initialSymbol.typeParams.contains(sym))
467- )
468-
469463 // @M #2585 when generating a java generic signature that includes
470464 // a selection of an inner class p.I, (p = `pre`, I = `cls`) must
471465 // rewrite to p'.I, where p' refers to the class that directly defines
@@ -549,6 +543,11 @@ object GenericSignatures {
549543
550544 /** Collect type parameters that are actually used in the given types. */
551545 private def collectUsedTypeParams (types : List [Type ], initialSymbol : Symbol )(using Context ): (Set [Name ], Set [Symbol ]) =
546+ assert(initialSymbol.is(Method ))
547+ def isTypeParameterInMethSig (sym : Symbol , initialSymbol : Symbol )(using Context ) =
548+ ! sym.maybeOwner.isTypeParam && // check if it's not higher order type param
549+ sym.isTypeParam && sym.owner == initialSymbol
550+
552551 val usedMethodTypeParamNames = collection.mutable.Set .empty[Name ]
553552 val usedClassTypeParams = collection.mutable.Set .empty[Symbol ]
554553
@@ -557,9 +556,7 @@ object GenericSignatures {
557556 usedMethodTypeParamNames += ref.paramName
558557 case tp : TypeRef =>
559558 val sym = tp.typeSymbol
560- if isTypeParameterInMethSig(sym, initialSymbol) then
561- usedMethodTypeParamNames += sym.name
562- else if sym.isTypeParam && sym.isContainedIn(initialSymbol.topLevelClass) then
559+ if sym.isTypeParam && sym.isContainedIn(initialSymbol.topLevelClass) then
563560 usedClassTypeParams += sym
564561 case _ =>
565562
0 commit comments