Skip to content

Combination of trait, type alias, Tuple.Concat, and named tuple, where named tuple elements are not selectable #22643

Closed
@kavedaa

Description

@kavedaa

Compiler version

3.6.3, 3.7.0-RC1-bin-20250222-4dc4668-NIGHTLY

Minimized code

package bug

import scala.language.experimental.namedTuples

object ExhibitA:

  trait Join[A <: Tuple, B <: Tuple]:
    type Names = Tuple.Concat[A, B]
    type NT = NamedTuple.NamedTuple[Names, (String, Int)]
    val nt: NT = ???

  val join: Join[Tuple1["name"], Tuple1["age"]] = ???

  join.nt.name    // fails

  
object ExhibitB:

  trait Join[A <: Tuple, B <: Tuple]:
    type NT = NamedTuple.NamedTuple[Tuple.Concat[A, B], (String, Int)]
    val nt: NT = ???

  val join: Join[Tuple1["name"], Tuple1["age"]] = ???

  join.nt.name    // works

    
object ExhibitC:

  type A = Tuple1["name"]
  type B = Tuple1["age"]

  type Names = Tuple.Concat[A, B]
  type NT = NamedTuple.NamedTuple[Names, (String, Int)]
  val nt: NT = ???

  nt.name   // works


object ExhibitD:

  trait Join[A, B]:
    type Names = (A, B)
    type NT = NamedTuple.NamedTuple[Names, (String, Int)]
    val nt: NT = ???

  val join: Join["name", "age"] = ???
  
  join.nt.name    // works

Output

[error] .\bug.scala:16:3
[error] value name is not a member of bug.ExhibitA.join.NT
[error]   join.nt.name    // fails
[error]   ^^^^^^^^^^^^

Expectation

Successful compilation

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions