Skip to content

Commit 0fbf014

Browse files
committed
lookupRefined: check for AliasingBounds instead of TypeBounds with equal 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? `lookupRefined` doesn't actually loop on the alias but maybe it should?) or if we should change the logic in Namer to return a TypeAlias instead.
1 parent be9c8be commit 0fbf014

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,8 +1548,10 @@ object Types {
15481548
@tailrec def loop(pre: Type): Type = pre.stripTypeVar match {
15491549
case pre: RefinedType =>
15501550
pre.refinedInfo match {
1551-
case TypeBounds(lo, hi) if lo eq hi =>
1552-
if (pre.refinedName ne name) loop(pre.parent) else lo
1551+
case tp: AliasingBounds =>
1552+
// TODO: should we recurse on tp.alias? Can that lead to cycles if
1553+
// problematic if AliasingBounds is a MatchAlias?
1554+
if (pre.refinedName ne name) loop(pre.parent) else tp.alias
15531555
case _ =>
15541556
loop(pre.parent)
15551557
}

0 commit comments

Comments
 (0)