diff --git a/compiler/src/dotty/tools/dotc/transform/Splicer.scala b/compiler/src/dotty/tools/dotc/transform/Splicer.scala index c870336995f0..46a8571b4f30 100644 --- a/compiler/src/dotty/tools/dotc/transform/Splicer.scala +++ b/compiler/src/dotty/tools/dotc/transform/Splicer.scala @@ -31,6 +31,7 @@ import dotty.tools.dotc.quoted.{PickledQuotes, QuoteUtils} import scala.quoted.Quotes import scala.quoted.runtime.impl._ +import dotty.tools.dotc.core.NameKinds /** Utility class to splice quoted expressions */ object Splicer { @@ -214,6 +215,13 @@ object Splicer { report.error("Macro cannot be implemented with an `inline` method", fn.srcPos) args.flatten.foreach(checkIfValidArgument) + case Call(fn, args) if fn.symbol.name.is(NameKinds.InlineAccessorName) => + // TODO suggest use of @binaryAPI once we have the annotation + report.error( + i"""Macro implementation is not statically accessible. + | + |Non-static inline accessor was generated in ${fn.symbol.owner} + |""".stripMargin, tree.srcPos) case _ => report.error( """Malformed macro. diff --git a/tests/neg-macros/i15413.check b/tests/neg-macros/i15413.check new file mode 100644 index 000000000000..56f587eb2fb4 --- /dev/null +++ b/tests/neg-macros/i15413.check @@ -0,0 +1,6 @@ +-- Error: tests/neg-macros/i15413.scala:4:22 --------------------------------------------------------------------------- +4 | inline def foo = ${ Macro.fooImpl } // error + | ^^^^^^^^^^^^^ + | Macro implementation is not statically accessible. + | + | Non-static inline accessor was generated in class Macro diff --git a/tests/neg-macros/i15413.scala b/tests/neg-macros/i15413.scala new file mode 100644 index 000000000000..186ba60f3d25 --- /dev/null +++ b/tests/neg-macros/i15413.scala @@ -0,0 +1,7 @@ +import scala.quoted.* + +class Macro: + inline def foo = ${ Macro.fooImpl } // error + +object Macro: + private def fooImpl(using Quotes) = '{}