Skip to content

Commit fb97e1d

Browse files
committed
WIP: compile libs together, load them all
1 parent 81716fc commit fb97e1d

File tree

2 files changed

+43
-7
lines changed

2 files changed

+43
-7
lines changed

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,12 @@ trait TypeAssigner {
299299
else fntpe.resultType
300300
else
301301
errorType(i"wrong number of arguments at ${ctx.phase.prev} for $fntpe: ${fn.tpe}, expected: ${fntpe.paramInfos.length}, found: ${args.length}", tree.srcPos)
302-
case t if args.isEmpty =>
303-
// NOTE this case is necessary when loading the stdlib from Tasty. Our extensions are compiled with stdlib loaded
304-
// from Scala2 classfiles while they are loaded with stdlib loaded from Tasty. This results in `def toString` being
305-
// typed as MethodType in the first case and ExprType in the second case. In the second case (and, I think, only then)
306-
// we need to handle ExprType being present here.
307-
t
302+
// case t if args.isEmpty =>
303+
// // NOTE this case is necessary when loading the stdlib from Tasty. Our extensions are compiled with stdlib loaded
304+
// // from Scala2 classfiles while they are loaded with stdlib loaded from Tasty. This results in `def toString` being
305+
// // typed as MethodType in the first case and ExprType in the second case. In the second case (and, I think, only then)
306+
// // we need to handle ExprType being present here.
307+
// t
308308
case t =>
309309
if (ctx.settings.Ydebug.value) new FatalError("").printStackTrace()
310310
errorType(err.takesNoParamsStr(fn, ""), tree.srcPos)

project/Build.scala

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,16 @@ object Build {
841841
settings(
842842
moduleName := "scala-library",
843843
javaOptions := (javaOptions in `scala3-compiler-bootstrapped`).value,
844+
Compile/scalacOptions += "-Yerased-terms",
845+
Compile/scalacOptions ++= {
846+
Seq(
847+
"-sourcepath",
848+
Seq(
849+
(Compile/sourceManaged).value / "scala-library-src",
850+
(Compile/sourceManaged).value / "dotty-library-src",
851+
).mkString(File.pathSeparator),
852+
)
853+
},
844854
scalacOptions -= "-Xfatal-warnings",
845855
ivyConfigurations += SourceDeps.hide,
846856
transitiveClassifiers := Seq("sources"),
@@ -870,6 +880,31 @@ object Build {
870880
((trgDir ** "*.scala") +++ (trgDir ** "*.java")).get.toSet
871881
} (Set(scalaLibrarySourcesJar)).toSeq
872882
}.taskValue,
883+
sourceGenerators in Compile += Def.task {
884+
val s = streams.value
885+
val cacheDir = s.cacheDirectory
886+
val trgDir = (sourceManaged in Compile).value / "dotty-library-src"
887+
888+
// NOTE `sourceDirectory` is used for actual copying,
889+
// but `sources` are used as cache keys
890+
val dottyLibSourceDir = (`scala3-library-bootstrapped`/sourceDirectory).value
891+
val dottyLibSources = (`scala3-library-bootstrapped`/Compile/sources).value
892+
893+
val cachedFun = FileFunction.cached(
894+
cacheDir / s"copyDottyLibrarySrc",
895+
FilesInfo.lastModified,
896+
FilesInfo.exists,
897+
) { _ =>
898+
s.log.info(s"Copying scala3-library sources from $dottyLibSourceDir to $trgDir...")
899+
if (trgDir.exists) IO.delete(trgDir)
900+
// IO.createDirectory(trgDir)
901+
IO.copyDirectory(dottyLibSourceDir, trgDir)
902+
903+
((trgDir ** "*.scala") +++ (trgDir ** "*.java")).get.toSet
904+
}
905+
906+
cachedFun(dottyLibSources.toSet).toSeq
907+
}.taskValue,
873908
sources in Compile ~= (_.filterNot(file =>
874909
// sources from https://github.com/scala/scala/tree/2.13.x/src/library-aux
875910
file.getPath.endsWith("scala-library-src/scala/Any.scala") ||
@@ -1555,8 +1590,9 @@ object Build {
15551590

15561591
generateScala3StdlibDocumentation:= Def.taskDyn {
15571592
val dottyJars: Seq[java.io.File] = Seq(
1558-
(`scala3-library-bootstrapped`/Compile/products).value,
15591593
(`stdlib-bootstrapped`/Compile/products).value,
1594+
(`scala3-interfaces`/Compile/products).value,
1595+
(`tasty-core-bootstrapped`/Compile/products).value,
15601596
).flatten
15611597

15621598
val roots = joinProducts(dottyJars)

0 commit comments

Comments
 (0)