Skip to content

Commit d287c70

Browse files
committed
Make -tasty a ScalaSettings flag and remove FromTasty
1 parent bb5deff commit d287c70

File tree

7 files changed

+15
-37
lines changed

7 files changed

+15
-37
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import core.Contexts.{Context, ContextBase}
66
import util.DotClass
77
import reporting._
88
import scala.util.control.NonFatal
9+
import fromtasty.TASTYCompiler
910

1011
/** Run the Dotty compiler.
1112
*
@@ -15,7 +16,9 @@ import scala.util.control.NonFatal
1516
*/
1617
class Driver extends DotClass {
1718

18-
protected def newCompiler(implicit ctx: Context): Compiler = new Compiler
19+
protected def newCompiler(implicit ctx: Context): Compiler =
20+
if (ctx.settings.tasty.value) new TASTYCompiler
21+
else new Compiler
1922

2023
protected def emptyReporter: Reporter = new StoreReporter(null)
2124

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

-23
This file was deleted.
-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package dotty.tools
22
package dotc
33

4-
import core.Contexts.Context
5-
64
/** Main class of the `dotc` batch compiler. */
75
object Main extends Driver

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

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ScalaSettings extends Settings.SettingGroup {
4343
val language = MultiStringSetting("-language", "feature", "Enable one or more language features.")
4444
val rewrite = OptionSetting[Rewrites]("-rewrite", "When used in conjunction with -language:Scala2 rewrites sources to migrate to new syntax")
4545
val silentWarnings = BooleanSetting("-nowarn", "Silence all warnings.")
46+
val tasty = BooleanSetting("-tasty", "Compile classes from tasty in classpath. The arguments are used as class names.")
4647

4748
/** -X "Advanced" settings
4849
*/

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
395395
protected def compileFromTasty(flags0: TestFlags, suppressErrors: Boolean, targetDir: JFile): TestReporter = {
396396
val tastyOutput = new JFile(targetDir.getPath + "_from-tasty")
397397
tastyOutput.mkdir()
398-
val flags = flags0 and ("-d", tastyOutput.getAbsolutePath)
398+
val flags = flags0 and ("-d", tastyOutput.getAbsolutePath) and "-tasty"
399399

400400
def hasTastyFileToClassName(f: JFile): String =
401401
targetDir.toPath.relativize(f.toPath).toString.dropRight(".hasTasty".length).replace('/', '.')
@@ -405,9 +405,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
405405
TestReporter.reporter(realStdout, logLevel =
406406
if (suppressErrors || suppressAllOutput) ERROR + 1 else ERROR)
407407

408+
val driver = new Driver
409+
408410
// Compile with a try to catch any StackTrace generated by the compiler:
409411
try {
410-
dotc.FromTasty.process(flags.all ++ classes, reporter = reporter)
412+
driver.process(flags.all ++ classes, reporter = reporter)
411413
}
412414
catch {
413415
case NonFatal(ex) => reporter.logStackTrace(ex)

dist/bin/dotc

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ default_java_opts="-Xmx768m -Xms768m"
3131
bootcp=true
3232

3333
CompilerMain=dotty.tools.dotc.Main
34-
FromTasty=dotty.tools.dotc.FromTasty
3534
ReplMain=dotty.tools.repl.Main
3635

3736
PROG_NAME=$CompilerMain
@@ -82,7 +81,7 @@ case "$1" in
8281
# Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222
8382
-Oshort) addJava "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" && shift ;;
8483
-repl) PROG_NAME="$ReplMain" && shift ;;
85-
-tasty) addScala "-Yretain-trees" && PROG_NAME="$FromTasty" && shift ;;
84+
-tasty) addScala "-Yretain-trees" && PROG_NAME="$CompilerMain" && shift ;;
8685
-compile) PROG_NAME="$CompilerMain" && shift ;;
8786
-run) PROG_NAME="$ReplMain" && shift ;;
8887
-bootcp) bootcp=true && shift ;;

project/Build.scala

+5-7
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,8 @@ object Build {
523523
}
524524
},
525525
run := dotc.evaluated,
526-
dotc := runCompilerMain(Nil).evaluated,
527-
repl := runCompilerMain(List("-repl")).evaluated,
526+
dotc := runCompilerMain(false).evaluated,
527+
repl := runCompilerMain(true).evaluated,
528528

529529
// enable verbose exception messages for JUnit
530530
testOptions in Test += Tests.Argument(
@@ -618,17 +618,15 @@ object Build {
618618
}
619619
)
620620

621-
def runCompilerMain(otherArgs: List[String]) = Def.inputTaskDyn {
621+
def runCompilerMain(repl: Boolean) = Def.inputTaskDyn {
622622
val dottyLib = packageAll.value("dotty-library")
623-
val args0: List[String] = spaceDelimited("<arg>").parsed.toList ++ otherArgs
624-
val args = args0.filter(arg => arg != "-tasty" && arg != "-repl")
623+
val args0: List[String] = spaceDelimited("<arg>").parsed.toList
624+
val args = args0.filter(arg => arg != "-repl")
625625

626-
val repl = args0.contains("-repl")
627626
val tasty = args0.contains("-tasty")
628627

629628
val main =
630629
if (repl) "dotty.tools.repl.Main"
631-
else if (tasty) "dotty.tools.dotc.FromTasty"
632630
else "dotty.tools.dotc.Main"
633631

634632
val extraArgs =

0 commit comments

Comments
 (0)