Skip to content

Cannot parameterize inline macro #4023

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
nicolasstucki opened this issue Feb 21, 2018 · 1 comment
Closed

Cannot parameterize inline macro #4023

nicolasstucki opened this issue Feb 21, 2018 · 1 comment

Comments

@nicolasstucki
Copy link
Contributor

nicolasstucki commented Feb 21, 2018

import scala.quoted._
object Macro {
  inline def ff[T](x: T): T = ~impl[T]('(x))
  def impl[T](x: Expr[T]): Expr[T] = x
}

fails with

3 |  inline def ff[T](x: T): T = ~impl[T]('(x))
  |                                    ^
  |              access to type T from wrong staging level:
  |               - the definition is at level 1,
  |               - but the access is at level 0.
  |              
  |               The access would be accepted with the right type tag, but
  |               no implicit argument of type scala.quoted.Type[T] was found

But if we add the implicit quoted.Type[T] it fails with

3 |  inline def ff[T: Type](x: T): T = ~impl[T]('(x))
  |                                     ^
  |                      access to value evidence$1 from wrong staging level:
  |                       - the definition is at level 1,
  |                       - but the access is at level -1.
@nicolasstucki nicolasstucki changed the title Cant parameterize inline macro Cannot parameterize inline macro Feb 21, 2018
@nicolasstucki
Copy link
Contributor Author

Smaller code that fails with the same issue

import scala.quoted._
object Macro {
  inline def ff[T](implicit t: Type[T]): Int = ~impl[T]
  def impl[T]: Expr[Int] = 4
}

@nicolasstucki nicolasstucki self-assigned this Feb 26, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 26, 2018
odersky added a commit that referenced this issue Mar 1, 2018
Fix #4023: Ignore healed implicit tag at level 0
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