File tree Expand file tree Collapse file tree 4 files changed +10
-5
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 4 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -567,4 +567,9 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
567567
568568object TypeOps {
569569 @ sharable var track : Boolean = false // !!!DEBUG
570+
571+ // TODO: Move other typeops here. It's a bit weird that they are a part of `ctx`
572+
573+ def tupleOf (ts : List [Type ])(implicit ctx : Context ): Type =
574+ (ts :\ (defn.UnitType : Type ))(defn.PairType .appliedTo(_, _))
570575}
Original file line number Diff line number Diff line change @@ -48,8 +48,8 @@ object TypeUtils {
4848 else throw new AssertionError (" not a tuple" )
4949 }
5050
51- /** The `*:` equivalent of an instantce of a Tuple class */
51+ /** The `*:` equivalent of an instance of a Tuple class */
5252 def toNestedPairs (implicit ctx : Context ): Type =
53- (tupleElementTypes :\ (defn. UnitType : Type ))(defn. PairType .appliedTo(_, _) )
53+ TypeOps .tupleOf(tupleElementTypes )
5454 }
5555}
Original file line number Diff line number Diff line change @@ -78,14 +78,14 @@ trait Deriving { this: Typer =>
7878 case _ =>
7979 (sym.termRef, Nil )
8080 }
81- val elemShape = (elems :\ (defn. UnitType : Type ))(defn. PairType .appliedTo(_, _) )
81+ val elemShape = TypeOps .tupleOf(elems )
8282 defn.ShapeCaseType .appliedTo(constr, elemShape)
8383 }
8484
8585 /** The shape of `cls` if `cls` is sealed */
8686 private def sealedShape : Type = {
8787 val cases = children.map(caseShape).filter(_.exists)
88- val casesShape = (cases :\ (defn. UnitType : Type ))(defn. PairType .appliedTo(_, _) )
88+ val casesShape = TypeOps .tupleOf(cases )
8989 defn.ShapeCasesType .appliedTo(casesShape)
9090 }
9191
Original file line number Diff line number Diff line change @@ -1919,7 +1919,7 @@ class Typer extends Namer
19191919 else {
19201920 val elemTpes = (elems, pts).zipped.map((elem, pt) =>
19211921 ctx.typeComparer.widenInferred(elem.tpe, pt))
1922- val resTpe = (elemTpes :\ (defn. UnitType : Type ))(defn. PairType .appliedTo(_, _) )
1922+ val resTpe = TypeOps .tupleOf(elemTpes )
19231923 app1.cast(resTpe)
19241924 }
19251925 }
You can’t perform that action at this time.
0 commit comments