Skip to content

Better error when macro call is used within the same compilation unit as macro definition. #4540

Closed
@mosyp

Description

@mosyp

When macro definition and macro call is written within the same compilation unit, compiler errors with:
Could not find interpreted class Main in classpath, see https://scastie.scala-lang.org/h8cEUZIER2mT6YBtl4wFlA as example.
It'd be great to add a compiler hint as it was in scala.reflect macros: error: macro implementation not found: printf (the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them) and improve docs in http://dotty.epfl.ch/docs/reference/principled-meta-programming.html
See last paragraph of https://docs.scala-lang.org/overviews/macros/overview.html#a-complete-example for example

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions