summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-01-15 12:25:41 +0100
committerJason Zaugg <jzaugg@gmail.com>2014-01-15 12:32:36 +0100
commit07ff3a99b75174c4e4a4e52348b34aa0b68f51b1 (patch)
treede5bbfbbc7ddde80ae5b1a97a6a8f6b6560da8af /src/reflect/scala/reflect
parente089cafb5fd02e2457bafde3252da3a771d3180e (diff)
downloadscala-07ff3a99b75174c4e4a4e52348b34aa0b68f51b1.tar.gz
scala-07ff3a99b75174c4e4a4e52348b34aa0b68f51b1.tar.bz2
scala-07ff3a99b75174c4e4a4e52348b34aa0b68f51b1.zip
SI-8151 Remove -Yself-in-annots and associated implementation
This experimental option typechecked arguments of annotations with an injected value in scope named `self`: @Foo(self.foo < 1) This has been slated for removal [1] for some time. This commit removes it in one fell swoop, without any attempt at source compatibility with code that constructs or pattern matches on AnnotatedType. [1] https://groups.google.com/d/msg/scala-internals/VdZ5UJwQFGI/C6tZ493Yxx4J
Diffstat (limited to 'src/reflect/scala/reflect')
-rw-r--r--src/reflect/scala/reflect/api/Types.scala9
-rw-r--r--src/reflect/scala/reflect/internal/AnnotationInfos.scala4
-rw-r--r--src/reflect/scala/reflect/internal/Definitions.scala2
-rw-r--r--src/reflect/scala/reflect/internal/Importers.scala4
-rw-r--r--src/reflect/scala/reflect/internal/TreeGen.scala2
-rw-r--r--src/reflect/scala/reflect/internal/Types.scala32
-rw-r--r--src/reflect/scala/reflect/internal/Variances.scala4
-rw-r--r--src/reflect/scala/reflect/internal/pickling/UnPickler.scala2
-rw-r--r--src/reflect/scala/reflect/internal/tpe/GlbLubs.scala2
-rw-r--r--src/reflect/scala/reflect/internal/tpe/TypeComparers.scala6
-rw-r--r--src/reflect/scala/reflect/internal/tpe/TypeMaps.scala8
-rw-r--r--src/reflect/scala/reflect/internal/transform/Erasure.scala2
12 files changed, 30 insertions, 47 deletions
diff --git a/src/reflect/scala/reflect/api/Types.scala b/src/reflect/scala/reflect/api/Types.scala
index 9d2d06da69..4892b46e16 100644
--- a/src/reflect/scala/reflect/api/Types.scala
+++ b/src/reflect/scala/reflect/api/Types.scala
@@ -707,14 +707,14 @@ trait Types {
val AnnotatedType: AnnotatedTypeExtractor
/** An extractor class to create and pattern match with syntax
- * `AnnotatedType(annotations, underlying, selfsym)`.
+ * `AnnotatedType(annotations, underlying)`.
* Here, `annotations` are the annotations decorating the underlying type `underlying`.
* `selfSym` is a symbol representing the annotated type itself.
* @group Extractors
*/
abstract class AnnotatedTypeExtractor {
- def apply(annotations: List[Annotation], underlying: Type, selfsym: Symbol): AnnotatedType
- def unapply(tpe: AnnotatedType): Option[(List[Annotation], Type, Symbol)]
+ def apply(annotations: List[Annotation], underlying: Type): AnnotatedType
+ def unapply(tpe: AnnotatedType): Option[(List[Annotation], Type)]
}
/** The API that all annotated types support.
@@ -727,9 +727,6 @@ trait Types {
/** The annotee. */
def underlying: Type
-
- /** A symbol that represents the annotated type itself. */
- def selfsym: Symbol
}
/** The `TypeBounds` type signature is used to indicate lower and upper type bounds
diff --git a/src/reflect/scala/reflect/internal/AnnotationInfos.scala b/src/reflect/scala/reflect/internal/AnnotationInfos.scala
index f45fa40f89..4fde57ed02 100644
--- a/src/reflect/scala/reflect/internal/AnnotationInfos.scala
+++ b/src/reflect/scala/reflect/internal/AnnotationInfos.scala
@@ -290,8 +290,8 @@ trait AnnotationInfos extends api.Annotations { self: SymbolTable =>
* metaAnnotations = List(setter, field).
*/
def metaAnnotations: List[AnnotationInfo] = atp match {
- case AnnotatedType(metas, _, _) => metas
- case _ => Nil
+ case AnnotatedType(metas, _) => metas
+ case _ => Nil
}
/** The default kind of members to which this annotation is attached.
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala
index 38be6fcf56..83595506d9 100644
--- a/src/reflect/scala/reflect/internal/Definitions.scala
+++ b/src/reflect/scala/reflect/internal/Definitions.scala
@@ -692,7 +692,7 @@ trait Definitions extends api.StandardDefinitions {
case TypeRef(pre, sym, _) if sym.isModuleClass => isStable(pre)
case TypeRef(_, _, _) if tp ne tp.dealias => isStable(tp.dealias)
case TypeVar(origin, _) => isStable(origin)
- case AnnotatedType(_, atp, _) => isStable(atp) // Really?
+ case AnnotatedType(_, atp) => isStable(atp) // Really?
case _: SimpleTypeProxy => isStable(tp.underlying)
case _ => false
}
diff --git a/src/reflect/scala/reflect/internal/Importers.scala b/src/reflect/scala/reflect/internal/Importers.scala
index 91ba552012..86038afaf1 100644
--- a/src/reflect/scala/reflect/internal/Importers.scala
+++ b/src/reflect/scala/reflect/internal/Importers.scala
@@ -266,8 +266,8 @@ trait Importers extends api.Importers { to: SymbolTable =>
val myconstr = new TypeConstraint(their.constr.loBounds map importType, their.constr.hiBounds map importType)
myconstr.inst = importType(their.constr.inst)
TypeVar(importType(their.origin), myconstr, their.typeArgs map importType, their.params map importSymbol)
- case from.AnnotatedType(annots, result, selfsym) =>
- AnnotatedType(annots map importAnnotationInfo, importType(result), importSymbol(selfsym))
+ case from.AnnotatedType(annots, result) =>
+ AnnotatedType(annots map importAnnotationInfo, importType(result))
case from.ErrorType =>
ErrorType
case from.WildcardType =>
diff --git a/src/reflect/scala/reflect/internal/TreeGen.scala b/src/reflect/scala/reflect/internal/TreeGen.scala
index f6d21ec9bd..53f0e7c647 100644
--- a/src/reflect/scala/reflect/internal/TreeGen.scala
+++ b/src/reflect/scala/reflect/internal/TreeGen.scala
@@ -95,7 +95,7 @@ abstract class TreeGen extends macros.TreeBuilder {
case ConstantType(value) =>
Literal(value) setType tpe
- case AnnotatedType(_, atp, _) =>
+ case AnnotatedType(_, atp) =>
mkAttributedQualifier(atp)
case RefinedType(parents, _) =>
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala
index 99e6ae633f..a217ef128f 100644
--- a/src/reflect/scala/reflect/internal/Types.scala
+++ b/src/reflect/scala/reflect/internal/Types.scala
@@ -44,7 +44,7 @@ import TypeConstants._
// parent1 with ... with parentn { defs }
case ExistentialType(tparams, result) =>
// result forSome { tparams }
- case AnnotatedType(annots, tp, selfsym) =>
+ case AnnotatedType(annots, tp) =>
// tp @annots
// the following are non-value types; you cannot write them down in Scala source.
@@ -1191,13 +1191,6 @@ trait Types
def setAnnotations(annots: List[AnnotationInfo]): Type = annotatedType(annots, this)
def withAnnotations(annots: List[AnnotationInfo]): Type = annotatedType(annots, this)
- /** Set the self symbol of an annotated type, or do nothing
- * otherwise. */
- def withSelfsym(sym: Symbol) = this
-
- /** The selfsym of an annotated type, or NoSymbol of anything else */
- def selfsym: Symbol = NoSymbol
-
/** The kind of this type; used for debugging */
def kind: String = "unknown type of class "+getClass()
}
@@ -3235,13 +3228,9 @@ trait Types
*
* @param annotations the list of annotations on the type
* @param underlying the type without the annotation
- * @param selfsym a "self" symbol with type `underlying`;
- * only available if -Yself-in-annots is turned on. Can be `NoSymbol`
- * if it is not used.
*/
case class AnnotatedType(override val annotations: List[AnnotationInfo],
- override val underlying: Type,
- override val selfsym: Symbol)
+ override val underlying: Type)
extends RewrappingTypeProxy with AnnotatedTypeApi {
assert(!annotations.isEmpty, "" + underlying)
@@ -3274,9 +3263,6 @@ trait Types
*/
override def withoutAnnotations = underlying.withoutAnnotations
- /** Set the self symbol */
- override def withSelfsym(sym: Symbol) = copy(selfsym = sym)
-
/** Drop the annotations on the bounds, unless the low and high
* bounds are exactly tp.
*/
@@ -3291,7 +3277,7 @@ trait Types
formals, actuals), info.args, info.assocs).setPos(info.pos))
val underlying1 = underlying.instantiateTypeParams(formals, actuals)
if ((annotations1 eq annotations) && (underlying1 eq underlying)) this
- else AnnotatedType(annotations1, underlying1, selfsym)
+ else AnnotatedType(annotations1, underlying1)
}
/** Return the base type sequence of tp, dropping the annotations, unless the base type sequence of tp
@@ -3310,9 +3296,9 @@ trait Types
/** Creator for AnnotatedTypes. It returns the underlying type if annotations.isEmpty
* rather than walking into the assertion.
*/
- def annotatedType(annots: List[AnnotationInfo], underlying: Type, selfsym: Symbol = NoSymbol): Type =
+ def annotatedType(annots: List[AnnotationInfo], underlying: Type): Type =
if (annots.isEmpty) underlying
- else AnnotatedType(annots, underlying, selfsym)
+ else AnnotatedType(annots, underlying)
object AnnotatedType extends AnnotatedTypeExtractor
@@ -3565,7 +3551,7 @@ trait Types
case RefinedType(parents, decls) => RefinedType(parents map (appliedType(_, args)), decls) // @PP: Can this be right?
case TypeBounds(lo, hi) => TypeBounds(appliedType(lo, args), appliedType(hi, args)) // @PP: Can this be right?
case tv@TypeVar(_, _) => tv.applyArgs(args)
- case AnnotatedType(annots, underlying, self) => AnnotatedType(annots, appliedType(underlying, args), self)
+ case AnnotatedType(annots, underlying) => AnnotatedType(annots, appliedType(underlying, args))
case ErrorType | WildcardType => tycon
case _ => abort(debugString(tycon))
}
@@ -3670,7 +3656,7 @@ trait Types
class TypeUnwrapper(poly: Boolean, existential: Boolean, annotated: Boolean, nullary: Boolean) extends (Type => Type) {
def apply(tp: Type): Type = tp match {
- case AnnotatedType(_, underlying, _) if annotated => apply(underlying)
+ case AnnotatedType(_, underlying) if annotated => apply(underlying)
case ExistentialType(_, underlying) if existential => apply(underlying)
case PolyType(_, underlying) if poly => apply(underlying)
case NullaryMethodType(underlying) if nullary => apply(underlying)
@@ -3713,7 +3699,7 @@ trait Types
def transparentShallowTransform(container: Symbol, tp: Type)(f: Type => Type): Type = {
def loop(tp: Type): Type = tp match {
- case tp @ AnnotatedType(_, underlying, _) => tp.copy(underlying = loop(underlying))
+ case tp @ AnnotatedType(_, underlying) => tp.copy(underlying = loop(underlying))
case tp @ ExistentialType(_, underlying) => tp.copy(underlying = loop(underlying))
case tp @ PolyType(_, resultType) => tp.copy(resultType = loop(resultType))
case tp @ NullaryMethodType(resultType) => tp.copy(resultType = loop(resultType))
@@ -4074,7 +4060,7 @@ trait Types
private def isValueElseNonValue(tp: Type): Boolean = tp match {
case tp if isAlwaysValueType(tp) => true
case tp if isAlwaysNonValueType(tp) => false
- case AnnotatedType(_, underlying, _) => isValueElseNonValue(underlying)
+ case AnnotatedType(_, underlying) => isValueElseNonValue(underlying)
case SingleType(_, sym) => sym.isValue // excludes packages and statics
case TypeRef(_, _, _) if tp.isHigherKinded => false // excludes type constructors
case ThisType(sym) => !sym.isPackageClass // excludes packages
diff --git a/src/reflect/scala/reflect/internal/Variances.scala b/src/reflect/scala/reflect/internal/Variances.scala
index cd09e83cd3..a7cac5254c 100644
--- a/src/reflect/scala/reflect/internal/Variances.scala
+++ b/src/reflect/scala/reflect/internal/Variances.scala
@@ -84,7 +84,7 @@ trait Variances {
loop(base, Covariant)
}
def isUncheckedVariance(tp: Type) = tp match {
- case AnnotatedType(annots, _, _) => annots exists (_ matches definitions.uncheckedVarianceClass)
+ case AnnotatedType(annots, _) => annots exists (_ matches definitions.uncheckedVarianceClass)
case _ => false
}
@@ -202,7 +202,7 @@ trait Variances {
case MethodType(params, restpe) => inSyms(params).flip & inType(restpe)
case PolyType(tparams, restpe) => inSyms(tparams).flip & inType(restpe)
case ExistentialType(tparams, restpe) => inSyms(tparams) & inType(restpe)
- case AnnotatedType(annots, tp, _) => inTypes(annots map (_.atp)) & inType(tp)
+ case AnnotatedType(annots, tp) => inTypes(annots map (_.atp)) & inType(tp)
}
inType(tp)
diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
index 3d222fce10..2a19441476 100644
--- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
+++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
@@ -362,7 +362,7 @@ abstract class UnPickler {
case METHODtpe => MethodTypeRef(readTypeRef(), readSymbols())
case POLYtpe => PolyOrNullaryType(readTypeRef(), readSymbols())
case EXISTENTIALtpe => ExistentialType(underlying = readTypeRef(), quantified = readSymbols())
- case ANNOTATEDtpe => AnnotatedType(underlying = readTypeRef(), annotations = readAnnots(), selfsym = NoSymbol)
+ case ANNOTATEDtpe => AnnotatedType(underlying = readTypeRef(), annotations = readAnnots())
}
}
diff --git a/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala b/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala
index 6b33aca025..1c4d05ae32 100644
--- a/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala
+++ b/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala
@@ -316,7 +316,7 @@ private[internal] trait GlbLubs {
NullaryMethodType(lub0(matchingRestypes(ts, Nil)))
case ts @ TypeBounds(_, _) :: rest =>
TypeBounds(glb(ts map (_.bounds.lo), depth), lub(ts map (_.bounds.hi), depth))
- case ts @ AnnotatedType(annots, tpe, _) :: rest =>
+ case ts @ AnnotatedType(annots, tpe) :: rest =>
annotationsLub(lub0(ts map (_.withoutAnnotations)), ts)
case ts =>
lubResults get ((depth, ts)) match {
diff --git a/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala b/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala
index b60fecd66e..0c04f4a1e0 100644
--- a/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala
+++ b/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala
@@ -403,14 +403,14 @@ trait TypeComparers {
case _ =>
secondTry
}
- case AnnotatedType(_, _, _) =>
+ case AnnotatedType(_, _) =>
isSubType(tp1.withoutAnnotations, tp2.withoutAnnotations, depth) &&
annotationsConform(tp1, tp2)
case BoundedWildcardType(bounds) =>
isSubType(tp1, bounds.hi, depth)
case tv2 @ TypeVar(_, constr2) =>
tp1 match {
- case AnnotatedType(_, _, _) | BoundedWildcardType(_) =>
+ case AnnotatedType(_, _) | BoundedWildcardType(_) =>
secondTry
case _ =>
tv2.registerBound(tp1, isLowerBound = true)
@@ -425,7 +425,7 @@ trait TypeComparers {
* - handle existential types by skolemization.
*/
def secondTry = tp1 match {
- case AnnotatedType(_, _, _) =>
+ case AnnotatedType(_, _) =>
isSubType(tp1.withoutAnnotations, tp2.withoutAnnotations, depth) &&
annotationsConform(tp1, tp2)
case BoundedWildcardType(bounds) =>
diff --git a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
index f5aa048e6a..09f4389b82 100644
--- a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
+++ b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
@@ -48,7 +48,7 @@ private[internal] trait TypeMaps {
case TypeRef(_, sym, _) if sym.isAliasType => apply(tp.dealias)
case TypeRef(_, sym, _) if sym.isAbstractType => apply(tp.bounds.hi)
case rtp @ RefinedType(parents, decls) => copyRefinedType(rtp, parents mapConserve this, decls)
- case AnnotatedType(_, _, _) => mapOver(tp)
+ case AnnotatedType(_, _) => mapOver(tp)
case _ => tp // no recursion - top level only
}
}
@@ -174,12 +174,12 @@ private[internal] trait TypeMaps {
case tv@TypeVar(_, constr) =>
if (constr.instValid) this(constr.inst)
else tv.applyArgs(mapOverArgs(tv.typeArgs, tv.params)) //@M !args.isEmpty implies !typeParams.isEmpty
- case AnnotatedType(annots, atp, selfsym) =>
+ case AnnotatedType(annots, atp) =>
val annots1 = mapOverAnnotations(annots)
val atp1 = this(atp)
if ((annots1 eq annots) && (atp1 eq atp)) tp
else if (annots1.isEmpty) atp1
- else AnnotatedType(annots1, atp1, selfsym)
+ else AnnotatedType(annots1, atp1)
/*
case ErrorType => tp
case WildcardType => tp
@@ -1142,7 +1142,7 @@ private[internal] trait TypeMaps {
case SuperType(_, _) => mapOver(tp)
case TypeBounds(_, _) => mapOver(tp)
case TypeVar(_, _) => mapOver(tp)
- case AnnotatedType(_,_,_) => mapOver(tp)
+ case AnnotatedType(_, _) => mapOver(tp)
case ExistentialType(_, _) => mapOver(tp)
case _ => tp
}
diff --git a/src/reflect/scala/reflect/internal/transform/Erasure.scala b/src/reflect/scala/reflect/internal/transform/Erasure.scala
index addc7eb389..786ff2210c 100644
--- a/src/reflect/scala/reflect/internal/transform/Erasure.scala
+++ b/src/reflect/scala/reflect/internal/transform/Erasure.scala
@@ -144,7 +144,7 @@ trait Erasure {
else apply(mt.resultType(mt.paramTypes)))
case RefinedType(parents, decls) =>
apply(mergeParents(parents))
- case AnnotatedType(_, atp, _) =>
+ case AnnotatedType(_, atp) =>
apply(atp)
case ClassInfoType(parents, decls, clazz) =>
ClassInfoType(