Skip to content

Commit 50d91c1

Browse files
committed
small refactoring of code
1 parent ab0a7c3 commit 50d91c1

File tree

1 file changed

+13
-23
lines changed
  • compiler/src/dotty/tools/dotc/transform/patmat

1 file changed

+13
-23
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -600,38 +600,28 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
600600
def instantiate(tp1: NamedType, tp2: Type)(implicit ctx: Context): Type = {
601601
// expose abstract type references to their bounds or tvars according to variance
602602
class AbstractTypeMap(maximize: Boolean)(implicit ctx: Context) extends TypeMap {
603-
def expose(tp: TypeRef): Type = {
604-
val lo = this(tp.info.loBound)
605-
val hi = this(tp.info.hiBound)
606-
val exposed =
607-
if (variance == 0)
608-
newTypeVar(TypeBounds(lo, hi))
609-
else if (variance == 1)
610-
if (maximize) hi else lo
611-
else
612-
if (maximize) lo else hi
613-
614-
debug.println(s"$tp exposed to =====> $exposed")
615-
exposed
616-
}
603+
def expose(lo: Type, hi: Type): Type =
604+
if (variance == 0)
605+
newTypeVar(TypeBounds(lo, hi))
606+
else if (variance == 1)
607+
if (maximize) hi else lo
608+
else
609+
if (maximize) lo else hi
617610

618611
def apply(tp: Type): Type = tp match {
619612
case tp: TypeRef if tp.underlying.isInstanceOf[TypeBounds] =>
613+
val lo = this(tp.info.loBound)
614+
val hi = this(tp.info.hiBound)
620615
// See tests/patmat/gadt.scala tests/patmat/exhausting.scala tests/patmat/t9657.scala
621-
expose(tp)
616+
val exposed = expose(lo, hi)
617+
debug.println(s"$tp exposed to =====> $exposed")
618+
exposed
622619

623620
case AppliedType(tycon: TypeRef, args) if tycon.underlying.isInstanceOf[TypeBounds] =>
624621
val args2 = args.map(this)
625622
val lo = this(tycon.info.loBound).applyIfParameterized(args2)
626623
val hi = this(tycon.info.hiBound).applyIfParameterized(args2)
627-
val exposed =
628-
if (variance == 0)
629-
newTypeVar(TypeBounds(lo, hi))
630-
else if (variance == 1)
631-
if (maximize) hi else lo
632-
else
633-
if (maximize) lo else hi
634-
624+
val exposed = expose(lo, hi)
635625
debug.println(s"$tp exposed to =====> $exposed")
636626
exposed
637627

0 commit comments

Comments
 (0)