diff --git a/compiler/src/dotty/tools/dotc/typer/PrepareInlineable.scala b/compiler/src/dotty/tools/dotc/typer/PrepareInlineable.scala index 3ceca092d102..97ebf77b5fca 100644 --- a/compiler/src/dotty/tools/dotc/typer/PrepareInlineable.scala +++ b/compiler/src/dotty/tools/dotc/typer/PrepareInlineable.scala @@ -251,7 +251,10 @@ object PrepareInlineable { */ object InlineSplice { def unapply(tree: Tree)(implicit ctx: Context): Option[Tree] = tree match { - case Spliced(code) if Splicer.canBeSpliced(code) => Some(code) + case Spliced(code) if Splicer.canBeSpliced(code) => + if (code.symbol.flags.is(Inline)) + ctx.error("Macro cannot be implemented with an `inline` method", code.sourcePos) + Some(code) case Block(List(stat), Literal(Constants.Constant(()))) => unapply(stat) case Block(Nil, expr) => unapply(expr) case Typed(expr, _) => unapply(expr) diff --git a/tests/neg/i6739.scala b/tests/neg/i6739.scala new file mode 100644 index 000000000000..2852394d11d5 --- /dev/null +++ b/tests/neg/i6739.scala @@ -0,0 +1,6 @@ +import scala.quoted._ + +inline def assert(expr: => Boolean): Unit = + ${ assertImpl('expr) } // error: Macro cannot be implemented with an `inline` method + +inline def assertImpl(expr: Expr[Boolean]): Expr[Unit] = '{ println("Hello World") }