diff --git a/compiler/src/dotty/tools/backend/jvm/CodeGen.scala b/compiler/src/dotty/tools/backend/jvm/CodeGen.scala index 0888c60fd5c8..0faca328c1d2 100644 --- a/compiler/src/dotty/tools/backend/jvm/CodeGen.scala +++ b/compiler/src/dotty/tools/backend/jvm/CodeGen.scala @@ -72,7 +72,13 @@ class CodeGen(val int: DottyBackendInterface, val primitives: DottyPrimitives)( genTastyAndSetAttributes(sym, tastyAttrNode) def registerGeneratedClass(classNode: ClassNode, isArtifact: Boolean): Unit = - generatedClasses += GeneratedClass(classNode, sym.javaClassName, sym.srcPos.sourcePos, isArtifact, onFileCreated(classNode, sym, unit.source)) + if classNode ne null then + generatedClasses += GeneratedClass(classNode, + sourceClassName = sym.javaClassName, + position = sym.srcPos.sourcePos, + isArtifact = isArtifact, + onFileCreated = onFileCreated(classNode, sym, unit.source) + ) registerGeneratedClass(mainClassNode, isArtifact = false) registerGeneratedClass(mirrorClassNode, isArtifact = true) diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 4f7d3fc3f241..824a3bc4ad04 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -18,6 +18,7 @@ import scala.concurrent.duration._ import TestSources.sources import reporting.TestReporter import vulpix._ +import dotty.tools.dotc.config.ScalaSettings class CompilationTests { import ParallelTesting._ @@ -212,7 +213,6 @@ class CompilationTests { compileFilesInDir("tests/init/warn", defaultOptions.and("-Ysafe-init")).checkWarnings() compileFilesInDir("tests/init/pos", options).checkCompile() compileFilesInDir("tests/init/crash", options.without("-Xfatal-warnings")).checkCompile() - // The regression test for i12128 has some atypical classpath requirements. // The test consists of three files: (a) Reflect_1 (b) Macro_2 (c) Test_3 // which must be compiled separately. In addition: @@ -234,6 +234,38 @@ class CompilationTests { tests.foreach(_.delete()) } } + + // parallel backend tests + @Test def parallelBackend: Unit = { + given TestGroup = TestGroup("parallelBackend") + val parallelism = Runtime.getRuntime().availableProcessors().min(16) + assumeTrue("Not enough available processors to run parallel tests", parallelism > 1) + + val options = defaultOptions.and(s"-Ybackend-parallelism:${parallelism}") + def parCompileDir(directory: String) = compileDir(directory, options) + + // Compilation units containing more than 1 source file + aggregateTests( + parCompileDir("tests/pos/i10477"), + parCompileDir("tests/pos/i4758"), + parCompileDir("tests/pos/scala2traits"), + parCompileDir("tests/pos/class-gadt"), + parCompileDir("tests/pos/tailcall"), + parCompileDir("tests/pos/reference"), + parCompileDir("tests/pos/pos_valueclasses") + ).checkCompile() + + aggregateTests( + parCompileDir("tests/neg/package-implicit"), + parCompileDir("tests/neg/package-export") + ).checkExpectedErrors() + + aggregateTests( + parCompileDir("tests/run/decorators"), + parCompileDir("tests/run/generic") + ).checkRuns() + + } } object CompilationTests extends ParallelTesting {