Skip to content

Macros do not expand TASTY macros if in any form of nesting #8866

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
yilinwei opened this issue May 3, 2020 · 0 comments · Fixed by #8870
Closed

Macros do not expand TASTY macros if in any form of nesting #8866

yilinwei opened this issue May 3, 2020 · 0 comments · Fixed by #8870
Assignees
Milestone

Comments

@yilinwei
Copy link
Contributor

yilinwei commented May 3, 2020

Minimized example

import scala.quoted._

object OtherMacro {

  def impl(using qctx: QuoteContext): Expr[Int] =
    '{ 42 }

  inline def apply = ${ OtherMacro.impl }

}

object Macro {

  def impl(using qctx: QuoteContext): Expr[Int] = {
    import qctx.tasty._
    import util._

    // Simply returning this term is OK
    // Select.unique(
    //   '{ OtherMacro }.unseal,
    //   "apply"
    // ).seal.cast[Int]

    let(
      Select.unique(
        '{ OtherMacro }.unseal,
        "apply"
      )
    )(identity).seal.cast[Int]
  }

  inline def apply = ${ Macro.impl }

}

Output

[error] 3 |  val a = Macro.apply
[error]   |          ^^^^^^^^^^^
[error]   |          method apply is declared as erased, but is in fact used

Expectation

Either TASTY reflect terms shouldn't be expanded, or possibly we can expand them explicitly? If you simply return the commented out code, the macro gets expanded.

If you have a quote with a macro it gets expanded as expected.

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 4, 2020
@nicolasstucki nicolasstucki linked a pull request May 4, 2020 that will close this issue
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 4, 2020
@nicolasstucki nicolasstucki self-assigned this May 4, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 4, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 5, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 8, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 25, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 25, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jun 2, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jun 10, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jun 15, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jun 17, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 6, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Sep 1, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Sep 1, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Sep 1, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Sep 2, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Sep 7, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Sep 10, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Sep 10, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Sep 10, 2020
nicolasstucki added a commit that referenced this issue Sep 11, 2020
Fix #8866: Inline calls inserted by macros
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants