aboutsummaryrefslogtreecommitdiff
path: root/src/dotty
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-09-24 16:50:58 +0200
committerMartin Odersky <odersky@gmail.com>2016-09-24 16:50:58 +0200
commit331e75be7e90817bc2931c3d00dd931b22c179f5 (patch)
treee9541e8aad22f3d6f8e9b4ade3eab1ad644a46c6 /src/dotty
parentfb710457959d1c2d4b983986141875a8fde5992b (diff)
downloaddotty-331e75be7e90817bc2931c3d00dd931b22c179f5.tar.gz
dotty-331e75be7e90817bc2931c3d00dd931b22c179f5.tar.bz2
dotty-331e75be7e90817bc2931c3d00dd931b22c179f5.zip
Swap order of elements in Annotated
Now it's annotated first, annotation second. This is in line with AnnotatedType and in line with the principle that tree arguments should come in the order they are written. The reason why the order was swapped before is historical - Scala2 did it that way.
Diffstat (limited to 'src/dotty')
-rw-r--r--src/dotty/tools/dotc/ast/Desugar.scala10
-rw-r--r--src/dotty/tools/dotc/ast/TreeInfo.scala2
-rw-r--r--src/dotty/tools/dotc/ast/Trees.scala16
-rw-r--r--src/dotty/tools/dotc/ast/tpd.scala10
-rw-r--r--src/dotty/tools/dotc/ast/untpd.scala2
-rw-r--r--src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala2
-rw-r--r--src/dotty/tools/dotc/parsing/Parsers.scala8
-rw-r--r--src/dotty/tools/dotc/printing/RefinedPrinter.scala2
-rw-r--r--src/dotty/tools/dotc/transform/ExpandSAMs.scala2
-rw-r--r--src/dotty/tools/dotc/transform/PostTyper.scala4
-rw-r--r--src/dotty/tools/dotc/transform/TreeChecker.scala2
-rw-r--r--src/dotty/tools/dotc/typer/TypeAssigner.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala2
13 files changed, 32 insertions, 32 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala
index 36cae6378..d7ae1bf85 100644
--- a/src/dotty/tools/dotc/ast/Desugar.scala
+++ b/src/dotty/tools/dotc/ast/Desugar.scala
@@ -632,7 +632,7 @@ object desugar {
val selector = makeTuple(params.map(p => Ident(p.name)))
if (unchecked)
- Function(params, Match(Annotated(New(ref(defn.UncheckedAnnotType)), selector), cases))
+ Function(params, Match(Annotated(selector, New(ref(defn.UncheckedAnnotType))), cases))
else
Function(params, Match(selector, cases))
}
@@ -661,7 +661,7 @@ object desugar {
* tree @cls
*/
def makeAnnotated(cls: Symbol, tree: Tree)(implicit ctx: Context) =
- Annotated(untpd.New(untpd.TypeTree(cls.typeRef), Nil), tree)
+ Annotated(tree, untpd.New(untpd.TypeTree(cls.typeRef), Nil))
private def derivedValDef(original: Tree, named: NameTree, tpt: Tree, rhs: Tree, mods: Modifiers)(implicit ctx: Context) = {
val vdef = ValDef(named.name.asTermName, tpt, rhs)
@@ -904,8 +904,8 @@ object desugar {
if ((ctx.mode is Mode.Type) && op == nme.raw.STAR) {
val seqType = if (ctx.compilationUnit.isJava) defn.ArrayType else defn.SeqType
Annotated(
- New(ref(defn.RepeatedAnnotType), Nil :: Nil),
- AppliedTypeTree(ref(seqType), t))
+ AppliedTypeTree(ref(seqType), t),
+ New(ref(defn.RepeatedAnnotType), Nil :: Nil))
} else {
assert(ctx.mode.isExpr || ctx.reporter.hasErrors, ctx.mode)
Select(t, op)
@@ -1052,7 +1052,7 @@ object desugar {
case Alternative(trees) =>
for (tree <- trees; (vble, _) <- getVariables(tree))
ctx.error("illegal variable in pattern alternative", vble.pos)
- case Annotated(annot, arg) =>
+ case Annotated(arg, _) =>
collect(arg)
case InterpolatedString(_, _, elems) =>
elems foreach collect
diff --git a/src/dotty/tools/dotc/ast/TreeInfo.scala b/src/dotty/tools/dotc/ast/TreeInfo.scala
index 6c371abc1..0d4179218 100644
--- a/src/dotty/tools/dotc/ast/TreeInfo.scala
+++ b/src/dotty/tools/dotc/ast/TreeInfo.scala
@@ -183,7 +183,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
case RefinedTypeTree(tpt, refinements) => mayBeTypePat(tpt) || refinements.exists(_.isInstanceOf[Bind])
case AppliedTypeTree(tpt, args) => mayBeTypePat(tpt) || args.exists(_.isInstanceOf[Bind])
case SelectFromTypeTree(tpt, _) => mayBeTypePat(tpt)
- case Annotated(_, tpt) => mayBeTypePat(tpt)
+ case Annotated(tpt, _) => mayBeTypePat(tpt)
case _ => false
}
diff --git a/src/dotty/tools/dotc/ast/Trees.scala b/src/dotty/tools/dotc/ast/Trees.scala
index 4ba4eda0a..5744742b8 100644
--- a/src/dotty/tools/dotc/ast/Trees.scala
+++ b/src/dotty/tools/dotc/ast/Trees.scala
@@ -709,7 +709,7 @@ object Trees {
}
/** arg @annot */
- case class Annotated[-T >: Untyped] private[ast] (annot: Tree[T], arg: Tree[T])
+ case class Annotated[-T >: Untyped] private[ast] (arg: Tree[T], annot: Tree[T])
extends ProxyTree[T] {
type ThisTree[-T >: Untyped] = Annotated[T]
def forwardTo = arg
@@ -1082,9 +1082,9 @@ object Trees {
case tree: PackageDef if (pid eq tree.pid) && (stats eq tree.stats) => tree
case _ => finalize(tree, untpd.PackageDef(pid, stats))
}
- def Annotated(tree: Tree)(annot: Tree, arg: Tree)(implicit ctx: Context): Annotated = tree match {
- case tree: Annotated if (annot eq tree.annot) && (arg eq tree.arg) => tree
- case _ => finalize(tree, untpd.Annotated(annot, arg))
+ def Annotated(tree: Tree)(arg: Tree, annot: Tree)(implicit ctx: Context): Annotated = tree match {
+ case tree: Annotated if (arg eq tree.arg) && (annot eq tree.annot) => tree
+ case _ => finalize(tree, untpd.Annotated(arg, annot))
}
def Thicket(tree: Tree)(trees: List[Tree]): Thicket = tree match {
case tree: Thicket if trees eq tree.trees => tree
@@ -1198,8 +1198,8 @@ object Trees {
cpy.Import(tree)(transform(expr), selectors)
case PackageDef(pid, stats) =>
cpy.PackageDef(tree)(transformSub(pid), transformStats(stats))
- case Annotated(annot, arg) =>
- cpy.Annotated(tree)(transform(annot), transform(arg))
+ case Annotated(arg, annot) =>
+ cpy.Annotated(tree)(transform(arg), transform(annot))
case Thicket(trees) =>
val trees1 = transform(trees)
if (trees1 eq trees) tree else Thicket(trees1)
@@ -1304,8 +1304,8 @@ object Trees {
this(x, expr)
case PackageDef(pid, stats) =>
this(this(x, pid), stats)(localCtx)
- case Annotated(annot, arg) =>
- this(this(x, annot), arg)
+ case Annotated(arg, annot) =>
+ this(this(x, arg), annot)
case Thicket(ts) =>
this(x, ts)
}
diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala
index 5fa787b8c..022671540 100644
--- a/src/dotty/tools/dotc/ast/tpd.scala
+++ b/src/dotty/tools/dotc/ast/tpd.scala
@@ -292,8 +292,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
def PackageDef(pid: RefTree, stats: List[Tree])(implicit ctx: Context): PackageDef =
ta.assignType(untpd.PackageDef(pid, stats), pid)
- def Annotated(annot: Tree, arg: Tree)(implicit ctx: Context): Annotated =
- ta.assignType(untpd.Annotated(annot, arg), annot, arg)
+ def Annotated(arg: Tree, annot: Tree)(implicit ctx: Context): Annotated =
+ ta.assignType(untpd.Annotated(arg, annot), arg, annot)
def Throw(expr: Tree)(implicit ctx: Context): Tree =
ref(defn.throwMethod).appliedTo(expr)
@@ -568,11 +568,11 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
}
}
- override def Annotated(tree: Tree)(annot: Tree, arg: Tree)(implicit ctx: Context): Annotated = {
- val tree1 = untpd.cpy.Annotated(tree)(annot, arg)
+ override def Annotated(tree: Tree)(arg: Tree, annot: Tree)(implicit ctx: Context): Annotated = {
+ val tree1 = untpd.cpy.Annotated(tree)(arg, annot)
tree match {
case tree: Annotated if (arg.tpe eq tree.arg.tpe) && (annot eq tree.annot) => tree1.withTypeUnchecked(tree.tpe)
- case _ => ta.assignType(tree1, annot, arg)
+ case _ => ta.assignType(tree1, arg, annot)
}
}
diff --git a/src/dotty/tools/dotc/ast/untpd.scala b/src/dotty/tools/dotc/ast/untpd.scala
index 4e18b1d5c..fdc4be823 100644
--- a/src/dotty/tools/dotc/ast/untpd.scala
+++ b/src/dotty/tools/dotc/ast/untpd.scala
@@ -159,7 +159,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
def Template(constr: DefDef, parents: List[Tree], self: ValDef, body: LazyTreeList): Template = new Template(constr, parents, self, body)
def Import(expr: Tree, selectors: List[untpd.Tree]): Import = new Import(expr, selectors)
def PackageDef(pid: RefTree, stats: List[Tree]): PackageDef = new PackageDef(pid, stats)
- def Annotated(annot: Tree, arg: Tree): Annotated = new Annotated(annot, arg)
+ def Annotated(arg: Tree, annot: Tree): Annotated = new Annotated(arg, annot)
// ------ Additional creation methods for untyped only -----------------
diff --git a/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
index 0d91e8cd6..371d20e60 100644
--- a/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
+++ b/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
@@ -1186,7 +1186,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
case ANNOTATEDtree =>
val annot = readTreeRef()
val arg = readTreeRef()
- Annotated(annot, arg)
+ Annotated(arg, annot)
case SINGLETONTYPEtree =>
SingletonTypeTree(readTreeRef())
diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala
index 153b58283..b8ec38268 100644
--- a/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -338,7 +338,7 @@ object Parsers {
def isWildcard(t: Tree): Boolean = t match {
case Ident(name1) => placeholderParams.nonEmpty && name1 == placeholderParams.head.name
case Typed(t1, _) => isWildcard(t1)
- case t: Annotated => isWildcard(t.arg)
+ case Annotated(t1, _) => isWildcard(t1)
case Parens(t1) => isWildcard(t1)
case _ => false
}
@@ -742,7 +742,7 @@ object Parsers {
def annotType(): Tree = annotTypeRest(simpleType())
def annotTypeRest(t: Tree): Tree =
- if (in.token == AT) annotTypeRest(atPos(t.pos.start) { Annotated(annot(), t) })
+ if (in.token == AT) annotTypeRest(atPos(t.pos.start) { Annotated(t, annot()) })
else t
/** SimpleType ::= SimpleType TypeArgs
@@ -900,7 +900,7 @@ object Parsers {
private final def findWildcardType(t: Tree): Option[Position] = t match {
case TypeBoundsTree(_, _) => Some(t.pos)
case Parens(t1) => findWildcardType(t1)
- case Annotated(_, t1) => findWildcardType(t1)
+ case Annotated(t1, _) => findWildcardType(t1)
case _ => None
}
@@ -1071,7 +1071,7 @@ object Parsers {
syntaxErrorOrIncomplete("`*' expected"); t
}
case AT if location != Location.InPattern =>
- (t /: annotations()) ((t, annot) => Annotated(annot, t))
+ (t /: annotations())(Annotated)
case _ =>
val tpt = typeDependingOn(location)
if (isWildcard(t) && location != Location.InPattern) {
diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
index 701c81a9d..9744e7026 100644
--- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala
+++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
@@ -434,7 +434,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
"package " ~ toTextPackageId(pid) ~ bodyText
case tree: Template =>
toTextTemplate(tree)
- case Annotated(annot, arg) =>
+ case Annotated(arg, annot) =>
toTextLocal(arg) ~~ annotText(annot)
case EmptyTree =>
"<empty>"
diff --git a/src/dotty/tools/dotc/transform/ExpandSAMs.scala b/src/dotty/tools/dotc/transform/ExpandSAMs.scala
index 04c6864b1..91399f91a 100644
--- a/src/dotty/tools/dotc/transform/ExpandSAMs.scala
+++ b/src/dotty/tools/dotc/transform/ExpandSAMs.scala
@@ -74,7 +74,7 @@ class ExpandSAMs extends MiniPhaseTransform { thisTransformer =>
Bind(defaultSym, Underscore(selector.tpe.widen)),
EmptyTree,
Literal(Constant(false)))
- val annotated = Annotated(New(ref(defn.UncheckedAnnotType)), paramRef)
+ val annotated = Annotated(paramRef, New(ref(defn.UncheckedAnnotType)))
cpy.Match(applyRhs)(annotated, cases.map(translateCase) :+ defaultCase)
case _ =>
tru
diff --git a/src/dotty/tools/dotc/transform/PostTyper.scala b/src/dotty/tools/dotc/transform/PostTyper.scala
index f27f116ef..6af225035 100644
--- a/src/dotty/tools/dotc/transform/PostTyper.scala
+++ b/src/dotty/tools/dotc/transform/PostTyper.scala
@@ -262,8 +262,8 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran
case tree: New if !inJavaAnnot && !parentNews.contains(tree) =>
Checking.checkInstantiable(tree.tpe, tree.pos)
super.transform(tree)
- case tree @ Annotated(annot, annotated) =>
- cpy.Annotated(tree)(transformAnnot(annot), transform(annotated))
+ case tree @ Annotated(annotated, annot) =>
+ cpy.Annotated(tree)(transform(annotated), transformAnnot(annot))
case tree: TypeTree =>
tree.withType(
tree.tpe match {
diff --git a/src/dotty/tools/dotc/transform/TreeChecker.scala b/src/dotty/tools/dotc/transform/TreeChecker.scala
index 18e3a6c8a..9d6445dc9 100644
--- a/src/dotty/tools/dotc/transform/TreeChecker.scala
+++ b/src/dotty/tools/dotc/transform/TreeChecker.scala
@@ -252,7 +252,7 @@ class TreeChecker extends Phase with SymTransformer {
// case tree: TypeBoundsTree =>
// case tree: Alternative =>
// case tree: PackageDef =>
- case Annotated(_, arg) =>
+ case Annotated(arg, _) =>
assertIdentNotJavaClass(arg)
case _ =>
}
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala
index 78919ccb6..740fa2658 100644
--- a/src/dotty/tools/dotc/typer/TypeAssigner.scala
+++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala
@@ -500,7 +500,7 @@ trait TypeAssigner {
def assignType(tree: untpd.Import, sym: Symbol)(implicit ctx: Context) =
tree.withType(sym.nonMemberTermRef)
- def assignType(tree: untpd.Annotated, annot: Tree, arg: Tree)(implicit ctx: Context) =
+ def assignType(tree: untpd.Annotated, arg: Tree, annot: Tree)(implicit ctx: Context) =
tree.withType(AnnotatedType(arg.tpe.widen, Annotation(annot)))
def assignType(tree: untpd.PackageDef, pid: Tree)(implicit ctx: Context) =
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index dcba7e7c4..af09a8283 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -1342,7 +1342,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
val annot1 = typedExpr(tree.annot, defn.AnnotationType)
val arg1 = typed(tree.arg, pt)
if (ctx.mode is Mode.Type)
- assignType(cpy.Annotated(tree)(annot1, arg1), annot1, arg1)
+ assignType(cpy.Annotated(tree)(arg1, annot1), arg1, annot1)
else {
val tpt = TypeTree(AnnotatedType(arg1.tpe.widen, Annotation(annot1)))
assignType(cpy.Typed(tree)(arg1, tpt), tpt)