Skip to content

Don't use the declared type info when infer type in match #8404

Closed
@ohze

Description

@ohze

minimized code

trait ActorRefScope
class ActorRef
case class DeathWatchNotification(actor: ActorRef)
object Main {
  val ref: ActorRef = ???
  ref match {
    case r: ActorRefScope => DeathWatchNotification(r)
    case _ =>
  }
}

Compilation output

[error] -- [E007] Type Mismatch Error: /dotty-example/src/main/scala/Main.scala:7:52 
[error] 7 |    case r: ActorRefScope => DeathWatchNotification(r)
[error]   |                                                    ^
[error]   |                                             Found:    (r : ActorRefScope)
[error]   |                                             Required: ActorRef

expectation

Compile successfully as in scala 2

info

dotty version: 0.22.0-RC1

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