Skip to content

Inconsistency with member selection of generic tuples with know TupleN #14215

Closed
@nicolasstucki

Description

@nicolasstucki

Compiler version

3.1.0

Minimized code

def f[T <: Tuple2[Int, Int]](tup: T): T = tup

def test: Unit =
  (1, 2)._1
  f((1, 2))._1

  (1 *: 2 *: EmptyTuple)._1 // error: `*:` does not have a member `_1` based on our current encoding it is considered ok
  f(1 *: 2 *: EmptyTuple)._1 // error: should not fail as `f` returns a subtype of `Tuple2` and should have the member `_1`
  f[Int *: Int *: EmptyTuple](1 *: 2 *: EmptyTuple)._1 // error

  f[Int *: Int *: EmptyTuple]((1, 2))._1 // error
  f[Tuple2[Int, Int]](1 *: 2 *: EmptyTuple)._1

Output

-- [E008] Not Found Error: Foo.scala:7:25 --------------------------------------
7 |  (1 *: 2 *: EmptyTuple)._1 // error: `*:` does not have a member `_1` based on our current encoding it is considered ok
  |  ^^^^^^^^^^^^^^^^^^^^^^^^^
  |  value _1 is not a member of (Int, Int)
-- [E008] Not Found Error: Foo.scala:8:26 --------------------------------------
8 |  f(1 *: 2 *: EmptyTuple)._1 // error: should not fail as `f` returns a subtype of `Tuple2` and should have the member `_1`
  |  ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |  value _1 is not a member of (Int, Int)
-- [E008] Not Found Error: Foo.scala:9:52 --------------------------------------
9 |  f[Int *: Int *: EmptyTuple](1 *: 2 *: EmptyTuple)._1 // error
  |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |  value _1 is not a member of Int *: Int *: EmptyTuple
-- [E008] Not Found Error: Foo.scala:11:38 -------------------------------------
11 |  f[Int *: Int *: EmptyTuple]((1, 2))._1 // error
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |  value _1 is

Expectation

Ideally, they should all work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions