Skip to content

Commit

Permalink
Handle TypeProxy of Named Tuples, minimal fix without refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
aherlihy committed Jan 8, 2025
1 parent 285cd40 commit 14fff9e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/TypeUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions tests/run/i22150.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
12 changes: 12 additions & 0 deletions tests/run/i22150.scala
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 14fff9e

Please sign in to comment.