Skip to content

Commit

Permalink
Simplify hasPrecisePrefix check
Browse files Browse the repository at this point in the history
`NoPrefix.isStable` already returns true.
  • Loading branch information
smarter committed Mar 25, 2023
1 parent c8efe69 commit d17da7a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -284,26 +284,26 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
given Context = ctx // optimization for performance
val info2 = tp2.info

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

info2 match
case info2: TypeAlias =>
if recur(tp1, info2.alias) then return true
if tp2.asInstanceOf[TypeRef].canDropAlias && hasPrecisePrefix(tp2) then
if tp2.asInstanceOf[TypeRef].canDropAlias && hasStablePrefix(tp2) then
return false
case _ =>
tp1 match
case tp1: NamedType =>
tp1.info match {
case info1: TypeAlias =>
if recur(info1.alias, tp2) then return true
if tp1.asInstanceOf[TypeRef].canDropAlias && hasPrecisePrefix(tp2) then
if tp1.asInstanceOf[TypeRef].canDropAlias && hasStablePrefix(tp2) then
return false
case _ =>
}
Expand Down

0 comments on commit d17da7a

Please sign in to comment.