diff options
author | Dmitry Petrashko <dark@d-d.me> | 2015-11-22 23:11:42 +0100 |
---|---|---|
committer | Dmitry Petrashko <dark@d-d.me> | 2015-11-22 23:11:42 +0100 |
commit | 4463f5e705480c7da188695abdb0ccacf452103c (patch) | |
tree | 538fb722301891470ad52192d2c82a869de9f0ea | |
parent | dce7053f3a6b859733253edcc82ad42b6ea3ed73 (diff) | |
parent | b7aae3f3deeb219c79a808454563145bf1b15243 (diff) | |
download | dotty-4463f5e705480c7da188695abdb0ccacf452103c.tar.gz dotty-4463f5e705480c7da188695abdb0ccacf452103c.tar.bz2 dotty-4463f5e705480c7da188695abdb0ccacf452103c.zip |
Merge pull request #969 from dotty-staging/change-swap-annot-args
Swap order of arguments in annotations
-rw-r--r-- | src/dotty/tools/backend/jvm/DottyBackendInterface.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeErasure.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeOps.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 27 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/TastyFormat.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/TreePickler.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/printing/PlainPrinter.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/PostTyper.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Inferencing.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/TypeAssigner.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/VarianceChecker.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Variances.scala | 4 |
15 files changed, 28 insertions, 32 deletions
diff --git a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala index 1498be354..f70143888 100644 --- a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala +++ b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala @@ -843,7 +843,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{ * meta-annotated annotations (@(ann @getter) val x = 0), so we don't emit a warning. * The type in the AnnotationInfo is an AnnotatedTpe. Tested in jvm/annotations.scala. */ - case a @ AnnotatedType(_, t) => + case a @ AnnotatedType(t, _) => debuglog(s"typeKind of annotated type $a") t.toTypeKind(ct)(storage) diff --git a/src/dotty/tools/dotc/core/TypeErasure.scala b/src/dotty/tools/dotc/core/TypeErasure.scala index 8f116c85f..7cca37911 100644 --- a/src/dotty/tools/dotc/core/TypeErasure.scala +++ b/src/dotty/tools/dotc/core/TypeErasure.scala @@ -44,7 +44,7 @@ object TypeErasure { true case JavaArrayType(elem) => isErasedType(elem) - case AnnotatedType(_, tp) => + case AnnotatedType(tp, _) => isErasedType(tp) case ThisType(tref) => isErasedType(tref) diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index 4cfc52909..f3884e11a 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -482,7 +482,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object. normalizeToRef(tp1) case ErrorType => defn.AnyType - case AnnotatedType(_, tpe) => + case AnnotatedType(tpe, _) => normalizeToRef(tpe) case _ => throw new TypeError(s"unexpected parent type: $tp") diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index db518d959..2558dcbb7 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -176,7 +176,7 @@ object Types { /** Does the type carry an annotation that is an instance of `cls`? */ final def hasAnnotation(cls: ClassSymbol)(implicit ctx: Context): Boolean = stripTypeVar match { - case AnnotatedType(annot, tp) => (annot matches cls) || (tp hasAnnotation cls) + case AnnotatedType(tp, annot) => (annot matches cls) || (tp hasAnnotation cls) case _ => false } @@ -758,7 +758,7 @@ object Types { case tp: LazyRef => tp.ref.dealias case tp: AnnotatedType => - tp.derivedAnnotatedType(tp.annot, tp.tpe.dealias) + tp.derivedAnnotatedType(tp.tpe.dealias, tp.annot) case tp => tp } @@ -2197,7 +2197,7 @@ object Types { def fromSymbols(params: List[Symbol], resultType: Type)(implicit ctx: Context) = { def translateRepeated(tp: Type): Type = tp match { case tp @ ExprType(tp1) => tp.derivedExprType(translateRepeated(tp1)) - case AnnotatedType(annot, tp) if annot matches defn.RepeatedAnnot => + case AnnotatedType(tp, annot) if annot matches defn.RepeatedAnnot => val typeSym = tp.typeSymbol.asClass assert(typeSym == defn.SeqClass || typeSym == defn.ArrayClass) tp.translateParameterized(typeSym, defn.RepeatedParamClass) @@ -2787,23 +2787,22 @@ object Types { // ----- Annotated and Import types ----------------------------------------------- /** An annotated type tpe @ annot */ - case class AnnotatedType(annot: Annotation, tpe: Type) + case class AnnotatedType(tpe: Type, annot: Annotation) extends UncachedProxyType with ValueType { // todo: cache them? but this makes only sense if annotations and trees are also cached. override def underlying(implicit ctx: Context): Type = tpe - def derivedAnnotatedType(annot: Annotation, tpe: Type) = - if ((annot eq this.annot) && (tpe eq this.tpe)) this - else AnnotatedType(annot, tpe) + def derivedAnnotatedType(tpe: Type, annot: Annotation) = + if ((tpe eq this.tpe) && (annot eq this.annot)) this + else AnnotatedType(tpe, annot) override def stripTypeVar(implicit ctx: Context): Type = - derivedAnnotatedType(annot, tpe.stripTypeVar) + derivedAnnotatedType(tpe.stripTypeVar, annot) override def stripAnnots(implicit ctx: Context): Type = tpe.stripAnnots } object AnnotatedType { - def make(annots: List[Annotation], underlying: Type) = - if (annots.isEmpty) underlying - else (underlying /: annots)((tp, ann) => AnnotatedType(ann, tp)) + def make(underlying: Type, annots: List[Annotation]) = + (underlying /: annots)(AnnotatedType(_, _)) } // Special type objects and classes ----------------------------------------------------- @@ -2997,9 +2996,9 @@ object Types { case tp: SkolemType => tp.derivedSkolemType(this(tp.info)) - case tp @ AnnotatedType(annot, underlying) => + case tp @ AnnotatedType(underlying, annot) => val underlying1 = this(underlying) - if (underlying1 eq underlying) tp else tp.derivedAnnotatedType(mapOver(annot), underlying1) + if (underlying1 eq underlying) tp else tp.derivedAnnotatedType(underlying1, mapOver(annot)) case tp @ WildcardType => tp.derivedWildcardType(mapOver(tp.optBounds)) @@ -3139,7 +3138,7 @@ object Types { case tp: SkolemType => this(x, tp.info) - case AnnotatedType(annot, underlying) => + case AnnotatedType(underlying, annot) => this(applyToAnnot(x, annot), underlying) case tp: TypeVar => diff --git a/src/dotty/tools/dotc/core/tasty/TastyFormat.scala b/src/dotty/tools/dotc/core/tasty/TastyFormat.scala index 94ed94052..1f24397c6 100644 --- a/src/dotty/tools/dotc/core/tasty/TastyFormat.scala +++ b/src/dotty/tools/dotc/core/tasty/TastyFormat.scala @@ -131,7 +131,7 @@ Standard-Section: "ASTs" TopLevelStat* APPLIEDtype Length tycon_Type arg_Type* TYPEBOUNDS Length low_Type high_Type TYPEALIAS Length alias_Type (COVARIANT | CONTRAVARIANT)? - ANNOTATED Length fullAnnotation_Term underlying_Type + ANNOTATED Length underlying_Type fullAnnotation_Term ANDtype Length left_Type right_Type ORtype Length left_Type right_Type BIND Length boundName_NameRef bounds_Type diff --git a/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/src/dotty/tools/dotc/core/tasty/TreePickler.scala index 86bbc893f..dae201a79 100644 --- a/src/dotty/tools/dotc/core/tasty/TreePickler.scala +++ b/src/dotty/tools/dotc/core/tasty/TreePickler.scala @@ -239,7 +239,7 @@ class TreePickler(pickler: TastyPickler) { withLength { pickleType(tpe.lo, richTypes); pickleType(tpe.hi, richTypes) } case tpe: AnnotatedType => writeByte(ANNOTATED) - withLength { pickleTree(tpe.annot.tree); pickleType(tpe.tpe, richTypes) } + withLength { pickleType(tpe.tpe, richTypes); pickleTree(tpe.annot.tree) } case tpe: AndOrType => writeByte(if (tpe.isAnd) ANDtype else ORtype) withLength { pickleType(tpe.tp1, richTypes); pickleType(tpe.tp2, richTypes) } diff --git a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 552d931d7..426a6804b 100644 --- a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -199,7 +199,7 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) { else 0 TypeAlias(alias, variance) case ANNOTATED => - AnnotatedType(Annotation(readTerm()), readType()) + AnnotatedType(readType(), Annotation(readTerm())) case ANDtype => AndType(readType(), readType()) case ORtype => diff --git a/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala index d14423b7b..cf7b487bb 100644 --- a/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala +++ b/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala @@ -800,10 +800,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas val boundSyms = until(end, readSymbolRef) elimExistentials(boundSyms, restpe) case ANNOTATEDtpe => - val tp = readTypeRef() - // no annotation self type is supported, so no test whether this is a symbol ref - val annots = until(end, readAnnotationRef) - AnnotatedType.make(annots, tp) + AnnotatedType.make(readTypeRef(), until(end, readAnnotationRef)) case _ => noSuchTypeTag(tag, end) } diff --git a/src/dotty/tools/dotc/printing/PlainPrinter.scala b/src/dotty/tools/dotc/printing/PlainPrinter.scala index 8b2d68570..0d925a27d 100644 --- a/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -158,7 +158,7 @@ class PlainPrinter(_ctx: Context) extends Printer { } case PolyParam(pt, n) => toText(polyParamName(pt.paramNames(n))) ~ polyHash(pt) - case AnnotatedType(annot, tpe) => + case AnnotatedType(tpe, annot) => toTextLocal(tpe) ~ " " ~ toText(annot) case tp: TypeVar => if (tp.isInstantiated) diff --git a/src/dotty/tools/dotc/transform/PostTyper.scala b/src/dotty/tools/dotc/transform/PostTyper.scala index 221d097f9..75c98ae8a 100644 --- a/src/dotty/tools/dotc/transform/PostTyper.scala +++ b/src/dotty/tools/dotc/transform/PostTyper.scala @@ -190,7 +190,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran case tree: TypeTree => tree.withType( tree.tpe match { - case AnnotatedType(annot, tpe) => AnnotatedType(transformAnnot(annot), tpe) + case AnnotatedType(tpe, annot) => AnnotatedType(tpe, transformAnnot(annot)) case tpe => tpe } ) diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala index ac4ad1b35..1e8dcf4b2 100644 --- a/src/dotty/tools/dotc/typer/Inferencing.scala +++ b/src/dotty/tools/dotc/typer/Inferencing.scala @@ -179,7 +179,7 @@ object Inferencing { /** Recursively widen and also follow type declarations and type aliases. */ def widenForMatchSelector(tp: Type)(implicit ctx: Context): Type = tp.widen match { case tp: TypeRef if !tp.symbol.isClass => widenForMatchSelector(tp.info.bounds.hi) - case tp: AnnotatedType => tp.derivedAnnotatedType(tp.annot, widenForMatchSelector(tp.tpe)) + case tp: AnnotatedType => tp.derivedAnnotatedType(widenForMatchSelector(tp.tpe), tp.annot) case tp => tp } diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala index f7cda1ef6..30d6baf8a 100644 --- a/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -404,7 +404,7 @@ trait TypeAssigner { tree.withType(sym.nonMemberTermRef) def assignType(tree: untpd.Annotated, annot: Tree, arg: Tree)(implicit ctx: Context) = - tree.withType(AnnotatedType(Annotation(annot), arg.tpe)) + tree.withType(AnnotatedType(arg.tpe, Annotation(annot))) def assignType(tree: untpd.PackageDef, pid: Tree)(implicit ctx: Context) = tree.withType(pid.symbol.valRef) diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 0ae04cbe8..3f5c4f47e 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -1051,7 +1051,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit if (ctx.mode is Mode.Type) assignType(cpy.Annotated(tree)(annot1, arg1), annot1, arg1) else { - val tpt = TypeTree(AnnotatedType(Annotation(annot1), arg1.tpe.widen)) + val tpt = TypeTree(AnnotatedType(arg1.tpe.widen, Annotation(annot1))) assignType(cpy.Typed(tree)(arg1, tpt), tpt) } } diff --git a/src/dotty/tools/dotc/typer/VarianceChecker.scala b/src/dotty/tools/dotc/typer/VarianceChecker.scala index 5d3bd4f20..86b1676c5 100644 --- a/src/dotty/tools/dotc/typer/VarianceChecker.scala +++ b/src/dotty/tools/dotc/typer/VarianceChecker.scala @@ -90,7 +90,7 @@ class VarianceChecker()(implicit ctx: Context) { this(status, tp.resultType) // params will be checked in their TypeDef nodes. case tp: PolyType => this(status, tp.resultType) // params will be checked in their ValDef nodes. - case AnnotatedType(annot, _) if annot.symbol == defn.UncheckedVarianceAnnot => + case AnnotatedType(_, annot) if annot.symbol == defn.UncheckedVarianceAnnot => status //case tp: ClassInfo => // ??? not clear what to do here yet. presumably, it's all checked at local typedefs diff --git a/src/dotty/tools/dotc/typer/Variances.scala b/src/dotty/tools/dotc/typer/Variances.scala index 0cc9e74cc..55e6b5232 100644 --- a/src/dotty/tools/dotc/typer/Variances.scala +++ b/src/dotty/tools/dotc/typer/Variances.scala @@ -83,8 +83,8 @@ object Variances { varianceInType(restpe)(tparam) case tp @ PolyType(_) => flip(varianceInTypes(tp.paramBounds)(tparam)) & varianceInType(tp.resultType)(tparam) - case AnnotatedType(annot, tp) => - varianceInAnnot(annot)(tparam) & varianceInType(tp)(tparam) + case AnnotatedType(tp, annot) => + varianceInType(tp)(tparam) & varianceInAnnot(annot)(tparam) case tp: AndOrType => varianceInType(tp.tp1)(tparam) & varianceInType(tp.tp2)(tparam) case _ => |