diff options
author | Martin Odersky <odersky@gmail.com> | 2013-05-30 10:09:48 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-05-30 10:09:48 +0200 |
commit | 17d0e7008f62882c10193ea0db09c9b90736c320 (patch) | |
tree | 44cf4d4f2675effabb2ba651f9399d7d6fce21a1 /src/dotty/tools/dotc/core | |
parent | c53ac49cbe7c98c05a99fea3c8e1dcad75275a82 (diff) | |
download | dotty-17d0e7008f62882c10193ea0db09c9b90736c320.tar.gz dotty-17d0e7008f62882c10193ea0db09c9b90736c320.tar.bz2 dotty-17d0e7008f62882c10193ea0db09c9b90736c320.zip |
wip, because I have to get off this machine.
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r-- | src/dotty/tools/dotc/core/Annotations.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Contexts.scala | 44 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Definitions.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 15 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Symbols.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 2 |
6 files changed, 47 insertions, 20 deletions
diff --git a/src/dotty/tools/dotc/core/Annotations.scala b/src/dotty/tools/dotc/core/Annotations.scala index bef8499b0..221f5c160 100644 --- a/src/dotty/tools/dotc/core/Annotations.scala +++ b/src/dotty/tools/dotc/core/Annotations.scala @@ -62,5 +62,5 @@ object Annotations { } def ThrowsAnnotation(cls: ClassSymbol)(implicit ctx: Context) = - Annotation(defn.ThrowsAnnot, Ident(cls.symbolicRef)) + Annotation(defn.ThrowsAnnot, Ident(cls.symTypeRef)) }
\ No newline at end of file diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala index 6ff6e148d..98cf7e801 100644 --- a/src/dotty/tools/dotc/core/Contexts.scala +++ b/src/dotty/tools/dotc/core/Contexts.scala @@ -8,15 +8,17 @@ import Names._ import Phases._ import Types._ import Symbols._ +import Scopes._ import TypeComparers._, NameOps._, SymDenotations._, util.Positions._ -import ast.tpd._, util.FreshNameCreator +import ast.Trees._, ast.untpd +import util.FreshNameCreator +import typer._ import config.Settings._ -import config.ScalaSettings import reporting._ import collection.mutable import collection.immutable.BitSet import printing._ -import config.{Settings, Platform, JavaPlatform} +import config.{Settings, ScalaSettings, Platform, JavaPlatform} import language.implicitConversions object Contexts { @@ -48,6 +50,7 @@ object Contexts { with Symbols with SymDenotations with Reporting + with NamerContextOps with Cloneable { thiscontext => implicit def ctx: Context = this @@ -76,6 +79,14 @@ object Contexts { protected def constraints_=(constraints: Constraints) = _constraints = constraints def constraints: Constraints = _constraints + /** The scope nesting level */ + private[this] var _scopeNestingLevel: Int = 0 + def scopeNestingLevel: Int = { + if (this._scopeNestingLevel == outer.scopeNestingLevel && this.scope != outer.scope) + this._scopeNestingLevel = outer.scopeNestingLevel + 1 + this._scopeNestingLevel + } + /** The current type comparer */ private[this] var _typeComparer: TypeComparer = _ protected def typeComparer_=(typeComparer: TypeComparer) = _typeComparer = typeComparer @@ -113,9 +124,19 @@ object Contexts { def sstate: SettingsState = _sstate /** The current tree */ - private[this] var _tree: Tree = _ - protected def tree_=(tree: Tree) = _tree = tree - def tree: Tree = _tree + private[this] var _tree: Tree[_ >: Untyped] = _ + protected def tree_=(tree: Tree[_ >: Untyped]) = _tree = tree + def tree: Tree[_ >: Untyped] = _tree + + /** The current scope */ + private[this] var _scope: Scope = _ + protected def scope_=(scope: Scope) = _scope = scope + def scope: Scope = _scope + + /** The currently visible imports */ + private[this] var _imports: List[ImportInfo] = _ + protected def imports_=(imports: List[ImportInfo]) = _imports = imports + def imports: List[ImportInfo] = _imports /** The current reporter */ private[this] var _reporter: Reporter = _ @@ -123,7 +144,7 @@ object Contexts { def reporter: Reporter = _reporter /** An optional diagostics buffer than is used by some checking code - * to leave provide more information in the buffer if it exists. + * to provide more information in the buffer if it exists. */ private var _diagnostics: Option[StringBuilder] = _ protected def diagnostics_=(diagnostics: Option[StringBuilder]) = _diagnostics = diagnostics @@ -134,6 +155,7 @@ object Contexts { protected def moreProperties_=(moreProperties: Map[String, Any]) = _moreProperties = moreProperties def moreProperties: Map[String, Any] = _moreProperties + /** If -Ydebug is on, the top of the stack trace where this context * was created, otherwise `null`. */ @@ -165,7 +187,7 @@ object Contexts { /** The next outer context whose tree is a template or package definition */ def enclTemplate: Context = { var c = this - while (c != NoContext && !c.tree.isInstanceOf[Template] && !c.tree.isInstanceOf[PackageDef]) + while (c != NoContext && !c.tree.isInstanceOf[Template[_]] && !c.tree.isInstanceOf[PackageDef[_]]) c = c.outer c } @@ -232,7 +254,9 @@ object Contexts { def withRefinedPrinter(printer: Context => Printer): this.type = { this.refinedPrinter = printer; this } def withOwner(owner: Symbol): this.type = { this.owner = owner; this } def withSettings(sstate: SettingsState): this.type = { this.sstate = sstate; this } - def withTree(tree: Tree): this.type = { this.tree = tree; this } + def withTree(tree: Tree[_ >: Untyped]): this.type = { this.tree = tree; this } + def withScope(scope: Scope): this.type = { this.scope = scope; this } + def withImport(importInfo: ImportInfo): this.type = { this.imports = importInfo :: imports; this } def withReporter(reporter: Reporter): this.type = { this.reporter = reporter; this } def withDiagnostics(diagnostics: Option[StringBuilder]): this.type = { this.diagnostics = diagnostics; this } def withMoreProperties(moreProperties: Map[String, Any]): this.type = { this.moreProperties = moreProperties; this } @@ -259,7 +283,7 @@ object Contexts { refinedPrinter = new RefinedPrinter(_) owner = NoSymbol sstate = settings.defaultState - tree = EmptyTree + tree = untpd.EmptyTree reporter = new ConsoleReporter()(this) diagnostics = None moreProperties = Map.empty diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala index d8d7f181d..58878a493 100644 --- a/src/dotty/tools/dotc/core/Definitions.scala +++ b/src/dotty/tools/dotc/core/Definitions.scala @@ -33,7 +33,7 @@ class Definitions(implicit ctx: Context) { val paramDecls = newScope val typeParam = newSyntheticTypeParam(cls, paramDecls) def instantiate(tpe: Type) = - if (tpe.typeParams.nonEmpty) tpe.appliedTo(typeParam.symbolicRef) + if (tpe.typeParams.nonEmpty) tpe.appliedTo(typeParam.symTypeRef) else tpe val parents = parentConstrs.toList map instantiate val parentRefs: List[TypeRef] = ctx.normalizeToRefs(parents, cls, paramDecls) diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 51e03aee7..56b168102 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -102,7 +102,7 @@ object SymDenotations { } } - protected[core] final def info_=(tp: Type) = { + protected[dotc] final def info_=(tp: Type) = { if ((this is ModuleClass) && !(this is PackageClass)) tp match { case ClassInfo(_, _, _, _, ost) => @@ -585,21 +585,24 @@ object SymDenotations { * @throws ClassCastException is this is not a type */ def typeConstructor(implicit ctx: Context): TypeRef = - if ((this is PackageClass) || owner.isTerm) symbolicRef + if ((this is PackageClass) || owner.isTerm) symTypeRef else TypeRef(owner.thisType, name.asTypeName).withDenot(this) /** The symbolic typeref representing the type constructor for this type. * @throws ClassCastException is this is not a type */ - final def symbolicRef(implicit ctx: Context): TypeRef = + final def symTypeRef(implicit ctx: Context): TypeRef = TypeRef.withSym(owner.thisType, symbol.asType) - /** The termref pointing to this termsymbol + /** The symbolic termref pointing to this termsymbol * @throws ClassCastException is this is not a term */ - def termRef(implicit ctx: Context): TermRef = + def symTermRef(implicit ctx: Context): TermRef = TermRef.withSym(owner.thisType, symbol.asTerm) + def symRef(implicit ctx: Context): NamedType = + NamedType.withSym(owner.thisType, symbol) + /** The variance of this type parameter as an Int, with * +1 = Covariant, -1 = Contravariant, 0 = Nonvariant, or not a type parameter */ @@ -1042,7 +1045,7 @@ object SymDenotations { // only apply to the module but not to the module class. The right solution // is to have the module class completer set the annotations of both the // class and the module. - denot.info = mclass.symbolicRef + denot.info = mclass.symTypeRef denot.privateWithin = from.privateWithin } } diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala index 0d6f87cda..23984c7a4 100644 --- a/src/dotty/tools/dotc/core/Symbols.scala +++ b/src/dotty/tools/dotc/core/Symbols.scala @@ -226,7 +226,7 @@ trait Symbols { this: Context => flags: FlagSet, boundsFn: List[TypeRef] => List[Type]) = { val tparams = names map (_ => newNakedSymbol[TypeName](NoCoord)) - val bounds = boundsFn(tparams map (_.symbolicRef)) + val bounds = boundsFn(tparams map (_.symTypeRef)) (names, tparams, bounds).zipped foreach { (name, tparam, bound) => tparam.denot = SymDenotation(tparam, owner, name, flags | TypeParamCreationFlags, bound) } diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 880cb7174..c0e338ef1 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -313,7 +313,7 @@ object Types { // member in Super instead of Sub. // As an example of this in the wild, see // loadClassWithPrivateInnerAndSubSelf in ShowClassTests - tp.cls.symbolicRef.findMember(name, pre, excluded) orElse d + tp.cls.symTypeRef.findMember(name, pre, excluded) orElse d case tp: TypeRef => tp.denot.findMember(name, pre, excluded) case tp: TypeProxy => |