diff options
author | Paul Phillips <paulp@improving.org> | 2010-12-02 17:28:58 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-12-02 17:28:58 +0000 |
commit | 765f9aa2bfd16fc066fcfe6f068bc9ab54b863c2 (patch) | |
tree | 1b8d31bab45162415d6cc6372c7336fc62bbad2b /src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | |
parent | a69c1afd4ba602bd4ccc9f9aced9bfc0f6f3c5e7 (diff) | |
download | scala-765f9aa2bfd16fc066fcfe6f068bc9ab54b863c2.tar.gz scala-765f9aa2bfd16fc066fcfe6f068bc9ab54b863c2.tar.bz2 scala-765f9aa2bfd16fc066fcfe6f068bc9ab54b863c2.zip |
It's a big one!
TermName and TypeName are exposed throughout the compiler based on what
kind of name a given abstraction ought to have. (There remain places
where one needs to create a name without knowing yet what it will be,
and those will always be Names.)
The nme object in the compiler now holds only term names. To reference a
known type name, use tpnme:
nme.List == ("List": TermName)
tpnme.List == ("List": TypeName)
The contents of nme and tpname are defined in traits, many of which
are shared, so if a name should exist only as a Type and not a
Term, it should be defined in CompilerTypeNames, but otherwise in
CompilerTermNames or CompilerCommonNames. This is partially complete but
I'm sure there are still many shared which should pick a side.
Usage of .toTermName and .toTypeName is strongly discouraged. After the
dust has settled, there will be very few places where it will make sense
to hop between namespaces like that.
There are some implicits to smooth everything out, most of which should
be removable eventually.
// these two are in no hurry to go anywhere
String => TermName
String => TypeName
// but not String => Name: def view in the compiler is no longer implicit
// these two are temporary, and can log when they kick off to help us
flush // out remaining issues of "name migration" Name => TermName
Name => TypeName
There is more work to be done before we're properly protected from
naming errors, but I will not allow another eight hour tragedy to befall
lukas or anyone else!
Review by rytz. (Formality.)
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Scanners.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 66a3dc356e..25b65f0791 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -34,7 +34,7 @@ trait Scanners { var lastOffset: Offset = 0 /** the name of an identifier */ - var name: Name = null + var name: TermName = null /** the string value of a literal */ var strVal: String = null @@ -898,14 +898,14 @@ trait Scanners { /** The highest name index of a keyword token */ private var maxKey = 0 /** An array of all keyword token names */ - private var keyName = new Array[Name](128) + private var keyName = new Array[TermName](128) /** The highest keyword token plus one */ private var tokenCount = 0 /** Enter keyword with given name and token id */ - protected def enterKeyword(n: Name, tokenId: Int) { + protected def enterKeyword(n: TermName, tokenId: Int) { while (tokenId >= keyName.length) { - val newTokName = new Array[Name](keyName.length * 2) + val newTokName = new Array[TermName](keyName.length * 2) compat.Platform.arraycopy(keyName, 0, newTokName, 0, newTokName.length) keyName = newTokName } |