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/typechecker/RefChecks.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/typechecker/RefChecks.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 1e45ce72e7..5c8e474d58 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -993,11 +993,14 @@ abstract class RefChecks extends InfoTransform { tree match { case ModuleDef(mods, name, impl) => val sym = tree.symbol - if (sym.isStatic) { - val cdef = ClassDef(mods | MODULE, name, List(), impl) + def mkClassDef(transformedInfo: Boolean) = { + ClassDef(mods | MODULE, name.toTypeName, Nil, impl) .setPos(tree.pos) - .setSymbol(sym.moduleClass) + .setSymbol(if (transformedInfo) sym.lazyAccessor else sym.moduleClass) .setType(NoType) + } + if (sym.isStatic) { + val cdef = mkClassDef(false) if (!sym.allOverriddenSymbols.isEmpty) { val factory = sym.owner.newMethod(sym.pos, sym.name) @@ -1020,11 +1023,7 @@ abstract class RefChecks extends InfoTransform { // that the object info was already run through the transformInfo. // Since we do not want to have duplicate lazy accessors // (through duplicate nested object -> lazy val transformation) we have this check here. - val cdef = ClassDef(mods | MODULE, name, List(), impl) - .setPos(tree.pos) - .setSymbol(if (!transformedInfo) sym.moduleClass else sym.lazyAccessor) - .setType(NoType) - + val cdef = mkClassDef(transformedInfo) val vdef = localTyper.typedPos(tree.pos){ if (!transformedInfo) gen.mkModuleVarDef(sym) @@ -1128,7 +1127,7 @@ abstract class RefChecks extends InfoTransform { (args corresponds clazz.primaryConstructor.tpe.asSeenFrom(seltpe, clazz).paramTypes)(isIrrefutable) // @PP: corresponds case Typed(pat, tpt) => seltpe <:< tpt.tpe - case Ident(nme.WILDCARD) => + case Ident(tpnme.WILDCARD) => true case Bind(_, pat) => isIrrefutable(pat, seltpe) @@ -1297,7 +1296,7 @@ abstract class RefChecks extends InfoTransform { def checkSuper(mix: Name) = // term should have been eliminated by super accessors - assert(!(qual.symbol.isTrait && sym.isTerm && mix == nme.EMPTY.toTypeName)) + assert(!(qual.symbol.isTrait && sym.isTerm && mix == tpnme.EMPTY)) transformCaseApply(tree, qual match { @@ -1387,15 +1386,15 @@ abstract class RefChecks extends InfoTransform { enterReference(tree.pos, tpt.tpe.typeSymbol) tree - case Typed(_, Ident(nme.WILDCARD_STAR)) if !isRepeatedParamArg(tree) => + case Typed(_, Ident(tpnme.WILDCARD_STAR)) if !isRepeatedParamArg(tree) => unit.error(tree.pos, "no `: _*' annotation allowed here\n"+ "(such annotations are only allowed in arguments to *-parameters)") tree case Ident(name) => transformCaseApply(tree, - if (name != nme.WILDCARD && name != nme.WILDCARD_STAR) { - assert(sym != NoSymbol, tree) //debug + if (name != nme.WILDCARD && name != tpnme.WILDCARD_STAR) { + assert(sym != NoSymbol, "transformCaseApply: name = " + name.debugString + " tree = " + tree + " / " + tree.getClass) //debug enterReference(tree.pos, sym) } ) |