Skip to content

Commit d17da7a

Browse files
committed
Simplify hasPrecisePrefix check
`NoPrefix.isStable` already returns true.
1 parent c8efe69 commit d17da7a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,26 +284,26 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
284284
given Context = ctx // optimization for performance
285285
val info2 = tp2.info
286286

287-
/** Does `tp2` have a stable prefix or NoPrefix as a prefix?
287+
/** Does `tp2` have a stable prefix?
288288
* If that's not the case, following an alias via asSeenFrom could be lossy
289289
* so we should not conclude `false` if comparing aliases fails.
290290
* See pos/i17064.scala for a test case
291291
*/
292-
def hasPrecisePrefix(tp: NamedType) =
293-
tp.prefix.isStable || tp.prefix == NoPrefix
292+
def hasStablePrefix(tp: NamedType) =
293+
tp.prefix.isStable
294294

295295
info2 match
296296
case info2: TypeAlias =>
297297
if recur(tp1, info2.alias) then return true
298-
if tp2.asInstanceOf[TypeRef].canDropAlias && hasPrecisePrefix(tp2) then
298+
if tp2.asInstanceOf[TypeRef].canDropAlias && hasStablePrefix(tp2) then
299299
return false
300300
case _ =>
301301
tp1 match
302302
case tp1: NamedType =>
303303
tp1.info match {
304304
case info1: TypeAlias =>
305305
if recur(info1.alias, tp2) then return true
306-
if tp1.asInstanceOf[TypeRef].canDropAlias && hasPrecisePrefix(tp2) then
306+
if tp1.asInstanceOf[TypeRef].canDropAlias && hasStablePrefix(tp2) then
307307
return false
308308
case _ =>
309309
}

0 commit comments

Comments
 (0)