Skip to content

Type bound breaks extraction of covariant type parameter from singleton type  #16504

Closed
@prolativ

Description

@prolativ

Compiler version

3.2.1, 3.3.0-RC1-bin-20221209-231f9ab-NIGHTLY
Used to work in 3.1.3

Minimized code

class Box[+A](a: A)
val box: Box[Int] = Box(123)

type Elem[T] = T match
  case Box[a] => a

def x1[F](f: F): Elem[f.type] = ???
def y1 = x1(box)

def x2[F <: Box[Any]](f: F): Elem[f.type] = ???
def y2 = x2(box)

Output

As seen in REPL:

// defined case class Box
val box: Box[Int] = Box(123)
def x1[F](f: F): Elem[f.type]
def y1: Int
def x2[F <: Box[Any]](f: F): Any
def y2: Any

Expectation

Elem[f.type] should be properly computed as Int, as in 3.1.3:

// defined case class Box
val box: Box[Int] = Box(123)
def x1[F](f: F): Elem[f.type]
def y1: Int
def x2[F <: Box[Any]](f: F): Elem[f.type]
def y2: Int

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