Skip to content

Commit c059b64

Browse files
authored
Merge pull request #6194 from dotty-staging/prepare-bootstrap
Preliminary fix needed for the full bootstrap
2 parents e4c4e0a + dc0c818 commit c059b64

File tree

11 files changed

+78
-143
lines changed

11 files changed

+78
-143
lines changed

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ val `dotty-compiler-bootstrapped` = Build.`dotty-compiler-bootstrapped`
88
val `dotty-library` = Build.`dotty-library`
99
val `dotty-library-bootstrapped` = Build.`dotty-library-bootstrapped`
1010
val `dotty-sbt-bridge` = Build.`dotty-sbt-bridge`
11+
val `dotty-sbt-bridge-tests` = Build.`dotty-sbt-bridge-tests`
1112
val `dotty-language-server` = Build.`dotty-language-server`
1213
val `dotty-bench` = Build.`dotty-bench`
1314
val `dotty-bench-bootstrapped` = Build.`dotty-bench-bootstrapped`

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,13 +1391,6 @@ class Definitions {
13911391
for (m <- ScalaShadowingPackageClass.info.decls)
13921392
ScalaPackageClass.enter(m)
13931393

1394-
// Temporary measure, as long as we do not read these classes from Tasty.
1395-
// Scala-2 classes don't have NoInits set even if they are pure. We override this
1396-
// for Product and Serializable so that case classes can be pure. A full solution
1397-
// requires that we read all Scala code from Tasty.
1398-
ProductClass.setFlag(NoInits)
1399-
SerializableClass.setFlag(NoInits)
1400-
14011394
// force initialization of every symbol that is synthesized or hijacked by the compiler
14021395
val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses()
14031396

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ object StdNames {
197197
final val Nothing: N = "Nothing"
198198
final val Null: N = "Null"
199199
final val Object: N = "Object"
200+
final val Product: N = "Product"
200201
final val PartialFunction: N = "PartialFunction"
201202
final val PrefixType: N = "PrefixType"
202203
final val S: N = "S"

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ class ClassfileParser(
804804
ctx.error("Could not load TASTY from .tasty for virtual file " + classfile)
805805
Array.empty
806806
case Some(jar: ZipArchive) => // We are in a jar
807-
val cl = new URLClassLoader(Array(jar.jpath.toUri.toURL))
807+
val cl = new URLClassLoader(Array(jar.jpath.toUri.toURL), /*parent =*/ null)
808808
val path = classfile.path.stripSuffix(".class") + ".tasty"
809809
val stream = cl.getResourceAsStream(path)
810810
if (stream != null) {

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,14 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
467467
def completeRoot(denot: ClassDenotation, completer: LazyType): Symbol = {
468468
denot.setFlag(flags)
469469
denot.resetFlag(Touched) // allow one more completion
470+
471+
// Temporary measure, as long as we do not read these classes from Tasty.
472+
// Scala-2 classes don't have NoInits set even if they are pure. We override this
473+
// for Product and Serializable so that case classes can be pure. A full solution
474+
// requires that we read all Scala code from Tasty.
475+
if (owner == defn.ScalaPackageClass && ((name eq tpnme.Serializable) || (name eq tpnme.Product)))
476+
denot.setFlag(NoInits)
477+
470478
denot.info = completer
471479
denot.symbol
472480
}

compiler/test/dotty/Properties.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package dotty
22

3+
import java.nio.file._
4+
35
/** Runtime properties from defines or environmnent */
46
object Properties {
57

@@ -36,6 +38,9 @@ object Properties {
3638
*/
3739
val testsSafeMode: Boolean = sys.props.isDefinedAt("dotty.tests.safemode")
3840

41+
/** Extra directory containing sources for the compiler */
42+
def dottyCompilerManagedSources: Path = Paths.get(sys.props("dotty.tests.dottyCompilerManagedSources"))
43+
3944
/** dotty-interfaces jar */
4045
def dottyInterfaces: String = sys.props("dotty.tests.classes.dottyInterfaces")
4146

compiler/test/dotty/tools/TestSources.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ object TestSources {
6262
(fileName.endsWith(".scala") || fileName.endsWith(".java")) && !excludedFiles.contains(fileName)
6363
}
6464

65-
assert(Files.isDirectory(path))
65+
assert(Files.isDirectory(path), s"Not a directory: $path")
6666
val files = if (shallow) Files.list(path) else Files.walk(path)
6767
try {
6868
val sources = files

compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import org.junit.experimental.categories.Category
1010
import scala.concurrent.duration._
1111
import vulpix._
1212

13+
import java.nio.file._
14+
1315
@Category(Array(classOf[BootstrappedOnlyTests]))
1416
class BootstrappedOnlyCompilationTests extends ParallelTesting {
1517
import ParallelTesting._
@@ -109,4 +111,27 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {
109111
compileDir("compiler/src/dotty/tools/dotc/core/tasty", picklingWithCompilerOptions) +
110112
compileDir("compiler/src/dotty/tools/dotc/core/unpickleScala2", picklingWithCompilerOptions)
111113
}.limitThreads(4).checkCompile()
114+
115+
@Test def testPlugins: Unit = {
116+
val pluginFile = "plugin.properties"
117+
118+
// 1. hack with absolute path for -Xplugin
119+
// 2. copy `pluginFile` to destination
120+
def compileFilesInDir(dir: String): CompilationTest = {
121+
val outDir = defaultOutputDir + "testPlugins/"
122+
val sourceDir = new java.io.File(dir)
123+
124+
val dirs = sourceDir.listFiles.toList.filter(_.isDirectory)
125+
val targets = dirs.map { dir =>
126+
val compileDir = createOutputDirsForDir(dir, sourceDir, outDir)
127+
Files.copy(dir.toPath.resolve(pluginFile), compileDir.toPath.resolve(pluginFile), StandardCopyOption.REPLACE_EXISTING)
128+
val flags = TestFlags(withCompilerClasspath, noCheckOptions).and("-Xplugin:" + compileDir.getAbsolutePath)
129+
SeparateCompilationSource("testPlugins", dir, flags, compileDir)
130+
}
131+
132+
new CompilationTest(targets)
133+
}
134+
135+
compileFilesInDir("tests/plugins/neg").checkExpectedErrors()
136+
}
112137
}

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,10 @@ class CompilationTests extends ParallelTesting {
239239
defaultOptions.and("-Ycheck-reentrant", "-strict", "-priorityclasspath", defaultOutputDir))(libGroup)
240240

241241
val compilerSources = sources(Paths.get("compiler/src"))
242+
val compilerManagedSources = sources(Properties.dottyCompilerManagedSources)
242243

243-
val scalaJSIRDir = Paths.get("compiler/target/scala-2.12/src_managed/main/scalajs-ir-src/org/scalajs/ir")
244-
val scalaJSIRSources = sources(scalaJSIRDir, shallow = true)
245-
246-
val dotty1 = compileList("dotty", compilerSources ++ scalaJSIRSources, opt)(dotty1Group)
247-
val dotty2 = compileList("dotty", compilerSources ++ scalaJSIRSources, opt)(dotty2Group)
244+
val dotty1 = compileList("dotty", compilerSources ++ compilerManagedSources, opt)(dotty1Group)
245+
val dotty2 = compileList("dotty", compilerSources ++ compilerManagedSources, opt)(dotty2Group)
248246

249247
val tests = {
250248
lib.keepOutput :: dotty1.keepOutput :: {
@@ -262,7 +260,7 @@ class CompilationTests extends ParallelTesting {
262260
compileShallowFilesInDir("compiler/src/dotty/tools/dotc/util", opt) +
263261
compileShallowFilesInDir("compiler/src/dotty/tools/backend", opt) +
264262
compileShallowFilesInDir("compiler/src/dotty/tools/backend/jvm", opt) +
265-
compileList("shallow-scalajs-ir", scalaJSIRSources, opt)
263+
compileList("managed-sources", compilerManagedSources, opt)
266264
}.keepOutput :: Nil
267265
}.map(_.checkCompile())
268266

@@ -274,29 +272,6 @@ class CompilationTests extends ParallelTesting {
274272

275273
tests.foreach(_.delete())
276274
}
277-
278-
@Test def testPlugins: Unit = {
279-
val pluginFile = "plugin.properties"
280-
281-
// 1. hack with absolute path for -Xplugin
282-
// 2. copy `pluginFile` to destination
283-
def compileFilesInDir(dir: String): CompilationTest = {
284-
val outDir = defaultOutputDir + "testPlugins/"
285-
val sourceDir = new java.io.File(dir)
286-
287-
val dirs = sourceDir.listFiles.toList.filter(_.isDirectory)
288-
val targets = dirs.map { dir =>
289-
val compileDir = createOutputDirsForDir(dir, sourceDir, outDir)
290-
Files.copy(dir.toPath.resolve(pluginFile), compileDir.toPath.resolve(pluginFile), StandardCopyOption.REPLACE_EXISTING)
291-
val flags = TestFlags(withCompilerClasspath, noCheckOptions).and("-Xplugin:" + compileDir.getAbsolutePath)
292-
SeparateCompilationSource("testPlugins", dir, flags, compileDir)
293-
}
294-
295-
new CompilationTest(targets)
296-
}
297-
298-
compileFilesInDir("tests/plugins/neg").checkExpectedErrors()
299-
}
300275
}
301276

302277
object CompilationTests {

compiler/test/dotty/tools/dotc/InterfaceEntryPointTest.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package tools.dotc
33

44
import org.junit.Test
55
import org.junit.Assert._
6+
import org.junit.experimental.categories.Category
67
import interfaces._
78
import scala.collection.mutable.ListBuffer
89
import java.nio.file._
@@ -18,6 +19,7 @@ import java.nio.file._
1819
*
1920
* @see [[OtherEntryPointsTest]]
2021
*/
22+
@Category(Array(classOf[BootstrappedOnlyTests]))
2123
class InterfaceEntryPointTest {
2224
@Test def runCompilerFromInterface = {
2325
val sources =

0 commit comments

Comments
 (0)