Skip to content

Commit 1a49039

Browse files
committed
Make loop in derivesFrom a tailrec loop.
1 parent 83a4f95 commit 1a49039

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,16 @@ object Types {
153153

154154
/** Is this type an instance of a non-bottom subclass of the given class `cls`? */
155155
final def derivesFrom(cls: Symbol)(implicit ctx: Context): Boolean = {
156-
def loop(tp: Type) = tp match {
156+
def loop(tp: Type): Boolean = tp match {
157157
case tp: TypeRef =>
158158
val sym = tp.symbol
159-
if (sym.isClass) sym.derivesFrom(cls) else tp.superType.derivesFrom(cls)
159+
if (sym.isClass) sym.derivesFrom(cls) else loop(tp.superType): @tailrec
160160
case tp: TypeProxy =>
161-
tp.underlying.derivesFrom(cls)
161+
loop(tp.underlying): @tailrec
162162
case tp: AndType =>
163-
tp.tp1.derivesFrom(cls) || tp.tp2.derivesFrom(cls)
163+
loop(tp.tp1) || loop(tp.tp2): @tailrec
164164
case tp: OrType =>
165-
tp.tp1.derivesFrom(cls) && tp.tp2.derivesFrom(cls)
165+
loop(tp.tp1) && loop(tp.tp2): @tailrec
166166
case tp: JavaArrayType =>
167167
cls == defn.ObjectClass
168168
case _ =>
@@ -1011,7 +1011,7 @@ object Types {
10111011
}
10121012
else NoType
10131013
case SkolemType(tp) =>
1014-
tp.lookupRefined(name)
1014+
loop(tp)
10151015
case pre: WildcardType =>
10161016
WildcardType
10171017
case pre: TypeRef =>

0 commit comments

Comments
 (0)