Skip to content

Support Scala 2 Macro bundle definitions #8945

Closed
@bishabosha

Description

@bishabosha

Minimized code

compile src-2/MacroImpl.scala with scala 2.13.2 then compile src-3/Macros.scala with the previous output on classpath

// src-2/MacroImpl.scala
class MacroImpl(val c: scala.reflect.macros.blackbox.Context) {
  import c.universe._
  def mono: Literal = q"()"
}
// src-3/Macros.scala
import scala.language.experimental.macros

object Macros {

  object Bundles {
    def mono: Unit = macro MacroImpl.mono
    inline def mono: Unit = ${ Macros3.monoImpl }
  }

  object Macros3 {
    def monoImpl(using quoted.QuoteContext) = '{()}
  }

}

Output

when compiling src-3/Macros.scala

-- [E006] Not Found Error: Macros.scala:8:27 
8 |    def mono: Unit = macro MacroImpl.mono
  |                           ^^^^^^^^^
  |                           Not found: MacroImpl

Expectation

macro MacroImpl.mono should be automatically rewritten to macro (new MacroImpl(null)).mono before pickling.

This special case of treating class MacroImpl as a term is only required for the end of the path before the method selection and if the term is actually a class with a single parameter.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions