diff options
author | Martin Odersky <odersky@gmail.com> | 2016-11-21 10:22:07 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-11-21 10:22:07 +0100 |
commit | 7f0637ce073131d8603c567329885e4443cd48d5 (patch) | |
tree | f94fa7e704b901d51fec272176090e174ffbb106 /src/dotty/tools/dotc/ast | |
parent | 5c7617b006fe4446a105b3db4916956a92826304 (diff) | |
download | dotty-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/ast')
-rw-r--r-- | src/dotty/tools/dotc/ast/Desugar.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/ast/Trees.scala | 14 | ||||
-rw-r--r-- | src/dotty/tools/dotc/ast/tpd.scala | 7 | ||||
-rw-r--r-- | src/dotty/tools/dotc/ast/untpd.scala | 8 |
4 files changed, 19 insertions, 12 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index 3c510c7b9..8f9c42e21 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -340,7 +340,7 @@ object desugar { val isDefinedMeth = syntheticProperty(nme.isDefined, Literal(Constant(true))) val caseParams = constrVparamss.head.toArray val productElemMeths = for (i <- 0 until arity) yield - syntheticProperty(nme.selectorName(i), Select(This(EmptyTypeName), caseParams(i).name)) + syntheticProperty(nme.selectorName(i), Select(This(EmptyTypeIdent), caseParams(i).name)) def isRepeated(tree: Tree): Boolean = tree match { case PostfixOp(_, nme.raw.STAR) => true case ByNameTypeTree(tree1) => isRepeated(tree1) diff --git a/src/dotty/tools/dotc/ast/Trees.scala b/src/dotty/tools/dotc/ast/Trees.scala index 78ac66812..2801bcae2 100644 --- a/src/dotty/tools/dotc/ast/Trees.scala +++ b/src/dotty/tools/dotc/ast/Trees.scala @@ -159,7 +159,7 @@ object Trees { /** Does this tree define a new symbol that is not defined elsewhere? */ def isDef: Boolean = false - /** Is this tree either the empty tree or the empty ValDef? */ + /** Is this tree either the empty tree or the empty ValDef or an empty type ident? */ def isEmpty: Boolean = false /** Convert tree to a list. Gives a singleton list, except @@ -353,7 +353,7 @@ object Trees { } /** qual.this */ - case class This[-T >: Untyped] private[ast] (qual: TypeName) + case class This[-T >: Untyped] private[ast] (qual: untpd.Ident) extends DenotingTree[T] with TermTree[T] { type ThisTree[-T >: Untyped] = This[T] // Denotation of a This tree is always the underlying class; needs correction for modules. @@ -368,7 +368,7 @@ object Trees { } /** C.super[mix], where qual = C.this */ - case class Super[-T >: Untyped] private[ast] (qual: Tree[T], mix: TypeName) + case class Super[-T >: Untyped] private[ast] (qual: Tree[T], mix: untpd.Ident) extends ProxyTree[T] with TermTree[T] { type ThisTree[-T >: Untyped] = Super[T] def forwardTo = qual @@ -890,12 +890,12 @@ object Trees { case tree: Select if (qualifier eq tree.qualifier) && (name == tree.name) => tree case _ => finalize(tree, untpd.Select(qualifier, name)) } - def This(tree: Tree)(qual: TypeName): This = tree match { - case tree: This if qual == tree.qual => tree + def This(tree: Tree)(qual: untpd.Ident): This = tree match { + case tree: This if qual eq tree.qual => tree case _ => finalize(tree, untpd.This(qual)) } - def Super(tree: Tree)(qual: Tree, mix: TypeName): Super = tree match { - case tree: Super if (qual eq tree.qual) && (mix == tree.mix) => tree + def Super(tree: Tree)(qual: Tree, mix: untpd.Ident): Super = tree match { + case tree: Super if (qual eq tree.qual) && (mix eq tree.mix) => tree case _ => finalize(tree, untpd.Super(qual, mix)) } def Apply(tree: Tree)(fun: Tree, args: List[Tree])(implicit ctx: Context): Apply = tree match { diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala index 09f2099d2..219d6d4ec 100644 --- a/src/dotty/tools/dotc/ast/tpd.scala +++ b/src/dotty/tools/dotc/ast/tpd.scala @@ -31,11 +31,14 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { untpd.Select(qualifier, tp.name).withType(tp) def This(cls: ClassSymbol)(implicit ctx: Context): This = - untpd.This(cls.name).withType(cls.thisType) + untpd.This(untpd.Ident(cls.name)).withType(cls.thisType) - def Super(qual: Tree, mix: TypeName, inConstrCall: Boolean, mixinClass: Symbol = NoSymbol)(implicit ctx: Context): Super = + def Super(qual: Tree, mix: untpd.Ident, inConstrCall: Boolean, mixinClass: Symbol)(implicit ctx: Context): Super = ta.assignType(untpd.Super(qual, mix), qual, inConstrCall, mixinClass) + def Super(qual: Tree, mixName: TypeName, inConstrCall: Boolean, mixinClass: Symbol = NoSymbol)(implicit ctx: Context): Super = + Super(qual, if (mixName.isEmpty) untpd.EmptyTypeIdent else untpd.Ident(mixName), inConstrCall, mixinClass) + def Apply(fn: Tree, args: List[Tree])(implicit ctx: Context): Apply = ta.assignType(untpd.Apply(fn, args), fn, args) diff --git a/src/dotty/tools/dotc/ast/untpd.scala b/src/dotty/tools/dotc/ast/untpd.scala index ac35ad09c..6c5210287 100644 --- a/src/dotty/tools/dotc/ast/untpd.scala +++ b/src/dotty/tools/dotc/ast/untpd.scala @@ -80,6 +80,10 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { case class ContextBounds(bounds: TypeBoundsTree, cxBounds: List[Tree]) extends TypTree case class PatDef(mods: Modifiers, pats: List[Tree], tpt: Tree, rhs: Tree) extends DefTree + @sharable object EmptyTypeIdent extends Ident(tpnme.EMPTY) with WithoutTypeOrPos[Untyped] { + override def isEmpty = true + } + /** A block arising from a right-associative infix operation, where, e.g. * * a +: b @@ -225,8 +229,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { def BackquotedIdent(name: Name): BackquotedIdent = new BackquotedIdent(name) def Select(qualifier: Tree, name: Name): Select = new Select(qualifier, name) def SelectWithSig(qualifier: Tree, name: Name, sig: Signature): Select = new SelectWithSig(qualifier, name, sig) - def This(qual: TypeName): This = new This(qual) - def Super(qual: Tree, mix: TypeName): Super = new Super(qual, mix) + def This(qual: Ident): This = new This(qual) + def Super(qual: Tree, mix: Ident): Super = new Super(qual, mix) def Apply(fun: Tree, args: List[Tree]): Apply = new Apply(fun, args) def TypeApply(fun: Tree, args: List[Tree]): TypeApply = new TypeApply(fun, args) def Literal(const: Constant): Literal = new Literal(const) |