Skip to content

Commit eb3c8e5

Browse files
committed
Honor -Yno-imports flag
If the flag is set, no root imports are added.
1 parent 4808d1d commit eb3c8e5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/dotty/tools/dotc/Compiler.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,11 @@ class Compiler {
103103
.setMode(Mode.ImplicitsEnabled)
104104
.setTyperState(new MutableTyperState(ctx.typerState, new ConsoleReporter()(ctx), isCommittable = true))
105105
ctx.definitions.init(start) // set context of definitions to start
106+
start.setRunInfo(new RunInfo(start))
106107
def addImport(ctx: Context, sym: Symbol) =
107108
ctx.fresh.setImportInfo(ImportInfo.rootImport(sym)(ctx))
108-
(start.setRunInfo(new RunInfo(start)) /: defn.RootImports)(addImport)
109+
if (ctx.settings.YnoImports.value) start
110+
else (start /: defn.RootImports)(addImport)
109111
}
110112

111113
def reset()(implicit ctx: Context): Unit = {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class ScalaSettings extends Settings.SettingGroup {
121121
val log = PhasesSetting("-Ylog", "Log operations during")
122122
val Ylogcp = BooleanSetting("-Ylog-classpath", "Output information about what classpath is being applied.")
123123
val Ynogenericsig = BooleanSetting("-Yno-generic-signatures", "Suppress generation of generic signatures for Java.")
124-
val noimports = BooleanSetting("-Yno-imports", "Compile without importing scala.*, java.lang.*, or Predef.")
124+
val YnoImports = BooleanSetting("-Yno-imports", "Compile without importing scala.*, java.lang.*, or Predef.")
125125
val nopredef = BooleanSetting("-Yno-predef", "Compile without importing Predef.")
126126
val noAdaptedArgs = BooleanSetting("-Yno-adapted-args", "Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver.")
127127
val selfInAnnots = BooleanSetting("-Yself-in-annots", "Include a \"self\" identifier inside of annotations.")

0 commit comments

Comments
 (0)