summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-05-03 10:10:39 -0700
committerPaul Phillips <paulp@improving.org>2012-05-03 10:53:03 -0700
commit0cb886ae44505334dd5e8408b9355a53bc00e578 (patch)
tree41e66ce4b4265cf4a53e5774236d9248afcdf5dd /src/compiler
parentca74659bb06611b87474ffe2fd17b131cd3d34b0 (diff)
downloadscala-0cb886ae44505334dd5e8408b9355a53bc00e578.tar.gz
scala-0cb886ae44505334dd5e8408b9355a53bc00e578.tar.bz2
scala-0cb886ae44505334dd5e8408b9355a53bc00e578.zip
Removed BackquotedIdent.
In favor of a marker attachment using Attachment, as suggested in comments. (The Attachment interface needs work.) I did this bit trying to fix SI-5715, but it's still a bit elusive because the Ident node is thrown away as soon as there's a member definition. Also, as far as I can see this will if anything propagate the backquotedness of an identifier less effectively than before, because TreeCopiers don't copy attachments. Maybe that's on the "todo" list? The whole idea seems to depend on their being propagated to copies.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/reflect/internal/Importers.scala8
-rw-r--r--src/compiler/scala/reflect/internal/StdNames.scala7
-rw-r--r--src/compiler/scala/reflect/internal/TreeInfo.scala7
-rw-r--r--src/compiler/scala/reflect/internal/TreePrinters.scala8
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala1
6 files changed, 19 insertions, 18 deletions
diff --git a/src/compiler/scala/reflect/internal/Importers.scala b/src/compiler/scala/reflect/internal/Importers.scala
index 8404386e10..6d6a0ec317 100644
--- a/src/compiler/scala/reflect/internal/Importers.scala
+++ b/src/compiler/scala/reflect/internal/Importers.scala
@@ -389,12 +389,8 @@ trait Importers { self: SymbolTable =>
new This(importName(qual).toTypeName)
case from.Select(qual, name) =>
new Select(importTree(qual), importName(name))
- case from.Ident(name) => tree match {
- case _: from.BackQuotedIdent =>
- new BackQuotedIdent(importName(name))
- case _ =>
- new Ident(importName(name))
- }
+ case from.Ident(name) =>
+ new Ident(importName(name))
case from.ReferenceToBoxed(ident) =>
new ReferenceToBoxed(importTree(ident) match { case ident: Ident => ident })
case from.Literal(constant @ from.Constant(_)) =>
diff --git a/src/compiler/scala/reflect/internal/StdNames.scala b/src/compiler/scala/reflect/internal/StdNames.scala
index 5b91270de1..6413f0ea43 100644
--- a/src/compiler/scala/reflect/internal/StdNames.scala
+++ b/src/compiler/scala/reflect/internal/StdNames.scala
@@ -332,6 +332,11 @@ trait StdNames {
def isSingletonName(name: Name) = name endsWith SINGLETON_SUFFIX
def isModuleName(name: Name) = name endsWith MODULE_SUFFIX_NAME
+ def isDeprecatedIdentifierName(name: Name) = name.toTermName match {
+ case nme.`then` | nme.`macro` => true
+ case _ => false
+ }
+
def isOpAssignmentName(name: Name) = name match {
case raw.NE | raw.LE | raw.GE | EMPTY => false
case _ =>
@@ -634,6 +639,7 @@ trait StdNames {
val lang: NameType = "lang"
val length: NameType = "length"
val lengthCompare: NameType = "lengthCompare"
+ val `macro` : NameType = "macro"
val macroThis : NameType = "_this"
val macroContext : NameType = "c"
val main: NameType = "main"
@@ -690,6 +696,7 @@ trait StdNames {
val staticModule : NameType = "staticModule"
val synchronized_ : NameType = "synchronized"
val tail: NameType = "tail"
+ val `then` : NameType = "then"
val thisModuleType: NameType = "thisModuleType"
val this_ : NameType = "this"
val throw_ : NameType = "throw"
diff --git a/src/compiler/scala/reflect/internal/TreeInfo.scala b/src/compiler/scala/reflect/internal/TreeInfo.scala
index f4878139e9..2251310f35 100644
--- a/src/compiler/scala/reflect/internal/TreeInfo.scala
+++ b/src/compiler/scala/reflect/internal/TreeInfo.scala
@@ -227,8 +227,11 @@ abstract class TreeInfo {
/** Is tree a variable pattern? */
def isVarPattern(pat: Tree): Boolean = pat match {
- case _: BackQuotedIdent => false
- case x: Ident => isVariableName(x.name)
+ case x: Ident => !x.isBackquoted && isVariableName(x.name)
+ case _ => false
+ }
+ def isDeprecatedIdentifier(tree: Tree): Boolean = tree match {
+ case x: Ident => !x.isBackquoted && nme.isDeprecatedIdentifierName(x.name)
case _ => false
}
diff --git a/src/compiler/scala/reflect/internal/TreePrinters.scala b/src/compiler/scala/reflect/internal/TreePrinters.scala
index 3093bb049a..b3e4318fdc 100644
--- a/src/compiler/scala/reflect/internal/TreePrinters.scala
+++ b/src/compiler/scala/reflect/internal/TreePrinters.scala
@@ -373,11 +373,9 @@ trait TreePrinters extends api.TreePrinters { self: SymbolTable =>
case Select(qualifier, name) =>
print(backquotedPath(qualifier), ".", symName(tree, name))
- case bqid: BackQuotedIdent =>
- print("`%s`" format symName(tree, bqid.name))
-
- case Ident(name) =>
- print(symName(tree, name))
+ case id @ Ident(name) =>
+ val str = symName(tree, name)
+ print( if (id.isBackquoted) "`" + str + "`" else str )
case Literal(x) =>
print(x.escapedStringValue)
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 337ca7671c..c02a7e493e 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -1027,7 +1027,7 @@ self =>
val tok = in.token
val name = ident()
t = atPos(start) {
- if (tok == BACKQUOTED_IDENT) new BackQuotedIdent(name)
+ if (tok == BACKQUOTED_IDENT) Ident(name) withAttachment BackquotedIdentifier
else Ident(name)
}
if (in.token == DOT) {
@@ -2506,7 +2506,6 @@ self =>
}
else {
val nameOffset = in.offset
- val isBackquoted = in.token == BACKQUOTED_IDENT
val name = ident()
funDefRest(start, nameOffset, mods, name)
}
@@ -2601,7 +2600,6 @@ self =>
newLinesOpt()
atPos(start, in.offset) {
val nameOffset = in.offset
- val isBackquoted = in.token == BACKQUOTED_IDENT
val name = identForType()
// @M! a type alias as well as an abstract type may declare type parameters
val tparams = typeParamClauseOpt(name, null)
@@ -2660,7 +2658,6 @@ self =>
def classDef(start: Int, mods: Modifiers): ClassDef = {
in.nextToken
val nameOffset = in.offset
- val isBackquoted = in.token == BACKQUOTED_IDENT
val name = identForType()
atPos(start, if (name == tpnme.ERROR) start else nameOffset) {
savingClassContextBounds {
@@ -2701,7 +2698,6 @@ self =>
def objectDef(start: Int, mods: Modifiers): ModuleDef = {
in.nextToken
val nameOffset = in.offset
- val isBackquoted = in.token == BACKQUOTED_IDENT
val name = ident()
val tstart = in.offset
atPos(start, if (name == nme.ERROR) start else nameOffset) {
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 917542aa76..e60cda6af7 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -1458,6 +1458,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
analyzer.ImplicitNotFoundMsg.check(sym) foreach { warn =>
unit.warning(tree.pos, "Invalid implicitNotFound message for %s%s:\n%s".format(sym, sym.locationString, warn))
}
+
case tpt@TypeTree() =>
if(tpt.original != null) {
tpt.original foreach {