From eb3c8e52dadb6244645adbc1443aed96dc24402e Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 4 May 2015 13:02:49 +0200 Subject: [PATCH 1/3] Honor -Yno-imports flag If the flag is set, no root imports are added. --- src/dotty/tools/dotc/Compiler.scala | 4 +++- src/dotty/tools/dotc/config/ScalaSettings.scala | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala index 4142acfa4dc0..93a4edd6f77a 100644 --- a/src/dotty/tools/dotc/Compiler.scala +++ b/src/dotty/tools/dotc/Compiler.scala @@ -103,9 +103,11 @@ class Compiler { .setMode(Mode.ImplicitsEnabled) .setTyperState(new MutableTyperState(ctx.typerState, new ConsoleReporter()(ctx), isCommittable = true)) ctx.definitions.init(start) // set context of definitions to start + start.setRunInfo(new RunInfo(start)) def addImport(ctx: Context, sym: Symbol) = ctx.fresh.setImportInfo(ImportInfo.rootImport(sym)(ctx)) - (start.setRunInfo(new RunInfo(start)) /: defn.RootImports)(addImport) + if (ctx.settings.YnoImports.value) start + else (start /: defn.RootImports)(addImport) } def reset()(implicit ctx: Context): Unit = { diff --git a/src/dotty/tools/dotc/config/ScalaSettings.scala b/src/dotty/tools/dotc/config/ScalaSettings.scala index 444a1c1ae388..2ad39c3c0faa 100644 --- a/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -121,7 +121,7 @@ class ScalaSettings extends Settings.SettingGroup { val log = PhasesSetting("-Ylog", "Log operations during") val Ylogcp = BooleanSetting("-Ylog-classpath", "Output information about what classpath is being applied.") val Ynogenericsig = BooleanSetting("-Yno-generic-signatures", "Suppress generation of generic signatures for Java.") - val noimports = BooleanSetting("-Yno-imports", "Compile without importing scala.*, java.lang.*, or Predef.") + val YnoImports = BooleanSetting("-Yno-imports", "Compile without importing scala.*, java.lang.*, or Predef.") val nopredef = BooleanSetting("-Yno-predef", "Compile without importing Predef.") val noAdaptedArgs = BooleanSetting("-Yno-adapted-args", "Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver.") val selfInAnnots = BooleanSetting("-Yself-in-annots", "Include a \"self\" identifier inside of annotations.") From d935bb06fc6746413b3ba86ac0afe02996d4684d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 4 May 2015 13:04:20 +0200 Subject: [PATCH 2/3] Make DottyPredef compilable with -Yno-imports DottyPredef needs to be compiled with -Yno-imports because it would clash otherwise with the DottyPredef in the root context. Note that ??? has to be written in fully qualified form because of #530. --- src/dotty/DottyPredef.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dotty/DottyPredef.scala b/src/dotty/DottyPredef.scala index b4580b6a3609..4b68e4029638 100644 --- a/src/dotty/DottyPredef.scala +++ b/src/dotty/DottyPredef.scala @@ -2,9 +2,10 @@ package dotty import scala.reflect.ClassTag import scala.reflect.runtime.universe.TypeTag +import scala.Predef.??? // this is currently ineffective, because of #530 object DottyPredef { /** implicits for ClassTag and TypeTag. Should be implemented with macros */ - implicit def classTag[T]: ClassTag[T] = ??? - implicit def typeTag[T]: TypeTag[T] = ??? + implicit def classTag[T]: ClassTag[T] = scala.Predef.??? + implicit def typeTag[T]: TypeTag[T] = scala.Predef.??? } From 7500b7ff73c130a49ce6da7ad31288eb6a4e05f0 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 4 May 2015 13:04:52 +0200 Subject: [PATCH 3/3] Test case for #530: symbolic import failure. --- tests/disabled/i530-import-symbolic.scala | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/disabled/i530-import-symbolic.scala diff --git a/tests/disabled/i530-import-symbolic.scala b/tests/disabled/i530-import-symbolic.scala new file mode 100644 index 000000000000..f2c541af45c2 --- /dev/null +++ b/tests/disabled/i530-import-symbolic.scala @@ -0,0 +1,8 @@ +object P { + def !#@ : Nothing = ??? +} + +object Test { + import P.!#@ + def f = !#@ +}