aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/parsing/Parsers.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-11-21 10:22:07 +0100
committerMartin Odersky <odersky@gmail.com>2016-11-21 10:22:07 +0100
commit7f0637ce073131d8603c567329885e4443cd48d5 (patch)
treef94fa7e704b901d51fec272176090e174ffbb106 /src/dotty/tools/dotc/parsing/Parsers.scala
parent5c7617b006fe4446a105b3db4916956a92826304 (diff)
downloaddotty-7f0637ce073131d8603c567329885e4443cd48d5.tar.gz
dotty-7f0637ce073131d8603c567329885e4443cd48d5.tar.bz2
dotty-7f0637ce073131d8603c567329885e4443cd48d5.zip
Make This and Super take idents as qualifier/mixin
The qualifier of a This and the mixin of a Super were names, which meant that their positions were lost. Now they are untyped idents.
Diffstat (limited to 'src/dotty/tools/dotc/parsing/Parsers.scala')
-rw-r--r--src/dotty/tools/dotc/parsing/Parsers.scala27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala
index e0c6be8c8..68d7e1a53 100644
--- a/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -527,27 +527,28 @@ object Parsers {
*/
def path(thisOK: Boolean, finish: Tree => Tree = id): Tree = {
val start = in.offset
- def handleThis(name: TypeName) = {
+ def handleThis(qual: Ident) = {
in.nextToken()
- val t = atPos(start) { This(name) }
+ val t = atPos(start) { This(qual) }
if (!thisOK && in.token != DOT) syntaxError("`.' expected")
dotSelectors(t, finish)
}
- def handleSuper(name: TypeName) = {
+ def handleSuper(qual: Ident) = {
in.nextToken()
val mix = mixinQualifierOpt()
- val t = atPos(start) { Super(This(name), mix) }
+ val t = atPos(start) { Super(This(qual), mix) }
accept(DOT)
dotSelectors(selector(t), finish)
}
- if (in.token == THIS) handleThis(tpnme.EMPTY)
- else if (in.token == SUPER) handleSuper(tpnme.EMPTY)
+ if (in.token == THIS) handleThis(EmptyTypeIdent)
+ else if (in.token == SUPER) handleSuper(EmptyTypeIdent)
else {
val t = termIdent()
if (in.token == DOT) {
+ def qual = cpy.Ident(t)(t.name.toTypeName)
in.nextToken()
- if (in.token == THIS) handleThis(t.name.toTypeName)
- else if (in.token == SUPER) handleSuper(t.name.toTypeName)
+ if (in.token == THIS) handleThis(qual)
+ else if (in.token == SUPER) handleSuper(qual)
else selectors(t, finish)
}
else t
@@ -556,9 +557,9 @@ object Parsers {
/** MixinQualifier ::= `[' Id `]'
*/
- def mixinQualifierOpt(): TypeName =
- if (in.token == LBRACKET) inBrackets(ident().toTypeName)
- else tpnme.EMPTY
+ def mixinQualifierOpt(): Ident =
+ if (in.token == LBRACKET) inBrackets(atPos(in.offset) { typeIdent() })
+ else EmptyTypeIdent
/** StableId ::= Id
* | Path `.' Id
@@ -617,7 +618,7 @@ object Parsers {
termIdent()
else if (in.token == THIS) {
in.nextToken()
- This(tpnme.EMPTY)
+ This(EmptyTypeIdent)
}
else if (in.token == LBRACE)
if (inPattern) Block(Nil, inBraces(pattern()))
@@ -2145,7 +2146,7 @@ object Parsers {
val first = expr1()
if (in.token == ARROW) {
first match {
- case Typed(tree @ This(tpnme.EMPTY), tpt) =>
+ case Typed(tree @ This(EmptyTypeIdent), tpt) =>
self = makeSelfDef(nme.WILDCARD, tpt).withPos(first.pos)
case _ =>
val ValDef(name, tpt, _) = convertToParam(first, expected = "self type clause")