From 765f9aa2bfd16fc066fcfe6f068bc9ab54b863c2 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 2 Dec 2010 17:28:58 +0000 Subject: 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.) --- src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/compiler/scala/tools/nsc/ast/parser/Scanners.scala') 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 } -- cgit v1.2.3