Skip to content

Fix #9484: Use new macro classloader to process suspended units #9491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/Driver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions tests/pos-macros/i9484/C.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import scala.quoted._

object C {
inline def m: Any = ${ mExpr }
def mExpr(using qctx: QuoteContext): Expr[Any] = Expr(1)
}
7 changes: 7 additions & 0 deletions tests/pos-macros/i9484/L.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import scala.quoted._

object L {
val m = C.m
}

class LC
6 changes: 6 additions & 0 deletions tests/pos-macros/i9484/Q.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import scala.quoted._

object Q {
inline def f(): Any = ${ fExpr }
def fExpr(using QuoteContext): Expr[Any] = { new LC; Expr(1) }
}
3 changes: 3 additions & 0 deletions tests/pos-macros/i9484/Test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Test extends App {
Q.f()
}
6 changes: 6 additions & 0 deletions tests/pos-macros/i9484b/C.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import scala.quoted._

object C {
inline def m: Any = ${ mExpr }
def mExpr(using qctx: QuoteContext): Expr[Any] = '{ () }
}
10 changes: 10 additions & 0 deletions tests/pos-macros/i9484b/Q.scala
Original file line number Diff line number Diff line change
@@ -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] = '{ () }
}
6 changes: 6 additions & 0 deletions tests/pos-macros/i9484b/Test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class TopLevelClass {
Q.f(1)
}

val a = 1
val b = Q.f(a)