diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/DottyPredef.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/Compiler.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/config/ScalaSettings.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 9 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeErasure.scala | 13 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/ValueClasses.scala | 2 |
6 files changed, 25 insertions, 10 deletions
diff --git a/src/dotty/DottyPredef.scala b/src/dotty/DottyPredef.scala index b4580b6a3..4b68e4029 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.??? } diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala index 4142acfa4..93a4edd6f 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 444a1c1ae..2ad39c3c0 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.") diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 30504bc8d..275fb8257 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -370,6 +370,15 @@ object SymDenotations { final def isAnonymousModuleVal(implicit ctx: Context) = this.symbol.is(ModuleVal) && (initial.asSymDenotation.name startsWith nme.ANON_CLASS) + /** Is this a companion class method or companion object method? + * These methods are generated by Symbols#synthesizeCompanionMethod + * and used in SymDenotations#companionClass and + * SymDenotations#companionModule . + */ + final def isCompanionMethod(implicit ctx: Context) = + name.toTermName == nme.COMPANION_CLASS_METHOD || + name.toTermName == nme.COMPANION_MODULE_METHOD + /** Is symbol a primitive value class? */ def isPrimitiveValueClass(implicit ctx: Context) = defn.ScalaValueClasses contains symbol diff --git a/src/dotty/tools/dotc/core/TypeErasure.scala b/src/dotty/tools/dotc/core/TypeErasure.scala index e695e6721..71146bd4e 100644 --- a/src/dotty/tools/dotc/core/TypeErasure.scala +++ b/src/dotty/tools/dotc/core/TypeErasure.scala @@ -142,15 +142,18 @@ object TypeErasure { * - For $asInstanceOf : [T]T * - For $isInstanceOf : [T]Boolean * - For all abstract types : = ? - * - For COMPANION_CLASS_METHOD : the erasure of their type with semiEraseVCs = false, - * this is needed to keep [[SymDenotation#companionClass]] - * working after erasure for value classes. + * - For companion methods : the erasure of their type with semiEraseVCs = false. + * The signature of these methods are used to keep a + * link between companions and should not be semi-erased. + * - For Java-defined symbols: : the erasure of their type with isJava = true, + * semiEraseVCs = false. Semi-erasure never happens in Java. * - For all other symbols : the semi-erasure of their types, with * isJava, isConstructor set according to symbol. */ def transformInfo(sym: Symbol, tp: Type)(implicit ctx: Context): Type = { - val semiEraseVCs = sym.name ne nme.COMPANION_CLASS_METHOD - val erase = erasureFn(sym is JavaDefined, semiEraseVCs, sym.isConstructor, wildcardOK = false) + val isJava = sym is JavaDefined + val semiEraseVCs = !isJava && !sym.isCompanionMethod + val erase = erasureFn(isJava, semiEraseVCs, sym.isConstructor, wildcardOK = false) def eraseParamBounds(tp: PolyType): Type = tp.derivedPolyType( diff --git a/src/dotty/tools/dotc/transform/ValueClasses.scala b/src/dotty/tools/dotc/transform/ValueClasses.scala index 8969b9321..f17a0e757 100644 --- a/src/dotty/tools/dotc/transform/ValueClasses.scala +++ b/src/dotty/tools/dotc/transform/ValueClasses.scala @@ -25,7 +25,7 @@ object ValueClasses { !d.isConstructor && !d.is(SuperAccessor) && !d.is(Macro) && - !(d.name eq nme.COMPANION_MODULE_METHOD) + !d.isCompanionMethod /** The member that of a derived value class that unboxes it. */ def valueClassUnbox(d: ClassDenotation)(implicit ctx: Context): Symbol = |