Skip to content

Backport "Call dealias after stripping type variables for tupleElementTypesUpTo" to 3.3 LTS #360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Call dealias after stripping type variables for tupleElementTypesUpTo
[Cherry-picked f8b12dd]
  • Loading branch information
aherlihy authored and tgodzik committed Apr 28, 2025
commit da59705c8e28714adecb865df805baa3efccab88
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/core/TypeUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ class TypeUtils:
case _ =>
if defn.isTupleClass(tp.typeSymbol) && !normalize then Some(tp.dealias.argInfos)
else None
recur(self.stripTypeVar, bound)
val stripped = if normalize then self.stripTypeVar.dealias else self.stripTypeVar // keep error reporting aliased
recur(stripped, bound)

/** Is this a generic tuple but not already an instance of one of Tuple1..22? */
def isGenericTuple(using Context): Boolean =
Expand Down
48 changes: 48 additions & 0 deletions tests/pos/i22643.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import language.experimental.namedTuples



object ExhibitB:

trait JoinB[A <: Tuple, B <: Tuple]:
type NTB = NamedTuple.NamedTuple[Tuple.Concat[A, B], (String, Int)]
val ntB: NTB = ???

val joinB: JoinB[Tuple1["nameB"], Tuple1["ageB"]] = ???

joinB.ntB.nameB // works


object ExhibitC:

type A = Tuple1["nameC"]
type B = Tuple1["ageC"]

type NamesC = Tuple.Concat[A, B]
type NTC = NamedTuple.NamedTuple[NamesC, (String, Int)]
val ntC: NTC = ???

ntC.nameC // works


object ExhibitD:

trait JoinD[A, B]:
type NamesD = (A, B)
type NTD = NamedTuple.NamedTuple[NamesD, (String, Int)]
val ntD: NTD = ???

val joinD: JoinD["nameD", "ageD"] = ???

joinD.ntD.nameD // works

object ExhibitA:

trait JoinA[A <: Tuple, B <: Tuple]:
type NamesA = Tuple.Concat[A, B]
type NTA = NamedTuple.NamedTuple[NamesA, (String, Int)]
val ntA: NTA = ???

val joinA: JoinA[Tuple1["nameA"], Tuple1["ageA"]] = ???

joinA.ntA.nameA // fixed