Skip to content

Commit 7c1f7f0

Browse files
committed
Drop followAlias
It turns out we don't need it anymore. This is nice, since `followAlias` did some fairly ad-hoc rewritings.
1 parent 9efa6f7 commit 7c1f7f0

File tree

1 file changed

+1
-29
lines changed

1 file changed

+1
-29
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,34 +2535,6 @@ class Typer extends Namer
25352535
}
25362536
}
25372537

2538-
/** If `tp` is a TypeVar which is fully constrained (i.e. its upper bound `hi` conforms
2539-
* to its lower bound `lo`), replace `tp` by `hi`. This is necessary to
2540-
* keep the right constraints for some implicit search problems. The paradigmatic case
2541-
* is `implicitNums.scala`. Without the healing done in `followAlias`, we cannot infer
2542-
* implicitly[_3], where _2 is the typelevel number 3. The problem here is that if a
2543-
* prototype is, say, Succ[Succ[Zero]], we can infer that it's argument type is Succ[Zero].
2544-
* But if the prototype is N? >: Succ[Succ[Zero]] <: Succ[Succ[Zero]], the same
2545-
* decomposition does not work - we'd get a N?#M where M is the element type name of Succ
2546-
* instead.
2547-
*/
2548-
def followAlias(tp: Type)(implicit ctx: Context): Type = {
2549-
val constraint = ctx.typerState.constraint
2550-
def inst(tp: Type): Type = tp match {
2551-
case TypeBounds(lo, hi)
2552-
if (lo eq hi) || ctx.test(implicit ctx => hi <:< lo) =>
2553-
inst(lo)
2554-
case tp: TypeParamRef =>
2555-
constraint.typeVarOfParam(tp).orElse(tp)
2556-
case _ =>
2557-
NoType
2558-
}
2559-
tp match {
2560-
case tp: TypeVar if constraint.contains(tp) =>
2561-
inst(constraint.entry(tp.origin)).orElse(tp)
2562-
case _ => tp
2563-
}
2564-
}
2565-
25662538
/** Reveal ignored parts of prototype when synthesizing the receiver
25672539
* of an extension method. This is necessary for pos/i5773a.scala
25682540
*/
@@ -2811,7 +2783,7 @@ class Typer extends Namer
28112783
}
28122784

28132785
def resultMatches(wtp: Type, pt: Type) =
2814-
constrainResult(tree.symbol, wtp, revealProtoOfExtMethod(followAlias(pt)))
2786+
constrainResult(tree.symbol, wtp, revealProtoOfExtMethod(pt))
28152787

28162788
def adaptNoArgs(wtp: Type): Tree = {
28172789
val ptNorm = underlyingApplied(pt)

0 commit comments

Comments
 (0)