Skip to content

Commit 3d31d20

Browse files
committed
Generalize tupleElems
- Always follow skolems to underlying types - Also follow other singletons to underlying types if normalize is true
1 parent e0c2669 commit 3d31d20

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ class TypeUtils {
6565
case tp: AppliedType if defn.isTupleNType(tp) && normalize =>
6666
Some(tp.args) // if normalize is set, use the dealiased tuple
6767
// otherwise rely on the default case below to print unaliased tuples.
68+
case tp: SkolemType =>
69+
recur(tp.underlying, bound)
6870
case tp: SingletonType =>
69-
if tp.termSymbol == defn.EmptyTupleModule then Some(Nil) else None
71+
if tp.termSymbol == defn.EmptyTupleModule then Some(Nil)
72+
else if normalize then recur(tp.widen, bound)
73+
else None
7074
case _ =>
7175
if defn.isTupleClass(tp.typeSymbol) && !normalize then Some(tp.dealias.argInfos)
7276
else None
@@ -84,6 +88,9 @@ class TypeUtils {
8488
case Some(elems) if elems.length <= Definitions.MaxTupleArity => true
8589
case _ => false
8690

91+
/** Is this type a named tuple element `name = value`? */
92+
def isNamedTupleElem(using Context): Boolean = defn.NamedTupleElem.unapply(self).isDefined
93+
8794
/** The `*:` equivalent of an instance of a Tuple class */
8895
def toNestedPairs(using Context): Type =
8996
tupleElementTypes match

0 commit comments

Comments
 (0)