aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/parsing
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2016-11-21 19:00:19 +0100
committerGitHub <noreply@github.com>2016-11-21 19:00:19 +0100
commit5b409515613173970d44a21978b04432cd01b73d (patch)
tree580409cc8e02bc2cfba3d5b94f62daa492ff2e49 /src/dotty/tools/dotc/parsing
parent601a286b1c1eb7f0bbea64609a7d07ed40f02118 (diff)
parenta2b1e601142e66255c252bf0584d2fc5ceb46b07 (diff)
downloaddotty-5b409515613173970d44a21978b04432cd01b73d.tar.gz
dotty-5b409515613173970d44a21978b04432cd01b73d.tar.bz2
dotty-5b409515613173970d44a21978b04432cd01b73d.zip
Merge pull request #1634 from dotty-staging/change-tasty-pos-ctd
Towards correct positions in TASTY types
Diffstat (limited to 'src/dotty/tools/dotc/parsing')
-rw-r--r--src/dotty/tools/dotc/parsing/JavaParsers.scala9
-rw-r--r--src/dotty/tools/dotc/parsing/Parsers.scala33
2 files changed, 21 insertions, 21 deletions
diff --git a/src/dotty/tools/dotc/parsing/JavaParsers.scala b/src/dotty/tools/dotc/parsing/JavaParsers.scala
index b6a423dc7..0f63b25bb 100644
--- a/src/dotty/tools/dotc/parsing/JavaParsers.scala
+++ b/src/dotty/tools/dotc/parsing/JavaParsers.scala
@@ -417,7 +417,7 @@ object JavaParsers {
atPos(in.offset) {
val name = identForType()
val hi = if (in.token == EXTENDS) { in.nextToken() ; bound() } else EmptyTree
- TypeDef(name, Nil, TypeBoundsTree(EmptyTree, hi)).withMods(Modifiers(flags))
+ TypeDef(name, TypeBoundsTree(EmptyTree, hi)).withMods(Modifiers(flags))
}
def bound(): Tree =
@@ -625,8 +625,7 @@ object JavaParsers {
val template = cdef.rhs.asInstanceOf[Template]
cpy.TypeDef(cdef)(cdef.name,
cpy.Template(template)(template.constr, template.parents, template.self,
- importCompanionObject(cdef) :: template.body),
- cdef.tparams).withMods(cdef.mods)
+ importCompanionObject(cdef) :: template.body)).withMods(cdef.mods)
}
List(makeCompanionObject(cdefNew, statics), cdefNew)
@@ -715,7 +714,7 @@ object JavaParsers {
val (statics, body) = typeBody(INTERFACE, name, tparams)
val iface = atPos(start, nameOffset) {
TypeDef(
- name, tparams,
+ name,
makeTemplate(parents, body, tparams, false)).withMods(mods | Flags.Trait | Flags.JavaInterface | Flags.Abstract)
}
addCompanionObject(statics, iface)
@@ -830,7 +829,7 @@ object JavaParsers {
Select(New(javaLangDot(tpnme.Enum)), nme.CONSTRUCTOR), List(enumType)),
List(Literal(Constant(null)),Literal(Constant(0))))
val enum = atPos(start, nameOffset) {
- TypeDef(name, List(),
+ TypeDef(name,
makeTemplate(superclazz :: interfaces, body, List(), true)).withMods(mods | Flags.Enum)
}
addCompanionObject(consts ::: statics ::: predefs, enum)
diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala
index bb76de6cc..fa0576c7a 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()))
@@ -1646,7 +1647,7 @@ object Parsers {
val bounds =
if (isConcreteOwner) typeParamBounds(name)
else typeBounds()
- TypeDef(name, hkparams, bounds).withMods(mods)
+ TypeDef(name, lambdaAbstract(hkparams, bounds)).withMods(mods)
}
}
commaSeparated(typeParam)
@@ -1956,9 +1957,9 @@ object Parsers {
in.token match {
case EQUALS =>
in.nextToken()
- TypeDef(name, tparams, typ()).withMods(mods).setComment(docstring)
+ TypeDef(name, lambdaAbstract(tparams, typ())).withMods(mods).setComment(docstring)
case SUPERTYPE | SUBTYPE | SEMI | NEWLINE | NEWLINES | COMMA | RBRACE | EOF =>
- TypeDef(name, tparams, typeBounds()).withMods(mods).setComment(docstring)
+ TypeDef(name, lambdaAbstract(tparams, typeBounds())).withMods(mods).setComment(docstring)
case _ =>
syntaxErrorOrIncomplete("`=', `>:', or `<:' expected")
EmptyTree
@@ -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")