diff --git a/.gitignore b/.gitignore index ae37d91100a3..961390f64f99 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,7 @@ compiler/test/debug/Gen.jar compiler/before-pickling.txt compiler/after-pickling.txt +bench/compile.txt *.dotty-ide-version *.decompiled.out diff --git a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala index 75efba2b1ef6..7db9614b1aad 100644 --- a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala +++ b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala @@ -365,7 +365,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma def getAnnotPickle(jclassName: String, sym: Symbol): Option[Annotation] = None - def getRequiredClass(fullname: String): Symbol = ctx.requiredClass(fullname.toTermName) + def getRequiredClass(fullname: String): Symbol = ctx.requiredClass(fullname) def getClassIfDefined(fullname: String): Symbol = NoSymbol // used only for android. todo: implement @@ -375,12 +375,12 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma } def requiredClass[T](implicit evidence: ClassTag[T]): Symbol = - ctx.requiredClass(erasureString(evidence.runtimeClass).toTermName) + ctx.requiredClass(erasureString(evidence.runtimeClass)) def requiredModule[T](implicit evidence: ClassTag[T]): Symbol = { val moduleName = erasureString(evidence.runtimeClass) val className = if (moduleName.endsWith("$")) moduleName.dropRight(1) else moduleName - ctx.requiredModule(className.toTermName) + ctx.requiredModule(className) } @@ -1193,8 +1193,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma val arity = field.meth.tpe.widenDealias.paramTypes.size - _1.size val returnsUnit = field.meth.tpe.widenDealias.resultType.classSymbol == UnitClass if (returnsUnit) - ctx.requiredClass(("scala.compat.java8.JProcedure" + arity).toTermName) - else ctx.requiredClass(("scala.compat.java8.JFunction" + arity).toTermName) + ctx.requiredClass(("scala.compat.java8.JProcedure" + arity)) + else ctx.requiredClass(("scala.compat.java8.JFunction" + arity)) } } } diff --git a/compiler/src/dotty/tools/dotc/Run.scala b/compiler/src/dotty/tools/dotc/Run.scala index 85e253cadcd8..6316ad9399ac 100644 --- a/compiler/src/dotty/tools/dotc/Run.scala +++ b/compiler/src/dotty/tools/dotc/Run.scala @@ -44,7 +44,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint */ protected[this] def rootContext(implicit ctx: Context): Context = { ctx.initialize()(ctx) - ctx.setPhasePlan(comp.phases) + ctx.base.setPhasePlan(comp.phases) val rootScope = new MutableScope val bootstrap = ctx.fresh .setPeriod(Period(comp.nextRunId, FirstPhaseId)) @@ -149,7 +149,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint protected def compileUnits()(implicit ctx: Context) = Stats.maybeMonitored { if (!ctx.mode.is(Mode.Interactive)) // IDEs might have multi-threaded access, accesses are synchronized - ctx.checkSingleThreaded() + ctx.base.checkSingleThreaded() compiling = true @@ -158,16 +158,16 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint if (ctx.settings.YtestPickler.value) List("pickler") else ctx.settings.YstopAfter.value - val pluginPlan = ctx.addPluginPhases(ctx.phasePlan) - val phases = ctx.squashPhases(pluginPlan, + val pluginPlan = ctx.addPluginPhases(ctx.base.phasePlan) + val phases = ctx.base.squashPhases(pluginPlan, ctx.settings.Yskip.value, ctx.settings.YstopBefore.value, stopAfter, ctx.settings.Ycheck.value) - ctx.usePhases(phases) + ctx.base.usePhases(phases) def runPhases(implicit ctx: Context) = { var lastPrintedTree: PrintedTree = NoPrintedTree val profiler = ctx.profiler - for (phase <- ctx.allPhases) + for (phase <- ctx.base.allPhases) if (phase.isRunnable) Stats.trackTime(s"$phase ms ") { val start = System.currentTimeMillis @@ -228,7 +228,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint private def printTree(last: PrintedTree)(implicit ctx: Context): PrintedTree = { val unit = ctx.compilationUnit val prevPhase = ctx.phase.prev // can be a mini-phase - val squashedPhase = ctx.squashed(prevPhase) + val squashedPhase = ctx.base.squashed(prevPhase) val treeString = unit.tpdTree.show(ctx.withProperty(XprintMode, Some(()))) ctx.echo(s"result of $unit after $squashedPhase:") @@ -274,4 +274,4 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint myUnits = null myUnitsCached = null } -} \ No newline at end of file +} diff --git a/compiler/src/dotty/tools/dotc/ast/Trees.scala b/compiler/src/dotty/tools/dotc/ast/Trees.scala index 0f512627a4d4..8c23a4a26c42 100644 --- a/compiler/src/dotty/tools/dotc/ast/Trees.scala +++ b/compiler/src/dotty/tools/dotc/ast/Trees.scala @@ -79,7 +79,7 @@ object Trees { /** The type constructor at the root of the tree */ type ThisTree[T >: Untyped] <: Tree[T] - private[this] var myTpe: T = _ + protected var myTpe: T @uncheckedVariance = _ /** Destructively set the type of the tree. This should be called only when it is known that * it is safe under sharing to do so. One use-case is in the withType method below @@ -92,7 +92,7 @@ object Trees { /** The type of the tree. In case of an untyped tree, * an UnAssignedTypeException is thrown. (Overridden by empty trees) */ - def tpe: T @uncheckedVariance = { + final def tpe: T @uncheckedVariance = { if (myTpe == null) throw new UnAssignedTypeException(this) myTpe @@ -756,7 +756,6 @@ object Trees { } trait WithoutTypeOrPos[-T >: Untyped] extends Tree[T] { - override def tpe: T @uncheckedVariance = NoType.asInstanceOf[T] override def withTypeUnchecked(tpe: Type) = this.asInstanceOf[ThisTree[Type]] override def pos = NoPosition override def setPos(pos: Position) = {} @@ -769,6 +768,8 @@ object Trees { */ case class Thicket[-T >: Untyped](trees: List[Tree[T]]) extends Tree[T] with WithoutTypeOrPos[T] { + myTpe = NoType.asInstanceOf[T] + type ThisTree[-T >: Untyped] = Thicket[T] override def isEmpty: Boolean = trees.isEmpty override def toList: List[Tree[T]] = flatten(trees) @@ -787,6 +788,7 @@ object Trees { class EmptyValDef[T >: Untyped] extends ValDef[T]( nme.WILDCARD, genericEmptyTree[T], genericEmptyTree[T]) with WithoutTypeOrPos[T] { + myTpe = NoType.asInstanceOf[T] override def isEmpty: Boolean = true setMods(untpd.Modifiers(PrivateLocal)) } diff --git a/compiler/src/dotty/tools/dotc/classpath/AggregateClassPath.scala b/compiler/src/dotty/tools/dotc/classpath/AggregateClassPath.scala index a6d22a9719c8..227282ff9ebd 100644 --- a/compiler/src/dotty/tools/dotc/classpath/AggregateClassPath.scala +++ b/compiler/src/dotty/tools/dotc/classpath/AggregateClassPath.scala @@ -70,7 +70,7 @@ case class AggregateClassPath(aggregates: Seq[ClassPath]) extends ClassPath { override private[dotty] def list(inPackage: String): ClassPathEntries = { val (packages, classesAndSources) = aggregates.map { cp => try { - cp.list(inPackage) + cp.list(inPackage).toTuple } catch { case ex: java.io.IOException => val e = new FatalError(ex.getMessage) diff --git a/compiler/src/dotty/tools/dotc/classpath/ClassPath.scala b/compiler/src/dotty/tools/dotc/classpath/ClassPath.scala index 89c68ae67112..06a465530db3 100644 --- a/compiler/src/dotty/tools/dotc/classpath/ClassPath.scala +++ b/compiler/src/dotty/tools/dotc/classpath/ClassPath.scala @@ -6,12 +6,8 @@ package dotty.tools.dotc.classpath import dotty.tools.io.AbstractFile import dotty.tools.io.ClassRepresentation -case class ClassPathEntries(packages: Seq[PackageEntry], classesAndSources: Seq[ClassRepresentation]) - -object ClassPathEntries { - import scala.language.implicitConversions - // to have working unzip method - implicit def entry2Tuple(entry: ClassPathEntries): (Seq[PackageEntry], Seq[ClassRepresentation]) = (entry.packages, entry.classesAndSources) +case class ClassPathEntries(packages: Seq[PackageEntry], classesAndSources: Seq[ClassRepresentation]) { + def toTuple = (packages, classesAndSources) } trait ClassFileEntry extends ClassRepresentation { diff --git a/compiler/src/dotty/tools/dotc/core/Contexts.scala b/compiler/src/dotty/tools/dotc/core/Contexts.scala index cb3272a3cdb3..cf4da2cba87a 100644 --- a/compiler/src/dotty/tools/dotc/core/Contexts.scala +++ b/compiler/src/dotty/tools/dotc/core/Contexts.scala @@ -428,6 +428,32 @@ object Contexts { "Context(\n" + (outersIterator map ( ctx => s" owner = ${ctx.owner}, scope = ${ctx.scope}, import = ${iinfo(ctx)}") mkString "\n") } + + def typerPhase = base.typerPhase + def sbtExtractDependenciesPhase = base.sbtExtractDependenciesPhase + def picklerPhase = base.picklerPhase + def refchecksPhase = base.refchecksPhase + def patmatPhase = base.patmatPhase + def elimRepeatedPhase = base.elimRepeatedPhase + def extensionMethodsPhase = base.extensionMethodsPhase + def explicitOuterPhase = base.explicitOuterPhase + def gettersPhase = base.gettersPhase + def erasurePhase = base.erasurePhase + def elimErasedValueTypePhase = base.elimErasedValueTypePhase + def lambdaLiftPhase = base.lambdaLiftPhase + def flattenPhase = base.flattenPhase + def genBCodePhase = base.genBCodePhase + def phases = base.phases + + def settings = base.settings + def definitions = base.definitions + def platform = base.platform + def pendingUnderlying = base.pendingUnderlying + def uniqueNamedTypes = base.uniqueNamedTypes + def uniques = base.uniques + def nextId = base.nextId + + def initialize()(implicit ctx: Context) = base.initialize()(ctx) } /** A condensed context provides only a small memory footprint over @@ -520,7 +546,7 @@ object Contexts { /** A class defining the initial context with given context base * and set of possible settings. */ - private class InitialContext(val base: ContextBase, settings: SettingGroup) extends FreshContext { + private class InitialContext(val base: ContextBase, settingsGroup: SettingGroup) extends FreshContext { outer = NoContext period = InitialPeriod mode = Mode.None @@ -529,7 +555,7 @@ object Contexts { tree = untpd.EmptyTree typeAssigner = TypeAssigner moreProperties = Map.empty - store = initialStore.updated(settingsStateLoc, settings.defaultState) + store = initialStore.updated(settingsStateLoc, settingsGroup.defaultState) typeComparer = new TypeComparer(this) searchHistory = new SearchHistory(0, Map()) gadt = EmptyGADTMap @@ -684,17 +710,6 @@ object Contexts { else assert(thread == Thread.currentThread(), "illegal multithreaded access to ContextBase") } - object Context { - - /** Implicit conversion that injects all printer operations into a context */ - implicit def toPrinter(ctx: Context): Printer = ctx.printer - - /** implicit conversion that injects all ContextBase members into a context */ - implicit def toBase(ctx: Context): ContextBase = ctx.base - - // @sharable val theBase = new ContextBase // !!! DEBUG, so that we can use a minimal context for reporting even in code that normally cannot access a context - } - class GADTMap(initBounds: SimpleIdentityMap[Symbol, TypeBounds]) extends util.DotClass { private[this] var myBounds = initBounds def setBounds(sym: Symbol, b: TypeBounds): Unit = diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index d8e9ebef4258..c1ce001c4ecf 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -188,19 +188,19 @@ class Definitions { } lazy val RootClass: ClassSymbol = ctx.newPackageSymbol( - NoSymbol, nme.ROOT, (root, rootcls) => ctx.rootLoader(root)).moduleClass.asClass + NoSymbol, nme.ROOT, (root, rootcls) => ctx.base.rootLoader(root)).moduleClass.asClass lazy val RootPackage: TermSymbol = ctx.newSymbol( NoSymbol, nme.ROOTPKG, PackageCreationFlags, TypeRef(NoPrefix, RootClass)) lazy val EmptyPackageVal = ctx.newPackageSymbol( - RootClass, nme.EMPTY_PACKAGE, (emptypkg, emptycls) => ctx.rootLoader(emptypkg)).entered + RootClass, nme.EMPTY_PACKAGE, (emptypkg, emptycls) => ctx.base.rootLoader(emptypkg)).entered lazy val EmptyPackageClass = EmptyPackageVal.moduleClass.asClass /** A package in which we can place all methods that are interpreted specially by the compiler */ lazy val OpsPackageVal = ctx.newCompletePackageSymbol(RootClass, nme.OPS_PACKAGE).entered lazy val OpsPackageClass = OpsPackageVal.moduleClass.asClass - lazy val ScalaPackageVal = ctx.requiredPackage("scala") + lazy val ScalaPackageVal = ctx.requiredPackage(nme.scala_) lazy val ScalaMathPackageVal = ctx.requiredPackage("scala.math") lazy val ScalaPackageClass = { val cls = ScalaPackageVal.moduleClass.asClass @@ -211,8 +211,8 @@ class Definitions { cls } lazy val ScalaPackageObjectRef = ctx.requiredModuleRef("scala.package") - lazy val JavaPackageVal = ctx.requiredPackage("java") - lazy val JavaLangPackageVal = ctx.requiredPackage("java.lang") + lazy val JavaPackageVal = ctx.requiredPackage(nme.java) + lazy val JavaLangPackageVal = ctx.requiredPackage(jnme.JavaLang) // fundamental modules lazy val SysPackage = ctx.requiredModule("scala.sys.package") lazy val Sys_errorR = SysPackage.moduleClass.requiredMethodRef(nme.error) @@ -342,11 +342,11 @@ class Definitions { lazy val Predef_ConformsR = ScalaPredefModule.requiredClass("<:<").typeRef def Predef_Conforms(implicit ctx: Context) = Predef_ConformsR.symbol - lazy val Predef_conformsR = ScalaPredefModule.requiredMethodRef("$conforms") + lazy val Predef_conformsR = ScalaPredefModule.requiredMethodRef(nme.conforms_) def Predef_conforms(implicit ctx: Context) = Predef_conformsR.symbol - lazy val Predef_classOfR = ScalaPredefModule.requiredMethodRef("classOf") + lazy val Predef_classOfR = ScalaPredefModule.requiredMethodRef(nme.classOf) def Predef_classOf(implicit ctx: Context) = Predef_classOfR.symbol - lazy val Predef_undefinedR = ScalaPredefModule.requiredMethodRef("???") + lazy val Predef_undefinedR = ScalaPredefModule.requiredMethodRef(nme.???) def Predef_undefined(implicit ctx: Context) = Predef_undefinedR.symbol lazy val ScalaRuntimeModuleRef = ctx.requiredModuleRef("scala.runtime.ScalaRunTime") diff --git a/compiler/src/dotty/tools/dotc/core/DenotTransformers.scala b/compiler/src/dotty/tools/dotc/core/DenotTransformers.scala index 192e2547a57d..5ec1620a77f1 100644 --- a/compiler/src/dotty/tools/dotc/core/DenotTransformers.scala +++ b/compiler/src/dotty/tools/dotc/core/DenotTransformers.scala @@ -22,7 +22,7 @@ object DenotTransformers { trait DenotTransformer extends Phase { /** The last phase during which the transformed denotations are valid */ - def lastPhaseId(implicit ctx: Context) = ctx.nextDenotTransformerId(id + 1) + def lastPhaseId(implicit ctx: Context) = ctx.base.nextDenotTransformerId(id + 1) /** The validity period of the transformed denotations in the given context */ def validFor(implicit ctx: Context): Period = diff --git a/compiler/src/dotty/tools/dotc/core/Denotations.scala b/compiler/src/dotty/tools/dotc/core/Denotations.scala index c84313ccae0e..82f071859a5d 100644 --- a/compiler/src/dotty/tools/dotc/core/Denotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Denotations.scala @@ -23,6 +23,7 @@ import config.Config import util.common._ import collection.mutable.ListBuffer import Decorators.SymbolIteratorDecorator +import SymDenotations.LazyType /** Denotations represent the meaning of symbols and named types. * The following diagram shows how the principal types of denotations @@ -171,12 +172,19 @@ object Denotations { * * @param symbol The referencing symbol, or NoSymbol is none exists */ - abstract class Denotation(val symbol: Symbol) extends PreDenotation with printing.Showable { - + abstract class Denotation(val symbol: Symbol, protected var myInfo: Type) extends PreDenotation with printing.Showable { type AsSeenFromResult <: Denotation - /** The type info of the denotation, exists only for non-overloaded denotations */ - def info(implicit ctx: Context): Type + /** The type info. + * The info is an instance of TypeType iff this is a type denotation + * Uncompleted denotations set myInfo to a LazyType. + */ + final def info(implicit ctx: Context): Type = { + def completeInfo = { // Written this way so that `info` is small enough to be inlined + this.asInstanceOf[SymDenotation].completeFrom(myInfo.asInstanceOf[LazyType]); info + } + if (myInfo.isInstanceOf[LazyType]) completeInfo else myInfo + } /** The type info, or, if this is a SymDenotation where the symbol * is not yet completed, the completer @@ -676,7 +684,7 @@ object Denotations { } /** A non-overloaded denotation */ - abstract class SingleDenotation(symbol: Symbol) extends Denotation(symbol) { + abstract class SingleDenotation(symbol: Symbol, initInfo: Type) extends Denotation(symbol, initInfo) { protected def newLikeThis(symbol: Symbol, info: Type): SingleDenotation final def name(implicit ctx: Context): Name = symbol.name @@ -891,12 +899,12 @@ object Denotations { } else { //println(s"might need new denot for $cur, valid for ${cur.validFor} at $currentPeriod") // not found, cur points to highest existing variant - val nextTransformerId = ctx.nextDenotTransformerId(cur.validFor.lastPhaseId) + val nextTransformerId = ctx.base.nextDenotTransformerId(cur.validFor.lastPhaseId) if (currentPeriod.lastPhaseId <= nextTransformerId) cur.validFor = Period(currentPeriod.runId, cur.validFor.firstPhaseId, nextTransformerId) else { var startPid = nextTransformerId + 1 - val transformer = ctx.denotTransformers(nextTransformerId) + val transformer = ctx.base.denotTransformers(nextTransformerId) //println(s"transforming $this with $transformer") try { next = transformer.transform(cur)(ctx.withPhase(transformer)) @@ -1042,7 +1050,7 @@ object Denotations { /** Show declaration string; useful for showing declarations * as seen from subclasses. */ - def showDcl(implicit ctx: Context): String = ctx.dclText(this).show + def showDcl(implicit ctx: Context): String = ctx.printer.dclText(this).show override def toString = if (symbol == NoSymbol) symbol.toString @@ -1100,16 +1108,15 @@ object Denotations { } } - abstract class NonSymSingleDenotation(symbol: Symbol) extends SingleDenotation(symbol) { - def infoOrCompleter: Type - def info(implicit ctx: Context) = infoOrCompleter + abstract class NonSymSingleDenotation(symbol: Symbol, initInfo: Type) extends SingleDenotation(symbol, initInfo) { + def infoOrCompleter: Type = initInfo def isType = infoOrCompleter.isInstanceOf[TypeType] } class UniqueRefDenotation( symbol: Symbol, - val infoOrCompleter: Type, - initValidFor: Period) extends NonSymSingleDenotation(symbol) { + initInfo: Type, + initValidFor: Period) extends NonSymSingleDenotation(symbol, initInfo) { validFor = initValidFor override def hasUniqueSym: Boolean = true protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = new UniqueRefDenotation(s, i, validFor) @@ -1117,17 +1124,16 @@ object Denotations { class JointRefDenotation( symbol: Symbol, - val infoOrCompleter: Type, - initValidFor: Period) extends NonSymSingleDenotation(symbol) { + initInfo: Type, + initValidFor: Period) extends NonSymSingleDenotation(symbol, initInfo) { validFor = initValidFor override def hasUniqueSym = false protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = new JointRefDenotation(s, i, validFor) } - class ErrorDenotation(implicit ctx: Context) extends NonSymSingleDenotation(NoSymbol) { + class ErrorDenotation(implicit ctx: Context) extends NonSymSingleDenotation(NoSymbol, NoType) { override def exists = false override def hasUniqueSym = false - def infoOrCompleter = NoType validFor = Period.allInRun(ctx.runId) protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = this } @@ -1203,9 +1209,8 @@ object Denotations { /** An overloaded denotation consisting of the alternatives of both given denotations. */ - case class MultiDenotation(denot1: Denotation, denot2: Denotation) extends Denotation(NoSymbol) with MultiPreDenotation { + case class MultiDenotation(denot1: Denotation, denot2: Denotation) extends Denotation(NoSymbol, NoType) with MultiPreDenotation { final def infoOrCompleter = multiHasNot("info") - final def info(implicit ctx: Context) = infoOrCompleter final def validFor = denot1.validFor & denot2.validFor final def isType = false final def hasUniqueSym = false diff --git a/compiler/src/dotty/tools/dotc/core/StdNames.scala b/compiler/src/dotty/tools/dotc/core/StdNames.scala index ff7a3abed486..1a58805f389c 100644 --- a/compiler/src/dotty/tools/dotc/core/StdNames.scala +++ b/compiler/src/dotty/tools/dotc/core/StdNames.scala @@ -393,7 +393,7 @@ object StdNames { val ClassManifestFactory: N = "ClassManifestFactory" val classOf: N = "classOf" val clone_ : N = "clone" - // val conforms : N = "conforms" // Dotty deviation: no special treatment of conforms, so the occurrence of the name here would cause to unintended implicit shadowing. Should find a less common name for it in Predef. + val conforms_ : N = "$conforms" val copy: N = "copy" val currentMirror: N = "currentMirror" val create: N = "create" diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index 7672c055e4ba..4cccb675ca58 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -125,7 +125,7 @@ object SymDenotations { final val name: Name, initFlags: FlagSet, initInfo: Type, - initPrivateWithin: Symbol = NoSymbol) extends SingleDenotation(symbol) { + initPrivateWithin: Symbol = NoSymbol) extends SingleDenotation(symbol, initInfo) { //assert(symbol.id != 4940, name) @@ -141,7 +141,6 @@ object SymDenotations { // ------ Getting and setting fields ----------------------------- private[this] var myFlags: FlagSet = adaptFlags(initFlags) - private[this] var myInfo: Type = initInfo private[this] var myPrivateWithin: Symbol = initPrivateWithin private[this] var myAnnotations: List[Annotation] = Nil @@ -203,17 +202,6 @@ object SymDenotations { final def is(fs: FlagConjunction, butNot: FlagSet)(implicit ctx: Context) = (if (isCurrent(fs) && isCurrent(butNot)) myFlags else flags) is (fs, butNot) - /** The type info. - * The info is an instance of TypeType iff this is a type denotation - * Uncompleted denotations set myInfo to a LazyType. - */ - final def info(implicit ctx: Context): Type = { - def completeInfo = { // Written this way so that `info` is small enough to be inlined - completeFrom(myInfo.asInstanceOf[LazyType]); info - } - if (myInfo.isInstanceOf[LazyType]) completeInfo else myInfo - } - /** The type info, or, if symbol is not yet completed, the completer */ final def infoOrCompleter = myInfo @@ -223,7 +211,7 @@ object SymDenotations { case _ => Some(myInfo) } - private def completeFrom(completer: LazyType)(implicit ctx: Context): Unit = + final def completeFrom(completer: LazyType)(implicit ctx: Context): Unit = if (Config.showCompletions) { println(i"${" " * indent}completing ${if (isType) "type" else "val"} $name") indent += 1 diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala index 271215777c04..44ef54256503 100644 --- a/compiler/src/dotty/tools/dotc/core/Symbols.scala +++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala @@ -646,12 +646,12 @@ object Symbols { def toText(printer: Printer): Text = printer.toText(this) - def showLocated(implicit ctx: Context): String = ctx.locatedText(this).show - def showExtendedLocation(implicit ctx: Context): String = ctx.extendedLocationText(this).show - def showDcl(implicit ctx: Context): String = ctx.dclText(this).show - def showKind(implicit ctx: Context): String = ctx.kindString(this) - def showName(implicit ctx: Context): String = ctx.nameString(this) - def showFullName(implicit ctx: Context): String = ctx.fullNameString(this) + def showLocated(implicit ctx: Context): String = ctx.printer.locatedText(this).show + def showExtendedLocation(implicit ctx: Context): String = ctx.printer.extendedLocationText(this).show + def showDcl(implicit ctx: Context): String = ctx.printer.dclText(this).show + def showKind(implicit ctx: Context): String = ctx.printer.kindString(this) + def showName(implicit ctx: Context): String = ctx.printer.nameString(this) + def showFullName(implicit ctx: Context): String = ctx.printer.fullNameString(this) override def hashCode() = id // for debugging. } diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 948c0bfc1606..4de739a5bb28 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -134,7 +134,7 @@ object Types { } /** Is this type different from NoType? */ - def exists: Boolean = true + final def exists: Boolean = this.ne(NoType) /** This type, if it exists, otherwise `that` type */ def orElse(that: => Type) = if (exists) this else that @@ -621,14 +621,14 @@ object Types { val jointInfo = if (rinfo.isAlias) rinfo else if (pinfo.isAlias) pinfo - else if (ctx.pendingMemberSearches.contains(name)) pinfo safe_& rinfo + else if (ctx.base.pendingMemberSearches.contains(name)) pinfo safe_& rinfo else pinfo recoverable_& rinfo pdenot.asSingleDenotation.derivedSingleDenotation(pdenot.symbol, jointInfo) } else { pdenot & ( new JointRefDenotation(NoSymbol, rinfo, Period.allInRun(ctx.runId)), pre, - safeIntersection = ctx.pendingMemberSearches.contains(name)) + safeIntersection = ctx.base.pendingMemberSearches.contains(name)) } } @@ -670,13 +670,13 @@ object Types { } def goAnd(l: Type, r: Type) = { - go(l) & (go(r), pre, safeIntersection = ctx.pendingMemberSearches.contains(name)) + go(l) & (go(r), pre, safeIntersection = ctx.base.pendingMemberSearches.contains(name)) } - val recCount = ctx.findMemberCount + val recCount = ctx.base.findMemberCount if (recCount >= Config.LogPendingFindMemberThreshold) - ctx.pendingMemberSearches = name :: ctx.pendingMemberSearches - ctx.findMemberCount = recCount + 1 + ctx.base.pendingMemberSearches = name :: ctx.base.pendingMemberSearches + ctx.base.findMemberCount = recCount + 1 try go(this) catch { case ex: Throwable => @@ -693,8 +693,8 @@ object Types { } finally { if (recCount >= Config.LogPendingFindMemberThreshold) - ctx.pendingMemberSearches = ctx.pendingMemberSearches.tail - ctx.findMemberCount = recCount + ctx.base.pendingMemberSearches = ctx.base.pendingMemberSearches.tail + ctx.base.findMemberCount = recCount } } @@ -1930,8 +1930,8 @@ object Types { * not loop before the error is detected. */ final def controlled[T](op: => T)(implicit ctx: Context): T = try { - ctx.underlyingRecursions += 1 - if (ctx.underlyingRecursions < Config.LogPendingUnderlyingThreshold) + ctx.base.underlyingRecursions += 1 + if (ctx.base.underlyingRecursions < Config.LogPendingUnderlyingThreshold) op else if (ctx.pendingUnderlying contains this) throw CyclicReference(symbol) @@ -1943,7 +1943,7 @@ object Types { ctx.pendingUnderlying -= this } } finally { - ctx.underlyingRecursions -= 1 + ctx.base.underlyingRecursions -= 1 } /** The argument corresponding to class type parameter `tparam` as seen from @@ -3766,7 +3766,6 @@ object Types { /** Sentinel for "missing type" */ @sharable case object NoType extends CachedGroundType { - override def exists = false override def computeHash(bs: Binders) = hashSeed } @@ -3788,7 +3787,7 @@ object Types { def apply(msg: => Message)(implicit ctx: Context): ErrorType = { val et = new ErrorType { def msg(implicit ctx: Context): Message = - ctx.errorTypeMsg.get(this) match { + ctx.base.errorTypeMsg.get(this) match { case Some(msgFun) => msgFun() case None => "error message from previous run no longer available" } diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala b/compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala index 80a7aac1743b..65724cfd8142 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala @@ -49,7 +49,7 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) { def printNat() = print(Yellow(" " + readNat()).show) def printName() = { val idx = readNat() - print(nameColor(" " + idx + " [" + nameRefToString(NameRef(idx)) + "]").show) + print(nameColor(" " + idx + " [" + nameRefToString(NameRef(idx)) + "]")) } def printTree(): Unit = { newLine() diff --git a/compiler/src/dotty/tools/dotc/fromtasty/ReadTastyTreesFromClasses.scala b/compiler/src/dotty/tools/dotc/fromtasty/ReadTastyTreesFromClasses.scala index 8fbbcdca3d07..0153ba932044 100644 --- a/compiler/src/dotty/tools/dotc/fromtasty/ReadTastyTreesFromClasses.scala +++ b/compiler/src/dotty/tools/dotc/fromtasty/ReadTastyTreesFromClasses.scala @@ -60,7 +60,7 @@ class ReadTastyTreesFromClasses extends FrontEnd { // Note that if both the class and the object are present, then loading the class will also load // the object, this is why we use orElse here, otherwise we could load the object twice and // create ambiguities! - ctx.staticRef(className) match { + ctx.base.staticRef(className) match { case clsd: ClassDenotation => clsd.infoOrCompleter match { case info: ClassfileLoader => diff --git a/compiler/src/dotty/tools/dotc/plugins/Plugins.scala b/compiler/src/dotty/tools/dotc/plugins/Plugins.scala index c2416467e2e7..1b19df3068aa 100644 --- a/compiler/src/dotty/tools/dotc/plugins/Plugins.scala +++ b/compiler/src/dotty/tools/dotc/plugins/Plugins.scala @@ -80,7 +80,7 @@ trait Plugins { } } - val plugs = pick(roughPluginsList, ctx.phasePlan.flatten.map(_.phaseName).toSet) + val plugs = pick(roughPluginsList, ctx.base.phasePlan.flatten.map(_.phaseName).toSet) // Verify required plugins are present. for (req <- ctx.settings.require.value ; if !(plugs exists (_.name == req))) diff --git a/compiler/src/dotty/tools/dotc/printing/Highlighting.scala b/compiler/src/dotty/tools/dotc/printing/Highlighting.scala index 3bda7fb7ae64..cdc1d966be4b 100644 --- a/compiler/src/dotty/tools/dotc/printing/Highlighting.scala +++ b/compiler/src/dotty/tools/dotc/printing/Highlighting.scala @@ -7,9 +7,6 @@ import core.Contexts.Context object Highlighting { - implicit def highlightShow(h: Highlight)(implicit ctx: Context): String = - h.show - abstract class Highlight(private val highlight: String) { def text: String diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index 79c00e0f9f92..51f95d94f794 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -22,15 +22,15 @@ class PlainPrinter(_ctx: Context) extends Printer { protected def maxToTextRecursions = 100 protected final def controlled(op: => Text): Text = - if (ctx.toTextRecursions < maxToTextRecursions && ctx.toTextRecursions < maxSummarized) + if (ctx.base.toTextRecursions < maxToTextRecursions && ctx.base.toTextRecursions < maxSummarized) try { - ctx.toTextRecursions += 1 + ctx.base.toTextRecursions += 1 op } finally { - ctx.toTextRecursions -= 1 + ctx.base.toTextRecursions -= 1 } else { - if (ctx.toTextRecursions >= maxToTextRecursions) + if (ctx.base.toTextRecursions >= maxToTextRecursions) recursionLimitExceeded() "..." } @@ -522,7 +522,7 @@ class PlainPrinter(_ctx: Context) extends Printer { def summarized[T](depth: Int)(op: => T): T = { val saved = maxSummarized - maxSummarized = ctx.toTextRecursions + depth + maxSummarized = ctx.base.toTextRecursions + depth try op finally maxSummarized = depth } diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index ef0e416ae1a2..72d0284ff51b 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -1821,7 +1821,7 @@ object messages { val kind = "Compatibility" val msg = "Failure to eliminate existential type. Proceed at own risk." val explanation = { - val originalType = ctx.dclsText(boundSyms, "; ").show + val originalType = ctx.printer.dclsText(boundSyms, "; ").show hl"""original type : $tp forSome ${originalType} |reduces to : $tp1 |type used instead: $tp2""" @@ -1961,7 +1961,7 @@ object messages { val msg = { val denotationOwner = denot.owner - val denotationName = ctx.fresh.setSetting(ctx.settings.YdebugNames, true).nameString(denot.name) + val denotationName = ctx.fresh.setSetting(ctx.settings.YdebugNames, true).printer.nameString(denot.name) val file = denot.symbol.associatedFile val (location, src) = if (file != null) (s" in $file", file.toString) diff --git a/compiler/src/dotty/tools/dotc/transform/LazyVals.scala b/compiler/src/dotty/tools/dotc/transform/LazyVals.scala index 71b8cd05c460..d3db6c1b1aa2 100644 --- a/compiler/src/dotty/tools/dotc/transform/LazyVals.scala +++ b/compiler/src/dotty/tools/dotc/transform/LazyVals.scala @@ -64,7 +64,7 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer { override def prepareForUnit(tree: Tree)(implicit ctx: Context) = { if (lazyValNullables == null) - lazyValNullables = ctx.collectNullableFieldsPhase.asInstanceOf[CollectNullableFields].lazyValNullables + lazyValNullables = ctx.base.collectNullableFieldsPhase.asInstanceOf[CollectNullableFields].lazyValNullables ctx } diff --git a/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala b/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala index 5c5bbebb3504..19ed183f357e 100644 --- a/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala +++ b/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala @@ -101,7 +101,7 @@ class TreeChecker extends Phase with SymTransformer { if (ctx.settings.YtestPickler.value && ctx.phase.prev.isInstanceOf[Pickler]) ctx.echo("Skipping Ycheck after pickling with -Ytest-pickler, the returned tree contains stale symbols") else - check(ctx.allPhases, ctx) + check(ctx.base.allPhases, ctx) } private def previousPhases(phases: List[Phase])(implicit ctx: Context): List[Phase] = phases match { @@ -118,7 +118,7 @@ class TreeChecker extends Phase with SymTransformer { def check(phasesToRun: Seq[Phase], ctx: Context) = { val prevPhase = ctx.phase.prev // can be a mini-phase - val squahsedPhase = ctx.squashed(prevPhase) + val squahsedPhase = ctx.base.squashed(prevPhase) ctx.echo(s"checking ${ctx.compilationUnit} after phase ${squahsedPhase}") assertSelectWrapsNew(ctx.compilationUnit.tpdTree)(ctx) diff --git a/compiler/src/dotty/tools/dotc/transform/TypeUtils.scala b/compiler/src/dotty/tools/dotc/transform/TypeUtils.scala index d474c77b4621..b7eb024b0f4d 100644 --- a/compiler/src/dotty/tools/dotc/transform/TypeUtils.scala +++ b/compiler/src/dotty/tools/dotc/transform/TypeUtils.scala @@ -12,23 +12,20 @@ import NameOps._ import language.implicitConversions object TypeUtils { - implicit def decorateTypeUtils(tpe: Type): TypeUtils = new TypeUtils(tpe) -} - -/** A decorator that provides methods on types - * that are needed in the transformer pipeline. - */ -class TypeUtils(val self: Type) extends AnyVal { - import TypeUtils._ + /** A decorator that provides methods on types + * that are needed in the transformer pipeline. + */ + implicit class TypeUtilsOps(val self: Type) extends AnyVal { - def isErasedValueType(implicit ctx: Context): Boolean = - self.isInstanceOf[ErasedValueType] + def isErasedValueType(implicit ctx: Context): Boolean = + self.isInstanceOf[ErasedValueType] - def isPrimitiveValueType(implicit ctx: Context): Boolean = - self.classSymbol.isPrimitiveValueClass + def isPrimitiveValueType(implicit ctx: Context): Boolean = + self.classSymbol.isPrimitiveValueClass - def ensureMethodic(implicit ctx: Context): Type = self match { - case self: MethodicType => self - case _ => if (ctx.erasedTypes) MethodType(Nil, self) else ExprType(self) + def ensureMethodic(implicit ctx: Context): Type = self match { + case self: MethodicType => self + case _ => if (ctx.erasedTypes) MethodType(Nil, self) else ExprType(self) + } } } diff --git a/compiler/src/dotty/tools/io/Jar.scala b/compiler/src/dotty/tools/io/Jar.scala index 03a42adcfceb..5e24f486cf13 100644 --- a/compiler/src/dotty/tools/io/Jar.scala +++ b/compiler/src/dotty/tools/io/Jar.scala @@ -40,7 +40,7 @@ class Jar(file: File) extends Iterable[JarEntry] { protected def errorFn(msg: String): Unit = Console println msg - private implicit def enrichManifest(m: JManifest): Jar.WManifest = Jar.WManifest(m) + import Jar._ lazy val jarFile = new JarFile(file.jpath.toFile) lazy val manifest = withJarInput(s => Option(s.getManifest)) @@ -60,7 +60,7 @@ class Jar(file: File) extends Iterable[JarEntry] { finally in.close() } def jarWriter(mainAttrs: (Attributes.Name, String)*) = { - new JarWriter(file, Jar.WManifest(mainAttrs: _*).underlying) + new JarWriter(file, Jar.WManifest.apply(mainAttrs: _*).underlying) } override def foreach[U](f: JarEntry => U): Unit = withJarInput { in => @@ -132,10 +132,8 @@ object Jar { m } - def apply(manifest: JManifest): WManifest = new WManifest(manifest) - implicit def unenrichManifest(x: WManifest): JManifest = x.underlying } - class WManifest(manifest: JManifest) { + implicit class WManifest(val manifest: JManifest) { for ((k, v) <- initialMainAttrs) this(k) = v diff --git a/compiler/test/dotty/tools/dotc/parsing/ModifiersParsingTest.scala b/compiler/test/dotty/tools/dotc/parsing/ModifiersParsingTest.scala index c560d1905cff..4068f440547b 100644 --- a/compiler/test/dotty/tools/dotc/parsing/ModifiersParsingTest.scala +++ b/compiler/test/dotty/tools/dotc/parsing/ModifiersParsingTest.scala @@ -16,7 +16,7 @@ import core.Flags object ModifiersParsingTest { implicit val ctx: Context = (new ContextBase).initialCtx - implicit def parse(code: String): Tree = { + def parse(code: String): Tree = { val (_, stats) = new Parser(new SourceFile("", code)).templateStatSeq() stats match { case List(stat) => stat; case stats => Thicket(stats) } } @@ -78,42 +78,42 @@ class ModifiersParsingTest { @Test def valDef = { - var source: Tree = "class A(var a: Int)" + var source = parse("class A(var a: Int)") assert(source.firstConstrValDef.modifiers == List(Mod.Var())) - source = "class A(val a: Int)" + source = parse("class A(val a: Int)") assert(source.firstConstrValDef.modifiers == List()) - source = "class A(private val a: Int)" + source = parse("class A(private val a: Int)") assert(source.firstConstrValDef.modifiers == List(Mod.Private())) - source = "class A(protected var a: Int)" + source = parse("class A(protected var a: Int)") assert(source.firstConstrValDef.modifiers == List(Mod.Protected(), Mod.Var())) - source = "class A(protected implicit val a: Int)" + source = parse("class A(protected implicit val a: Int)") assert(source.firstConstrValDef.modifiers == List(Mod.Protected(), Mod.Implicit())) - source = "class A[T]" + source = parse("class A[T]") assert(source.firstTypeParam.modifiers == List()) } @Test def typeDef = { - var source: Tree = "class A" + var source = parse("class A") assert(source.modifiers == List()) - source = "sealed class A" + source = parse("sealed class A") assert(source.modifiers == List(Mod.Sealed())) - source = "implicit class A" + source = parse("implicit class A") assert(source.modifiers == List(Mod.Implicit())) - source = "abstract sealed class A" + source = parse("abstract sealed class A") assert(source.modifiers == List(Mod.Abstract(), Mod.Sealed())) } @Test def fieldDef = { - val source: Tree = - """ + val source = + parse(""" | class A { | lazy var a = ??? | lazy private val b = ??? @@ -122,7 +122,7 @@ class ModifiersParsingTest { | abstract override def f: Boolean | transparent def g(n: Int) = ??? | } - """.stripMargin + """.stripMargin) assert(source.field("a").modifiers == List(Mod.Lazy(), Mod.Var())) assert(source.field("b").modifiers == List(Mod.Lazy(), Mod.Private())) @@ -132,29 +132,29 @@ class ModifiersParsingTest { } @Test def paramDef = { - var source: Tree = "def f(transparent a: Int) = ???" + var source: Tree = parse("def f(transparent a: Int) = ???") assert(source.defParam(0).modifiers == List(Mod.Transparent())) - source = "def f(implicit a: Int, b: Int) = ???" + source = parse("def f(implicit a: Int, b: Int) = ???") assert(source.defParam(0).modifiers == List(Mod.Implicit())) assert(source.defParam(1).modifiers == List(Mod.Implicit())) - source = "def f(x: Int, y: Int)(implicit a: Int, b: Int) = ???" + source = parse("def f(x: Int, y: Int)(implicit a: Int, b: Int) = ???") assert(source.defParam(0, 0).modifiers == List()) assert(source.defParam(1, 0).modifiers == List(Mod.Implicit())) } @Test def blockDef = { - var source: Tree = "implicit val x : A = ???" + var source: Tree = parse("implicit val x : A = ???") assert(source.modifiers == List(Mod.Implicit())) - source = "implicit var x : A = ???" + source = parse("implicit var x : A = ???") assert(source.modifiers == List(Mod.Implicit(), Mod.Var())) - source = "{ implicit var x : A = ??? }" + source = parse("{ implicit var x : A = ??? }") assert(source.stat(0).modifiers == List(Mod.Implicit(), Mod.Var())) - source = "{ implicit x => x * x }" + source = parse("{ implicit x => x * x }") assert(source.stat(0).funParam(0).modifiers == List(Mod.Implicit())) } } diff --git a/compiler/test/dotty/tools/dotc/transform/TreeTransformerTest.scala b/compiler/test/dotty/tools/dotc/transform/TreeTransformerTest.scala index aace7b734d17..1bb558e64806 100644 --- a/compiler/test/dotty/tools/dotc/transform/TreeTransformerTest.scala +++ b/compiler/test/dotty/tools/dotc/transform/TreeTransformerTest.scala @@ -16,7 +16,7 @@ class TreeTransformerTest extends DottyTest { implicit val ctx = context class EmptyTransform extends MiniPhase { override def phaseName: String = "empty" - init(ctx, ctx.period.firstPhaseId, ctx.period.lastPhaseId) + init(ctx.base, ctx.period.firstPhaseId, ctx.period.lastPhaseId) } val transformer = new MegaPhase(Array(new EmptyTransform)) val transformed = transformer.transformUnit(tree) @@ -34,7 +34,7 @@ class TreeTransformerTest extends DottyTest { override def transformLiteral(tree: tpd.Literal)(implicit ctx: Context): tpd.Tree = tpd.Literal(Constant(2)) override def phaseName: String = "canReplaceConstant" - init(ctx, ctx.period.firstPhaseId, ctx.period.lastPhaseId) + init(ctx.base, ctx.period.firstPhaseId, ctx.period.lastPhaseId) } val transformer = new MegaPhase(Array(new ConstantTransform)) val transformed = transformer.transformUnit(tree) @@ -60,7 +60,7 @@ class TreeTransformerTest extends DottyTest { tpd.cpy.ValDef(tree)(rhs = tpd.Literal(Constant(2))) } - init(ctx, ctx.period.firstPhaseId, ctx.period.lastPhaseId) + init(ctx.base, ctx.period.firstPhaseId, ctx.period.lastPhaseId) } val transformer = new MegaPhase(Array(new Transformation)) val tr = transformer.transformUnit(tree).toString @@ -91,7 +91,7 @@ class TreeTransformerTest extends DottyTest { tpd.cpy.ValDef(tree)(rhs = tpd.Literal(Constant(2))) } - init(ctx, ctx.period.firstPhaseId, ctx.period.lastPhaseId) + init(ctx.base, ctx.period.firstPhaseId, ctx.period.lastPhaseId) } class Transformation2 extends MiniPhase { override def phaseName: String = "transformationOrder2" @@ -102,7 +102,7 @@ class TreeTransformerTest extends DottyTest { tpd.cpy.ValDef(tree)(rhs = tpd.Literal(Constant(3))) } - init(ctx, ctx.period.firstPhaseId, ctx.period.lastPhaseId) + init(ctx.base, ctx.period.firstPhaseId, ctx.period.lastPhaseId) } val transformer = new MegaPhase(Array(new Transformation1, new Transformation2)) val tr = transformer.transformUnit(tree).toString @@ -135,7 +135,7 @@ class TreeTransformerTest extends DottyTest { tpd.cpy.ValDef(tree)(rhs = transformFollowing(tpd.Literal(Constant(2)))) } - init(ctx, ctx.period.firstPhaseId, ctx.period.lastPhaseId) + init(ctx.base, ctx.period.firstPhaseId, ctx.period.lastPhaseId) } var transformed2 = 0 class Transformation2 extends MiniPhase { @@ -166,7 +166,7 @@ class TreeTransformerTest extends DottyTest { transformFollowing(tpd.cpy.ValDef(tree)(rhs = tpd.Literal(Constant(3)))) } - init(ctx, ctx.period.firstPhaseId, ctx.period.lastPhaseId) + init(ctx.base, ctx.period.firstPhaseId, ctx.period.lastPhaseId) } val transformer = new MegaPhase(Array(new Transformation1, new Transformation2)) val tr = transformer.transformUnit(tree).toString diff --git a/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/plugin/DivideZero.scala b/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/plugin/DivideZero.scala index a69adf32d81e..c7558a041b0a 100644 --- a/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/plugin/DivideZero.scala +++ b/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/plugin/DivideZero.scala @@ -26,7 +26,7 @@ class DivideZero extends PluginPhase with StandardPlugin { private def isNumericDivide(sym: Symbol)(implicit ctx: Context): Boolean = { def test(tpe: String): Boolean = - (sym.owner eq ctx.requiredClass(tpe.toTermName)) && sym.name.show == "/" + (sym.owner eq ctx.requiredClass(tpe)) && sym.name.show == "/" test("scala.Int") || test("scala.Long") || test("scala.Short") || test("scala.Float") || test("scala.Double") } diff --git a/tests/plugins/neg/divideZero-research/plugin_1.scala b/tests/plugins/neg/divideZero-research/plugin_1.scala index f3056496e080..4b255faa1266 100644 --- a/tests/plugins/neg/divideZero-research/plugin_1.scala +++ b/tests/plugins/neg/divideZero-research/plugin_1.scala @@ -23,7 +23,7 @@ class DivideZero extends MiniPhase with ResearchPlugin { private def isNumericDivide(sym: Symbol)(implicit ctx: Context): Boolean = { def test(tpe: String): Boolean = - (sym.owner eq ctx.requiredClass(tpe.toTermName)) && sym.name == nme.DIV + (sym.owner eq ctx.requiredClass(tpe)) && sym.name == nme.DIV test("scala.Int") || test("scala.Long") || test("scala.Short") || test("scala.Float") || test("scala.Double") } diff --git a/tests/plugins/neg/divideZero/plugin_1.scala b/tests/plugins/neg/divideZero/plugin_1.scala index 04e0bd9941e9..0db0c2906bbb 100644 --- a/tests/plugins/neg/divideZero/plugin_1.scala +++ b/tests/plugins/neg/divideZero/plugin_1.scala @@ -24,7 +24,7 @@ class DivideZero extends PluginPhase with StandardPlugin { private def isNumericDivide(sym: Symbol)(implicit ctx: Context): Boolean = { def test(tpe: String): Boolean = - (sym.owner eq ctx.requiredClass(tpe.toTermName)) && sym.name == nme.DIV + (sym.owner eq ctx.requiredClass(tpe)) && sym.name == nme.DIV test("scala.Int") || test("scala.Long") || test("scala.Short") || test("scala.Float") || test("scala.Double") }