Skip to content

approximate existential types when checking pattern conformance #6587

Open
@scabug

Description

@scabug
trait Outer[T] {
  sealed trait Inner
  case class C1(val x: T) extends Inner
  case class C2(val x: T) extends Inner
}

object Test3 {
  type SomeInner = Outer[X]#Inner forSome { type X }

  // Clearly Test1.C1(5) is an instance of SomeInner, as seen here:
  var x: SomeInner = _
  x = Test1.C1(5)

  // And yet,
  //
  // def f0(x: SomeInner) = x match { case Test1.C1(_) => }
  //
  // ./a.scala:35: error: constructor cannot be instantiated to expected type;
  //  found   : Test1.C1
  //  required: Outer[X]#Inner where type X
  //   def f0(x: SomeInner) = x match { case Test1.C1(_) => }
  //
  // Whereas this is no problem:
  def f1(x: Any) = x match { case Test1.C1(_) => }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions