Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
milessabin opened this issue Dec 6, 2018 · 1 comment
Closed

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

milessabin opened this issue Dec 6, 2018 · 1 comment

Comments

@milessabin
Copy link
Contributor

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.

@abgruszecki
Copy link
Contributor

Will be visited as part of working on #5405.

abgruszecki added a commit to dotty-staging/dotty that referenced this issue Dec 23, 2018
Re-typing the pattern in GADT context is unnecessary - reducing
the pattern will on its own perform the same subtyping checks.
abgruszecki added a commit to dotty-staging/dotty that referenced this issue Dec 23, 2018
Re-typing the pattern in GADT context is unnecessary - reducing
the pattern will on its own perform the same subtyping checks.
abgruszecki added a commit to dotty-staging/dotty that referenced this issue Dec 23, 2018
Re-typing the pattern in GADT context is unnecessary - reducing
the pattern will on its own perform the same subtyping checks.

Previously if a pattern binding a HK type was inlined, a warning
saying that its kind is different from the kind of its parameter
was emitted _after_ preparing for reduction. This replaced the type
of the Bind node with an error, preventing the bind from being
located and narrowed when reducing the inline match.
abgruszecki added a commit to dotty-staging/dotty that referenced this issue Dec 27, 2018
Re-typing the pattern in GADT context is unnecessary - reducing
the pattern will on its own perform the same subtyping checks.

Previously if a pattern binding a HK type was inlined, a warning
saying that its kind is different from the kind of its parameter
was emitted _after_ preparing for reduction. This replaced the type
of the Bind node with an error, preventing the bind from being
located and narrowed when reducing the inline match.
abgruszecki added a commit to dotty-staging/dotty that referenced this issue Jan 3, 2019
Re-typing the pattern in GADT context is unnecessary - reducing
the pattern will on its own perform the same subtyping checks.

Previously if a pattern binding a HK type was inlined, a warning
saying that its kind is different from the kind of its parameter
was emitted _after_ preparing for reduction. This replaced the type
of the Bind node with an error, preventing the bind from being
located and narrowed when reducing the inline match.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants