Skip to content

Commit 14fff9e

Browse files
committed
Handle TypeProxy of Named Tuples, minimal fix without refactoring
1 parent 285cd40 commit 14fff9e

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ class TypeUtils:
135135
case t => throw TypeError(em"Malformed NamedTuple: names must be string types, but $t was found.")
136136
val values = vals.tupleElementTypesUpTo(bound, normalize).getOrElse(Nil)
137137
names.zip(values)
138+
case tp: TypeProxy if tp.derivesFromNamedTuple =>
139+
tp.superType.namedTupleElementTypesUpTo(bound, normalize)
138140
case t =>
139141
Nil
140142

tests/run/i22150.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

tests/run/i22150.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//> using options -experimental -language:experimental.namedTuples
2+
import language.experimental.namedTuples
3+
4+
val directionsNT = IArray(
5+
(dx = 0, dy = 1), // up
6+
(dx = 1, dy = 0), // right
7+
(dx = 0, dy = -1), // down
8+
(dx = -1, dy = 0), // left
9+
)
10+
val IArray(UpNT @ _, _, _, _) = directionsNT
11+
@main def Test =
12+
println(UpNT.dx)

0 commit comments

Comments
 (0)