Skip to content

Inherited methods cannot be called from splice #22592

Closed
@t9dupuy

Description

@t9dupuy

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions