diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index faff91716c4a..b3388f51fe6c 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -2082,7 +2082,7 @@ class Typer extends Namer } private def checkSpliceOutsideQuote(tree: untpd.Tree)(implicit ctx: Context): Unit = { - if (level == 0 && !ctx.owner.isInlineMethod) + if (level == 0 && !ctx.owner.ownersIterator.exists(_.is(Inline))) ctx.error("Splice ${...} outside quotes '{...} or inline method", tree.sourcePos) else if (level < 0) ctx.error( diff --git a/tests/neg/i6783.scala b/tests/neg/i6783.scala new file mode 100644 index 000000000000..55af88234692 --- /dev/null +++ b/tests/neg/i6783.scala @@ -0,0 +1,7 @@ +import scala.quoted._ + +inline def test(f: (Int, Int) => Int) = ${ // error: Malformed macro + testImpl((a: Expr[Int], b: Expr[Int]) => '{ f(${a}, ${b}) }) +} + +def testImpl(f: (Expr[Int], Expr[Int]) => Expr[Int]): Expr[Int] = ??? diff --git a/tests/pos/i6783.scala b/tests/pos/i6783.scala new file mode 100644 index 000000000000..e8945ec135be --- /dev/null +++ b/tests/pos/i6783.scala @@ -0,0 +1,7 @@ +import scala.quoted._ + +def testImpl(f: Expr[(Int, Int) => Int]): Expr[Int] = f('{1}, '{2}) + +inline def test(f: (Int, Int) => Int) = ${ + testImpl('f) +}