Skip to content

Commit

Permalink
lookupRefined: check for AliasingBounds instead of TypeBounds with eq…
Browse files Browse the repository at this point in the history
…ual bounds

It turns out that the problematic cases fixed in the previous commit only occurs
because we create type aliases with info of type MatchAlias instead of TypeAlias
if their rhs is an applied match type (Namer#TypeDefCompleter#typeSig calls
`toBounds` on the rhs which does `if (self.isMatch) MatchAlias(self)`).

I'm not sure if there is a good reason for that (and if so, do we need to be
careful to avoid loops when dealiasing MatchAlias?) or if we should change the
logic in Namer to return a TypeAlias instead.
  • Loading branch information
smarter committed Apr 20, 2022
1 parent be9c8be commit e0cce9a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Expand Up @@ -1548,8 +1548,8 @@ object Types {
@tailrec def loop(pre: Type): Type = pre.stripTypeVar match {
case pre: RefinedType =>
pre.refinedInfo match {
case TypeBounds(lo, hi) if lo eq hi =>
if (pre.refinedName ne name) loop(pre.parent) else lo
case tp: AliasingBounds =>
if (pre.refinedName ne name) loop(pre.parent) else tp.alias
case _ =>
loop(pre.parent)
}
Expand Down

0 comments on commit e0cce9a

Please sign in to comment.