Skip to content

Incorrect warning “type test cannot be checked at runtime” #8932

Closed
@julienrf

Description

@julienrf

Minimized code

package bugreport

sealed trait Foo[+A]
case class Bar[A]() extends Foo[A]

def bugReport[A](foo: Foo[A]): Foo[A] =
  foo match {
    case bar: Bar[A] => bar
  }

Output

[warn] -- Warning:
[warn] 8 |    case bar: Bar[A] => bar
[warn]   |         ^^^^^^^^^^^
[warn]   |         the type test for bugreport.Bar[A] cannot be checked at runtime

Expectation

There should be no warning.

Additional information

  • There was no warning in dotty 0.24.0-RC1
  • There is no warning if type parameter A is covariant in Bar

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions