Skip to content
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

Macro implementation in REPL cannot be non-toplevel #15104

Closed
prolativ opened this issue May 4, 2022 · 0 comments · Fixed by #16866
Closed

Macro implementation in REPL cannot be non-toplevel #15104

prolativ opened this issue May 4, 2022 · 0 comments · Fixed by #16866
Assignees
Labels
area:metaprogramming:quotes Issues related to quotes and splices area:repl itype:bug
Milestone

Comments

@prolativ
Copy link
Contributor

prolativ commented May 4, 2022

Compiler version

3.2.0-RC1-bin-20220503-aff1e11-NIGHTLY

Minimized code

In REPL paste the two snippets below one after another

import scala.quoted.*

object Foo:
  def macroImpl(using Quotes) = Expr(1)

inline def foo = ${ Foo.macroImpl }
def x = foo

Output

-- Error: ----------------------------------------------------------------------
1 |def x = foo
  |        ^^^
  |        Could not find class rs$line$1$Foo$ in classpath
  |-----------------------------------------------------------------------------
  |Inline stack trace
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  |This location contains code that was inlined from rs$line$1:6
6 |inline def foo = ${ Foo.macroImpl }
  |                 ^^^^^^^^^^^^^^^^^^
   -----------------------------------------------------------------------------
1 error found

Expectation

There should be no error, just like when macroImpl is a toplevel definition, e.g.

import scala.quoted.*

def macroImpl(using Quotes) = Expr(1)

inline def foo = ${ macroImpl }
def x = foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metaprogramming:quotes Issues related to quotes and splices area:repl itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants