Skip to content

Inherited methods cannot be called from splice #22592

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
t9dupuy opened this issue Feb 12, 2025 · 1 comment · Fixed by #22618
Closed

Inherited methods cannot be called from splice #22592

t9dupuy opened this issue Feb 12, 2025 · 1 comment · Fixed by #22618
Assignees
Labels
area:metaprogramming:quotes Issues related to quotes and splices itype:bug
Milestone

Comments

@t9dupuy
Copy link

t9dupuy commented Feb 12, 2025

Compiler version

3.6.3

Minimized code

Macros inside an object cannot access methods inherited by the object without calling the object itself.

import scala.quoted.*

trait Foo:
  def inherited = ()

object Bar extends Foo:
  def local = ()

  def macro1(using Quotes): Expr[Unit] = '{ local }           // Ok
  def macro2(using Quotes): Expr[Unit] = '{ Bar.inherited }   // Ok
  def macro3(using Quotes): Expr[Unit] = '{ inherited }       // Error

Output

access to object Bar from wrong staging level:
 - the definition is at level 0,
 - but the access is at level 1.

Expectation

This should work.

@t9dupuy t9dupuy added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 12, 2025
@Gedochao Gedochao added area:metaprogramming:quotes Issues related to quotes and splices and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 13, 2025
@Gedochao
Copy link
Contributor

@t9dupuy The original repro was missing import scala.quoted.*, I edited the original post.

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 itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants