Skip to content
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

When Fields in Selectable comes from type alias of named tuple. the fields are not selectable #22018

Closed
kavedaa opened this issue Nov 24, 2024 · 1 comment · Fixed by #22149
Closed
Labels
area:named-tuples Issues tied to the named tuples feature. itype:bug
Milestone

Comments

@kavedaa
Copy link

kavedaa commented Nov 24, 2024

Compiler version

3.6.4-RC1-bin-20241122-64411b6-NIGHTLY and earlier

Minimized code

import scala.language.experimental.namedTuples

class SelectableNT[A <: NamedTuple.AnyNamedTuple](val nt: A) extends Selectable:
  type Fields = A
  def selectDynamic(x: String) = ???

object Test:

  val a = (name = "foo", age = 1)

  val sa = SelectableNT(a)
  sa.name   // ok

  type B = a.type  
  val b: B = a

  val sb = SelectableNT(b)
  sb.name   // fails

Output

value name is not a member of bug.SelectableNT[(bug.Test.a : (name : String, age : Int))]

Expectation

Successful compilation

@kavedaa kavedaa added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 24, 2024
@Gedochao Gedochao added area:named-tuples Issues tied to the named tuples feature. and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 25, 2024
@odersky
Copy link
Contributor

odersky commented Dec 5, 2024

The problem came actually not from the fact that B is an alias, but that it is an alias of a singleton type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:named-tuples Issues tied to the named tuples feature. itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants