Skip to content

Commit 6837f23

Browse files
committed
Test stdlib from TASTy directly from Jar
Passing the class names will no be supported in the future.
1 parent 0bd50d3 commit 6837f23

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

compiler/src/dotty/tools/dotc/Driver.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class Driver {
8686
protected def fromTastySetup(fileNames0: List[String], ctx0: Context): (List[String], Context) =
8787
given Context = ctx0
8888
if (ctx0.settings.fromTasty.value) {
89+
val fromTastyBlacklist = ctx0.settings.YfromTastyBlacklist.value.toSet
8990
// Resolve classpath and class names of tasty files
9091
val (classPaths, classNames) = fileNames0.flatMap { name =>
9192
val path = Paths.get(name)
@@ -96,7 +97,7 @@ class Driver {
9697
Nil
9798
else if name.endsWith(".jar") then
9899
new dotty.tools.io.Jar(File(name)).toList.collect {
99-
case e if e.getName.endsWith(".tasty") =>
100+
case e if e.getName.endsWith(".tasty") && !fromTastyBlacklist(e.getName) =>
100101
(name, e.getName.stripSuffix(".tasty").replace("/", "."))
101102
}
102103
else

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ScalaSettings extends Settings.SettingGroup {
4545
val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.") withAbbreviation "--language"
4646
val rewrite: Setting[Option[Rewrites]] = OptionSetting[Rewrites]("-rewrite", "When used in conjunction with a `...-migration` source version, rewrites sources to migrate to new version.") withAbbreviation "--rewrite"
4747
val silentWarnings: Setting[Boolean] = BooleanSetting("-nowarn", "Silence all warnings.") withAbbreviation "--no-warnings"
48-
val fromTasty: Setting[Boolean] = BooleanSetting("-from-tasty", "Compile classes from tasty in classpath. The arguments are used as class names.") withAbbreviation "--from-tasty"
48+
val fromTasty: Setting[Boolean] = BooleanSetting("-from-tasty", "Compile classes from tasty files. The arguments are .tasty or .jar files.") withAbbreviation "--from-tasty"
4949

5050
val newSyntax: Setting[Boolean] = BooleanSetting("-new-syntax", "Require `then` and `do` in control expressions.")
5151
val oldSyntax: Setting[Boolean] = BooleanSetting("-old-syntax", "Require `(...)` around conditions.")
@@ -158,6 +158,7 @@ class ScalaSettings extends Settings.SettingGroup {
158158
val YretainTrees: Setting[Boolean] = BooleanSetting("-Yretain-trees", "Retain trees for top-level classes, accessible from ClassSymbol#tree")
159159
val Ysemanticdb: Setting[Boolean] = BooleanSetting("-Ysemanticdb", "Store information in SemanticDB.")
160160
val YshowTreeIds: Setting[Boolean] = BooleanSetting("-Yshow-tree-ids", "Uniquely tag all tree nodes in debugging output.")
161+
val YfromTastyBlacklist: Setting[List[String]] = MultiStringSetting("-Yfrom-tasty-blacklist", "file", "List of `tasty` files in jar files that will not be loaded when using -from-tasty")
161162

162163
val YprofileEnabled: Setting[Boolean] = BooleanSetting("-Yprofile-enabled", "Enable profiling.")
163164
val YprofileDestination: Setting[String] = StringSetting("-Yprofile-destination", "file", "Where to send profiling output - specify a file, default is to the console.", "")

stdlib-bootstrapped-tasty-tests/test/BootstrappedStdLibTASYyTest.scala

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import dotty.tools.dotc.util.ClasspathFromClassloader
1010
import scala.quoted._
1111

1212
import java.io.File.pathSeparator
13+
import java.io.File.separator
1314

1415
class BootstrappedStdLibTASYyTest:
1516

@@ -23,13 +24,6 @@ class BootstrappedStdLibTASYyTest:
2324
@Test def testFromTasty: Unit =
2425
compileFromTasty(loadBlacklisted.union(compileBlacklisted))
2526

26-
@Ignore
27-
@Test def testWhiteListFromTasty: Unit =
28-
val whitelist = Set(
29-
"scala.collection.mutable.StringBuilder"
30-
)
31-
compileFromTasty(x => !whitelist(x))
32-
3327
@Test def blacklistNoDuplicates =
3428
def testDup(name: String, list: List[String], set: Set[String]) =
3529
assert(list.size == set.size,
@@ -111,15 +105,17 @@ object BootstrappedStdLibTASYyTest:
111105
val hasErrors = inspector.inspectTastyFilesInJar(scalaLibJarPath)
112106
assert(!hasErrors, "Errors reported while loading from TASTy")
113107

114-
def compileFromTasty(blacklisted: String => Boolean): Unit = {
108+
def compileFromTasty(blacklisted: Iterable[String]): Unit = {
115109
val driver = new dotty.tools.dotc.Driver
116-
val currentClasspath = ClasspathFromClassloader(getClass.getClassLoader)
117-
val classNames = scalaLibJarTastyClassNames.filterNot(blacklisted)
110+
val yFromTastyBlacklist =
111+
blacklisted.map(x => x.replace(".", separator) + ".tasty").mkString("-Yfrom-tasty-blacklist:", ",", "")
118112
val args = Array(
119-
"-classpath", s"$scalaLibJarPath$pathSeparator$currentClasspath",
113+
"-classpath", ClasspathFromClassloader(getClass.getClassLoader),
120114
"-from-tasty",
121-
"-nowarn"
122-
) ++ classNames
115+
"-nowarn",
116+
yFromTastyBlacklist,
117+
scalaLibJarPath,
118+
)
123119
val reporter = driver.process(args)
124120
assert(reporter.errorCount == 0, "Errors while re-compiling")
125121
}

0 commit comments

Comments
 (0)