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.
567
567
568
568
object TypeOps {
569
569
@ 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(_, _))
570
575
}
Original file line number Diff line number Diff line change @@ -48,8 +48,8 @@ object TypeUtils {
48
48
else throw new AssertionError (" not a tuple" )
49
49
}
50
50
51
- /** The `*:` equivalent of an instantce of a Tuple class */
51
+ /** The `*:` equivalent of an instance of a Tuple class */
52
52
def toNestedPairs (implicit ctx : Context ): Type =
53
- (tupleElementTypes :\ (defn. UnitType : Type ))(defn. PairType .appliedTo(_, _) )
53
+ TypeOps .tupleOf(tupleElementTypes )
54
54
}
55
55
}
Original file line number Diff line number Diff line change @@ -78,14 +78,14 @@ trait Deriving { this: Typer =>
78
78
case _ =>
79
79
(sym.termRef, Nil )
80
80
}
81
- val elemShape = (elems :\ (defn. UnitType : Type ))(defn. PairType .appliedTo(_, _) )
81
+ val elemShape = TypeOps .tupleOf(elems )
82
82
defn.ShapeCaseType .appliedTo(constr, elemShape)
83
83
}
84
84
85
85
/** The shape of `cls` if `cls` is sealed */
86
86
private def sealedShape : Type = {
87
87
val cases = children.map(caseShape).filter(_.exists)
88
- val casesShape = (cases :\ (defn. UnitType : Type ))(defn. PairType .appliedTo(_, _) )
88
+ val casesShape = TypeOps .tupleOf(cases )
89
89
defn.ShapeCasesType .appliedTo(casesShape)
90
90
}
91
91
Original file line number Diff line number Diff line change @@ -1919,7 +1919,7 @@ class Typer extends Namer
1919
1919
else {
1920
1920
val elemTpes = (elems, pts).zipped.map((elem, pt) =>
1921
1921
ctx.typeComparer.widenInferred(elem.tpe, pt))
1922
- val resTpe = (elemTpes :\ (defn. UnitType : Type ))(defn. PairType .appliedTo(_, _) )
1922
+ val resTpe = TypeOps .tupleOf(elemTpes )
1923
1923
app1.cast(resTpe)
1924
1924
}
1925
1925
}
You can’t perform that action at this time.
0 commit comments