diff --git a/compiler/src/dotty/tools/dotc/Driver.scala b/compiler/src/dotty/tools/dotc/Driver.scala index 4604103d93cd..5af8252cd341 100644 --- a/compiler/src/dotty/tools/dotc/Driver.scala +++ b/compiler/src/dotty/tools/dotc/Driver.scala @@ -37,7 +37,7 @@ class Driver { val run = compiler.newRun run.compile(fileNames) - def finish(run: Run): Unit = + def finish(run: Run)(using Context): Unit = run.printSummary() if !ctx.reporter.errorsReported && run.suspendedUnits.nonEmpty then val suspendedUnits = run.suspendedUnits.toList @@ -46,7 +46,7 @@ class Driver { val run1 = compiler.newRun for unit <- suspendedUnits do unit.suspended = false run1.compileUnits(suspendedUnits) - finish(run1) + finish(run1)(using MacroClassLoader.init(ctx.fresh)) finish(run) catch diff --git a/tests/pos-macros/i9484/C.scala b/tests/pos-macros/i9484/C.scala new file mode 100644 index 000000000000..daf819cd3f96 --- /dev/null +++ b/tests/pos-macros/i9484/C.scala @@ -0,0 +1,6 @@ +import scala.quoted._ + +object C { + inline def m: Any = ${ mExpr } + def mExpr(using qctx: QuoteContext): Expr[Any] = Expr(1) +} diff --git a/tests/pos-macros/i9484/L.scala b/tests/pos-macros/i9484/L.scala new file mode 100644 index 000000000000..ce9c12566eb6 --- /dev/null +++ b/tests/pos-macros/i9484/L.scala @@ -0,0 +1,7 @@ +import scala.quoted._ + +object L { + val m = C.m +} + +class LC diff --git a/tests/pos-macros/i9484/Q.scala b/tests/pos-macros/i9484/Q.scala new file mode 100644 index 000000000000..accd4c28590f --- /dev/null +++ b/tests/pos-macros/i9484/Q.scala @@ -0,0 +1,6 @@ +import scala.quoted._ + +object Q { + inline def f(): Any = ${ fExpr } + def fExpr(using QuoteContext): Expr[Any] = { new LC; Expr(1) } +} \ No newline at end of file diff --git a/tests/pos-macros/i9484/Test.scala b/tests/pos-macros/i9484/Test.scala new file mode 100644 index 000000000000..4fe21cfcdcb4 --- /dev/null +++ b/tests/pos-macros/i9484/Test.scala @@ -0,0 +1,3 @@ +object Test extends App { + Q.f() +} diff --git a/tests/pos-macros/i9484b/C.scala b/tests/pos-macros/i9484b/C.scala new file mode 100644 index 000000000000..7021ba7dc575 --- /dev/null +++ b/tests/pos-macros/i9484b/C.scala @@ -0,0 +1,6 @@ +import scala.quoted._ + +object C { + inline def m: Any = ${ mExpr } + def mExpr(using qctx: QuoteContext): Expr[Any] = '{ () } +} diff --git a/tests/pos-macros/i9484b/Q.scala b/tests/pos-macros/i9484b/Q.scala new file mode 100644 index 000000000000..8d8a2a5461e3 --- /dev/null +++ b/tests/pos-macros/i9484b/Q.scala @@ -0,0 +1,10 @@ +import scala.quoted._ + +object Q { + inline def f(inline f: Any): Any = ${ Q2.fExpr('f) } +} + +object Q2 { + val m = C.m + def fExpr(f: Expr[Any])(using QuoteContext): Expr[Any] = '{ () } +} diff --git a/tests/pos-macros/i9484b/Test.scala b/tests/pos-macros/i9484b/Test.scala new file mode 100644 index 000000000000..59ee5cfbd8fe --- /dev/null +++ b/tests/pos-macros/i9484b/Test.scala @@ -0,0 +1,6 @@ +class TopLevelClass { + Q.f(1) +} + +val a = 1 +val b = Q.f(a)