@@ -18,6 +18,7 @@ import util.Positions.Position
18
18
import config .Printers .{core , typr }
19
19
import collection .mutable
20
20
import dotty .tools .dotc .config .Config
21
+ import annotation .tailrec
21
22
import java .util .NoSuchElementException
22
23
23
24
object TypeApplications {
@@ -168,31 +169,32 @@ class TypeApplications(val self: Type) extends AnyVal {
168
169
* any type parameter that is-rebound by the refinement.
169
170
*/
170
171
final def typeParams (implicit ctx : Context ): List [TypeParamInfo ] = /* >|>*/ track(" typeParams" ) /* <|<*/ {
171
- self match {
172
+ @ tailrec def recur ( tp : Type ) : List [ TypeParamInfo ] = tp match {
172
173
case self : TypeRef =>
173
174
val tsym = self.symbol
174
175
if (tsym.isClass) tsym.typeParams
175
- else if (! tsym.exists) self.info.typeParams
176
+ else if (! tsym.exists) recur( self.info)
176
177
else tsym.infoOrCompleter match {
177
178
case info : LazyType => info.completerTypeParams(tsym)
178
- case info => info.typeParams
179
+ case info => recur( info)
179
180
}
180
181
case self : AppliedType =>
181
182
if (self.tycon.typeSymbol.isClass) Nil
182
- else self.superType.typeParams
183
+ else recur( self.superType)
183
184
case self : ClassInfo =>
184
185
self.cls.typeParams
185
186
case self : HKTypeLambda =>
186
187
self.typeParams
187
188
case _ : SingletonType | _ : RefinedType | _ : RecType =>
188
189
Nil
189
190
case self : WildcardType =>
190
- self.optBounds.typeParams
191
+ recur( self.optBounds)
191
192
case self : TypeProxy =>
192
- self.superType.typeParams
193
+ recur( self.superType)
193
194
case _ =>
194
195
Nil
195
196
}
197
+ recur(self)
196
198
}
197
199
198
200
/** If `self` is a higher-kinded type, its type parameters, otherwise Nil */
0 commit comments