Skip to content

Commit 23344d6

Browse files
committed
Fix tests
1 parent 897fc8d commit 23344d6

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

compiler/src/dotty/tools/dotc/transform/Splicer.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,14 @@ object Splicer {
201201
else if (fn.symbol.is(Module))
202202
interpretModuleAccess(fn.symbol)
203203
else if (fn.symbol.isStatic) {
204-
val staticMethodCall = interpretedStaticMethodCall(fn.symbol.owner, fn.symbol, tree.sourcePos)
204+
val staticMethodCall = interpretedStaticMethodCall(fn.symbol.owner, fn.symbol, tree)
205205
staticMethodCall(args.flatten.map(interpretTree))
206206
}
207207
else if (fn.qualifier.symbol.is(Module) && fn.qualifier.symbol.isStatic)
208208
if (fn.name == nme.asInstanceOfPM)
209209
interpretModuleAccess(fn.qualifier.symbol)
210210
else {
211-
val staticMethodCall = interpretedStaticMethodCall(fn.qualifier.symbol.moduleClass, fn.symbol, tree.sourcePos)
211+
val staticMethodCall = interpretedStaticMethodCall(fn.qualifier.symbol.moduleClass, fn.symbol, tree)
212212
staticMethodCall(args.flatten.map(interpretTree))
213213
}
214214
else if (env.contains(fn.symbol))
@@ -266,10 +266,10 @@ object Splicer {
266266
private def interpretQuoteContext()(implicit env: Env): Object =
267267
QuoteContext()
268268

269-
private def interpretedStaticMethodCall(moduleClass: Symbol, fn: Symbol, pos: SourcePosition)(implicit env: Env): List[Object] => Object = {
269+
private def interpretedStaticMethodCall(moduleClass: Symbol, fn: Symbol, tree: Tree)(implicit env: Env): List[Object] => Object = {
270270
if fn.isDefinedInCurrentRun then
271271
if ctx.compilationUnit.source.file == fn.associatedFile then
272-
ctx.error("Cannot call macro defined in the same source file", pos)
272+
ctx.error(em"Cannot call macro $fn defined in the same source file", tree.sourcePos)
273273
ctx.compilationUnit.suspend()
274274

275275
val (inst, clazz) =

compiler/src/dotty/tools/dotc/util/SourcePosition.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ extends interfaces.SourcePosition with Showable {
6161
def focus : SourcePosition = withSpan(span.focus)
6262
def toSynthetic: SourcePosition = withSpan(span.toSynthetic)
6363

64+
def outermost: SourcePosition =
65+
if outer == null || outer == NoSourcePosition then this else outer.outermost
66+
6467
override def toString: String =
6568
s"${if (source.exists) source.file.toString else "(no source)"}:$span"
6669

tests/neg/macro-cycle1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import scala.quoted.{Expr, QuoteContext}
22
object Test {
33
def fooImpl(given QuoteContext): Expr[Unit] = '{println("hi")}
44

5-
inline def foo: Unit = ${fooImpl}
5+
inline def foo: Unit = ${fooImpl} // error
66

7-
foo // error
7+
foo
88
}

0 commit comments

Comments
 (0)