Skip to content

TASTy Type#simplified doesn't always simplifies match types #10078

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
IndiscriminateCoding opened this issue Oct 23, 2020 · 0 comments
Closed

Comments

@IndiscriminateCoding
Copy link

Minimized code

File T.scala:

import scala.quoted._

object T {
  inline def show[A <: AnyKind]: Unit = ${ showImpl[A] }

  def showImpl[A <: AnyKind](using t: Type[A])(using ctx: QuoteContext): Expr[Unit] = {
    val before = t.unseal.tpe
    val after = before.simplified
    println(s"Before: ${before.show}")
    println(s"After : ${after.show}")
    '{}
  }
}

File Main.scala:

trait K[F[_]]
trait K2[F[_[_]]]

type Param1[m] = [f[_]] =>> m match { case K2[g] => g[f] }
type Param2[m] = m match { case K2[g] => g }

type Local = K2[K]

val _ = T.show[Param1[Local]]
val _ = T.show[Param2[Local]]

Output

Before: Main$package.Param1[Main$package.Local]
After : Main$package.Param1[Main$package.Local]
Before: [F >: scala.Nothing <: [_$1 >: scala.Nothing <: scala.Any] => scala.Any] => K[F]
After : [F >: scala.Nothing <: [_$1 >: scala.Nothing <: scala.Any] => scala.Any] => K[F]

Expectation

I expect that Param1 would be simplified in the same way as Param2

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

1 participant