Skip to content

Commit da59705

Browse files
aherlihytgodzik
authored andcommitted
Call dealias after stripping type variables for tupleElementTypesUpTo
[Cherry-picked f8b12dd]
1 parent bb90d08 commit da59705

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ class TypeUtils:
7171
case _ =>
7272
if defn.isTupleClass(tp.typeSymbol) && !normalize then Some(tp.dealias.argInfos)
7373
else None
74-
recur(self.stripTypeVar, bound)
74+
val stripped = if normalize then self.stripTypeVar.dealias else self.stripTypeVar // keep error reporting aliased
75+
recur(stripped, bound)
7576

7677
/** Is this a generic tuple but not already an instance of one of Tuple1..22? */
7778
def isGenericTuple(using Context): Boolean =

tests/pos/i22643.scala

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import language.experimental.namedTuples
2+
3+
4+
5+
object ExhibitB:
6+
7+
trait JoinB[A <: Tuple, B <: Tuple]:
8+
type NTB = NamedTuple.NamedTuple[Tuple.Concat[A, B], (String, Int)]
9+
val ntB: NTB = ???
10+
11+
val joinB: JoinB[Tuple1["nameB"], Tuple1["ageB"]] = ???
12+
13+
joinB.ntB.nameB // works
14+
15+
16+
object ExhibitC:
17+
18+
type A = Tuple1["nameC"]
19+
type B = Tuple1["ageC"]
20+
21+
type NamesC = Tuple.Concat[A, B]
22+
type NTC = NamedTuple.NamedTuple[NamesC, (String, Int)]
23+
val ntC: NTC = ???
24+
25+
ntC.nameC // works
26+
27+
28+
object ExhibitD:
29+
30+
trait JoinD[A, B]:
31+
type NamesD = (A, B)
32+
type NTD = NamedTuple.NamedTuple[NamesD, (String, Int)]
33+
val ntD: NTD = ???
34+
35+
val joinD: JoinD["nameD", "ageD"] = ???
36+
37+
joinD.ntD.nameD // works
38+
39+
object ExhibitA:
40+
41+
trait JoinA[A <: Tuple, B <: Tuple]:
42+
type NamesA = Tuple.Concat[A, B]
43+
type NTA = NamedTuple.NamedTuple[NamesA, (String, Int)]
44+
val ntA: NTA = ???
45+
46+
val joinA: JoinA[Tuple1["nameA"], Tuple1["ageA"]] = ???
47+
48+
joinA.ntA.nameA // fixed

0 commit comments

Comments
 (0)