Skip to content

Unclear warning in pattern match #23028

Open
@tgodzik

Description

@tgodzik

Compiler version

3.3.6-RC1 and 3.7.0-RC1 both display the issue.

Minimized code

case class RequestLogsOuter(streamId: Int)
@main def Test = {
  case class RequestLogs(streamId: Int)
  var x: List[Any] = List(RequestLogsOuter(12), RequestLogs(36), RequestLogs(42), 42)
  x.collect{
    case outer @ RequestLogsOuter(id) => println(1)
    case RequestLogs(42) => println(2) // warns in 3.3.6
    case v: RequestLogs => println(3) // warned in 3.3.5 if above is commented out
  }
}

Output

the type test for RequestLogs cannot be checked at runtime because it's a local class

Expectation

The code work correctly despite the warning, is that expected? Most likely showed up after #22099

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions