Skip to content

Inline matches can't bind higher kinded types, match types can #5574

Closed
@milessabin

Description

@milessabin

The following fails to compile,

import scala.typelevel._

object Test {
  class Box[F[_]]
  
  inline def foo[T] <: Any =
    inline erasedValue[T] match {
      case _: Box[f] => 23
    }

  foo[Box[List]]
}

reporting,

11 |  foo[Box[List]]
   |  ^^^^^^^^^^^^^^
   |cannot reduce inline match with
   | scrutinee:  scala.typelevel.erasedValue[Test.Box[List]] : Test.Box[List]
   | patterns :  case _:Test.Box[f @ _]
   | This location is in code that was inlined at tests/pos/hk-inline-match.scala:11
one error found

However, the similar,

import scala.typelevel._

object Test {
  class Box[F[_]]
  
  type Foo[T] = T match {
    case Box[f] => Int
  }

  val i: Foo[Box[List]] = 23
}

compiles as expected.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions