Skip to content

Commit e611b33

Browse files
committed
Properly look for inline methods
This fixes a false positive where we mistakenly interpreted an `inline val` as an inline method. Fixes #14679
1 parent 400427d commit e611b33

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ trait QuotesAndSplices {
192192
assignType(tree, tpt)
193193

194194
private def checkSpliceOutsideQuote(tree: untpd.Tree)(using Context): Unit =
195-
if (level == 0 && !ctx.owner.ownersIterator.exists(_.is(Inline)))
195+
if (level == 0 && !ctx.owner.ownersIterator.exists(_.isInlineMethod))
196196
report.error("Splice ${...} outside quotes '{...} or inline method", tree.srcPos)
197197
else if (level < 0)
198198
report.error(

tests/neg-macros/i14679.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import scala.quoted.*
2+
3+
object A {
4+
inline val a = ${b} // error
5+
6+
def b(using Quotes): Expr[Unit] = '{ () }
7+
}

0 commit comments

Comments
 (0)