Skip to content

Commit 8edd676

Browse files
Merge pull request #6777 from dotty-staging/fix-#6739
Fix #6739: Emit error on definition for inline macro implementations
2 parents 09e7e47 + b667ec3 commit 8edd676

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

compiler/src/dotty/tools/dotc/typer/PrepareInlineable.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ object PrepareInlineable {
251251
*/
252252
object InlineSplice {
253253
def unapply(tree: Tree)(implicit ctx: Context): Option[Tree] = tree match {
254-
case Spliced(code) if Splicer.canBeSpliced(code) => Some(code)
254+
case Spliced(code) if Splicer.canBeSpliced(code) =>
255+
if (code.symbol.flags.is(Inline))
256+
ctx.error("Macro cannot be implemented with an `inline` method", code.sourcePos)
257+
Some(code)
255258
case Block(List(stat), Literal(Constants.Constant(()))) => unapply(stat)
256259
case Block(Nil, expr) => unapply(expr)
257260
case Typed(expr, _) => unapply(expr)

tests/neg/i6739.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import scala.quoted._
2+
3+
inline def assert(expr: => Boolean): Unit =
4+
${ assertImpl('expr) } // error: Macro cannot be implemented with an `inline` method
5+
6+
inline def assertImpl(expr: Expr[Boolean]): Expr[Unit] = '{ println("Hello World") }

0 commit comments

Comments
 (0)