diff options
author | Martin Odersky <odersky@gmail.com> | 2013-02-01 15:00:03 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-02-01 15:00:03 +0100 |
commit | 5610fe1abbb8e4cb005d644f37669f872327828b (patch) | |
tree | e8c1f9c7a18e1ea299c14d421fcd251f1c2a4dfc /src/dotty/tools/dotc/core/Symbols.scala | |
parent | 4faeeceffdbc8dec9dd53bf299174a13d6bf87d0 (diff) | |
download | dotty-5610fe1abbb8e4cb005d644f37669f872327828b.tar.gz dotty-5610fe1abbb8e4cb005d644f37669f872327828b.tar.bz2 dotty-5610fe1abbb8e4cb005d644f37669f872327828b.zip |
Refined completion, in particular for module symbols and made contexts explicit.
Made contexts in class constructors explicit (named initctx), so that we can better track where they are used. It's important that the context is not retained in the state of the object.
Diffstat (limited to 'src/dotty/tools/dotc/core/Symbols.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Symbols.scala | 79 |
1 files changed, 61 insertions, 18 deletions
diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala index 468e36cfd..a70e81d68 100644 --- a/src/dotty/tools/dotc/core/Symbols.scala +++ b/src/dotty/tools/dotc/core/Symbols.scala @@ -24,36 +24,79 @@ trait Symbols { this: Context => def newLazyTypeSymbol(owner: Symbol, name: TypeName, initFlags: FlagSet, completer: SymCompleter) = new TypeSymbol(new LazySymDenotation(_, owner, name, initFlags, completer)) - def newLazyClassSymbol(owner: Symbol, name: TypeName, initFlags: FlagSet, completer: ClassCompleter, assocfile: AbstractFile = null) = - new ClassSymbol(new LazyClassDenotation(_, owner, name, initFlags, completer, assocfile)) + def newLazyClassSymbol(owner: Symbol, name: TypeName, initFlags: FlagSet, completer: ClassCompleter, assocFile: AbstractFile = null) = + new ClassSymbol(new LazyClassDenotation(_, owner, name, initFlags, completer, assocFile)(this)) - def newCompleteTermSymbol( - owner: Symbol, + def newLazyModuleSymbol(owner: Symbol, name: TermName, flags: FlagSet, - info: Type) = - new TermSymbol(new CompleteSymDenotation(_, owner, name, flags, info)) + completer: ClassCompleter, + assocFile: AbstractFile = null) + = { + val module = newLazyTermSymbol( + owner, name, flags | Module, new ModuleCompleter) + val modcls = newLazyClassSymbol( + owner, name.toTypeName, flags | Module | Final, completer, assocFile) + module.denot.asInstanceOf[LazySymDenotation].info = + TypeRef(owner.thisType, modcls) + modcls.denot.asInstanceOf[LazyClassDenotation].selfType = + TermRef(owner.thisType, module) + module + } - def newCompleteTypeSymbol( + def newTermSymbol( + owner: Symbol, + name: TermName, + flags: FlagSet, + info: Type, + privateWithin: Symbol = NoSymbol) + = + new TermSymbol(new CompleteSymDenotation(_, owner, name, flags, privateWithin, info)) + + def newTypeSymbol( + owner: Symbol, + name: TypeName, + flags: FlagSet, + info: Type, + privateWithin: Symbol = NoSymbol) + = + new TypeSymbol(new CompleteSymDenotation(_, owner, name, flags, privateWithin, info)) + + def newAliasTypeSymbol(owner: Symbol, name: TypeName, alias: Type, flags: FlagSet = EmptyFlags, privateWithin: Symbol = NoSymbol) = + newTypeSymbol(owner, name, flags, TypeBounds(alias, alias), privateWithin) + + def newClassSymbol( owner: Symbol, name: TypeName, flags: FlagSet, - info: Type) = - new TypeSymbol(new CompleteSymDenotation(_, owner, name, flags, info)) - - def newAliasTypeSymbol(owner: Symbol, name: TypeName, alias: Type, flags: FlagSet = EmptyFlags) = - newCompleteTypeSymbol(owner, name, flags, TypeBounds(alias, alias)) + parents: List[TypeRef], + privateWithin: Symbol = NoSymbol, + optSelfType: Type = NoType, + decls: Scope = newScope, + assocFile: AbstractFile = null) + = + new ClassSymbol(new CompleteClassDenotation( + _, owner, name, flags, privateWithin, parents, optSelfType, decls, assocFile)(this)) - def newCompleteClassSymbol( + def newModuleSymbol( owner: Symbol, - name: TypeName, + name: TermName, flags: FlagSet, + classFlags: FlagSet, parents: List[TypeRef], - optSelfType: Type = NoType, + privateWithin: Symbol = NoSymbol, decls: Scope = newScope, - assocFile: AbstractFile = null) = - new ClassSymbol(new CompleteClassDenotation( - _, owner, name, flags, parents, optSelfType, decls, assocFile)) + assocFile: AbstractFile = null)(implicit ctx: Context) + = { + val module = newLazyTermSymbol(owner, name, flags, new ModuleCompleter) + val modcls = newClassSymbol( + owner, name.toTypeName, classFlags, parents, privateWithin, + optSelfType = TermRef(owner.thisType, module), + decls, assocFile) + module.denot.asInstanceOf[LazySymDenotation].info = + TypeRef(owner.thisType, modcls) + module + } } object Symbols { |