Skip to content

Unsound generic tuple type test #9056

Closed
@nicolasstucki

Description

@nicolasstucki

The following two matches succeed when they should not. Tuple, NonEmptyTuple, *: erase to Object or Product and therefore the test is performed on those classes.

("a": Any) match
    case _: Tuple => assert(false)
    case _ => // ok
  case class Foo(a: Int)

  (Foo(1): Any) match
    case a: (_ *: _) => a.tail
    case _ => // ok

As these classes do not exist at runtime we should handle them as abstract types which would yield the unchecked warning. This approach could be combined with TypeTest to provide a type test that does the correct checks at runtime.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions