diff --git a/compiler/src/dotty/tools/dotc/core/TypeUtils.scala b/compiler/src/dotty/tools/dotc/core/TypeUtils.scala index 0a219fa6ddfd..cf2906695571 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeUtils.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeUtils.scala @@ -135,6 +135,8 @@ class TypeUtils: case t => throw TypeError(em"Malformed NamedTuple: names must be string types, but $t was found.") val values = vals.tupleElementTypesUpTo(bound, normalize).getOrElse(Nil) names.zip(values) + case tp: TypeProxy if tp.derivesFromNamedTuple => + tp.superType.namedTupleElementTypesUpTo(bound, normalize) case t => Nil diff --git a/tests/run/i22150.check b/tests/run/i22150.check new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/tests/run/i22150.check @@ -0,0 +1 @@ +0 diff --git a/tests/run/i22150.scala b/tests/run/i22150.scala new file mode 100644 index 000000000000..5e224da66709 --- /dev/null +++ b/tests/run/i22150.scala @@ -0,0 +1,12 @@ +//> using options -experimental -language:experimental.namedTuples +import language.experimental.namedTuples + +val directionsNT = IArray( + (dx = 0, dy = 1), // up + (dx = 1, dy = 0), // right + (dx = 0, dy = -1), // down + (dx = -1, dy = 0), // left +) +val IArray(UpNT @ _, _, _, _) = directionsNT +@main def Test = + println(UpNT.dx)