diff options
author | odersky <odersky@gmail.com> | 2016-12-01 16:19:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-01 16:19:34 +0100 |
commit | 47d208448e614125446c7f294f8231c3fb7108d6 (patch) | |
tree | 8c25c6e24257f90489352dc2bee691c9d1a24883 /compiler/src/dotty/tools/dotc/core | |
parent | b9350f40990ce07ba7614a0448a98abd7075abe8 (diff) | |
parent | e1d79a280c16083db309be02f911e326ef205f2c (diff) | |
download | dotty-47d208448e614125446c7f294f8231c3fb7108d6.tar.gz dotty-47d208448e614125446c7f294f8231c3fb7108d6.tar.bz2 dotty-47d208448e614125446c7f294f8231c3fb7108d6.zip |
Merge pull request #1693 from dotty-staging/add-annotations-phase
Add annotations phase
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core')
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/Contexts.scala | 20 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/Definitions.scala | 7 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/Phases.scala | 5 |
3 files changed, 27 insertions, 5 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Contexts.scala b/compiler/src/dotty/tools/dotc/core/Contexts.scala index 639c4d111..a1b99d16d 100644 --- a/compiler/src/dotty/tools/dotc/core/Contexts.scala +++ b/compiler/src/dotty/tools/dotc/core/Contexts.scala @@ -216,8 +216,8 @@ object Contexts { else if (isNonEmptyScopeContext) scope.implicitDecls else Nil val outerImplicits = - if (isImportContext && importInfo.hiddenRoot.exists) - outer.implicits exclude importInfo.hiddenRoot + if (isImportContext && importInfo.unimported.exists) + outer.implicits exclude importInfo.unimported else outer.implicits if (implicitRefs.isEmpty) outerImplicits @@ -422,9 +422,18 @@ object Contexts { final def withOwner(owner: Symbol): Context = if (owner ne this.owner) fresh.setOwner(owner) else this - override def toString = + final def withProperty[T](key: Key[T], value: Option[T]): Context = + if (property(key) == value) this + else value match { + case Some(v) => fresh.setProperty(key, v) + case None => fresh.dropProperty(key) + } + + override def toString = { + def iinfo(implicit ctx: Context) = if (ctx.importInfo == null) "" else i"${ctx.importInfo.selectors}%, %" "Context(\n" + - (outersIterator map ( ctx => s" owner = ${ctx.owner}, scope = ${ctx.scope}") mkString "\n") + (outersIterator map ( ctx => s" owner = ${ctx.owner}, scope = ${ctx.scope}, import = ${iinfo(ctx)}") mkString "\n") + } } /** A condensed context provides only a small memory footprint over @@ -468,6 +477,9 @@ object Contexts { def setProperty[T](key: Key[T], value: T): this.type = setMoreProperties(moreProperties.updated(key, value)) + def dropProperty(key: Key[_]): this.type = + setMoreProperties(moreProperties - key) + def setPhase(pid: PhaseId): this.type = setPeriod(Period(runId, pid)) def setPhase(phase: Phase): this.type = setPeriod(Period(runId, phase.start, phase.end)) diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index 4b090d9b1..c5ccab261 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -650,6 +650,13 @@ class Definitions { def isTupleClass(cls: Symbol) = isVarArityClass(cls, tpnme.Tuple) def isProductClass(cls: Symbol) = isVarArityClass(cls, tpnme.Product) + val predefClassNames: Set[Name] = + Set("Predef$", "DeprecatedPredef", "LowPriorityImplicits").map(_.toTypeName) + + /** Is `cls` the predef module class, or a class inherited by Predef? */ + def isPredefClass(cls: Symbol) = + (cls.owner eq ScalaPackageClass) && predefClassNames.contains(cls.name) + val StaticRootImportFns = List[() => TermRef]( () => JavaLangPackageVal.termRef, () => ScalaPackageVal.termRef diff --git a/compiler/src/dotty/tools/dotc/core/Phases.scala b/compiler/src/dotty/tools/dotc/core/Phases.scala index 222e2235d..6a53e1b30 100644 --- a/compiler/src/dotty/tools/dotc/core/Phases.scala +++ b/compiler/src/dotty/tools/dotc/core/Phases.scala @@ -26,7 +26,10 @@ trait Phases { def phasesStack: List[Phase] = if ((this eq NoContext) || !phase.exists) Nil - else phase :: outersIterator.dropWhile(_.phase == phase).next.phasesStack + else { + val rest = outersIterator.dropWhile(_.phase == phase) + phase :: (if (rest.hasNext) rest.next.phasesStack else Nil) + } /** Execute `op` at given phase */ def atPhase[T](phase: Phase)(op: Context => T): T = |