Skip to content

Commit e436d28

Browse files
committed
Add output as macro classpath for suspended compilation
1 parent e440974 commit e436d28

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/core/MacroClassLoader.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ object MacroClassLoader {
2121

2222
private def makeMacroClassLoader(implicit ctx: Context): ClassLoader = trace("new macro class loader") {
2323
val urls = ctx.settings.classpath.value.split(java.io.File.pathSeparatorChar).map(cp => java.nio.file.Paths.get(cp).toUri.toURL)
24-
new java.net.URLClassLoader(urls, getClass.getClassLoader)
24+
val out = ctx.settings.outputDir.value.jpath.toUri.toURL // to find classes in case of suspended compilation
25+
new java.net.URLClassLoader(urls :+ out, getClass.getClassLoader)
2526
}
2627
}

project/scripts/cmdTests

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ clear_out "$OUT"
3737
"$SBT" ";dotc -d $OUT/out.jar $SOURCE; dotc -decompile -classpath $OUT/out.jar -color:never $MAIN" > "$tmp"
3838
grep -qe "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "$tmp"
3939

40+
echo "testing sbt dotc with suspension"
41+
clear_out "$OUT"
42+
"$SBT" "dotc -d $OUT/out.jar tests/pos-macros/macros-in-same-project-1/Bar.scala tests/pos-macros/macros-in-same-project-1/Foo.scala" > "$tmp"
43+
4044
# check that missing source file does not crash message rendering
4145
echo "testing that missing source file does not crash message rendering"
4246
clear_out "$OUT"

0 commit comments

Comments
 (0)