Skip to content

typed patterns get more precise types in scalac than dotty #3208

Closed
@allanrenucci

Description

@allanrenucci

The following code snippet fails to compile

class Test {
  trait E
  trait Marker

  def test(es: List[E]): List[E] = es.collect { case e: Marker => e }
}
-- Error: tests/allan/Test.scala:5:69 ------------------------------------------
5 |  def test(es: List[E]): List[E] = es.collect { case e: Marker => e }
  |                                                                     ^
  |Cannot construct a collection of type That
  |
  |where:    That is a type variable with constraint <: scala.collection.immutable.List[Test.this.E]
  | with elements of type Test.this.Marker based on a collection of type scala.collection.immutable.List[Test.this.E].

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions