summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenTypes.scala6
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/settings/ScalaSettings.scala1
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala5
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala4
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala62
-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
-rw-r--r--test/files/run/constrained-types.check10
-rw-r--r--test/files/run/constrained-types.scala6
27 files changed, 55 insertions, 138 deletions
diff --git a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala
index 99b968be3b..a90a3a338b 100644
--- a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala
+++ b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala
@@ -60,7 +60,7 @@ trait GenTypes {
reifyProduct(tpe)
case tpe @ NullaryMethodType(restpe) =>
reifyProduct(tpe)
- case tpe @ AnnotatedType(anns, underlying, selfsym) =>
+ case tpe @ AnnotatedType(anns, underlying) =>
reifyAnnotatedType(tpe)
case _ =>
reifyToughType(tpe)
@@ -162,8 +162,8 @@ trait GenTypes {
/** Reify an annotated type, i.e. the one that makes us deal with AnnotationInfos */
private def reifyAnnotatedType(tpe: AnnotatedType): Tree = {
- val AnnotatedType(anns, underlying, selfsym) = tpe
- mirrorFactoryCall(nme.AnnotatedType, mkList(anns map reifyAnnotationInfo), reify(underlying), reify(selfsym))
+ val AnnotatedType(anns, underlying) = tpe
+ mirrorFactoryCall(nme.AnnotatedType, mkList(anns map reifyAnnotationInfo), reify(underlying))
}
/** Reify a tough type, i.e. the one that leads to creation of auxiliary symbols */
diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
index c68b248240..429832f22c 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
@@ -619,7 +619,7 @@ abstract class TreeBrowsers {
toDocument(result) :: ")")
)
- case AnnotatedType(annots, tp, _) =>
+ case AnnotatedType(annots, tp) =>
Document.group(
Document.nest(4, "AnnotatedType(" :/:
annots.mkString("[", ",", "]") :/:
diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
index 633e71a756..a6d0d3b9fa 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
@@ -393,7 +393,7 @@ trait TypeKinds { self: ICodes =>
// if the first two cases exist because they do or as a defensive measure, but
// at the time I added it, RefinedTypes were indeed reaching here.
case ExistentialType(_, t) => toTypeKind(t)
- case AnnotatedType(_, t, _) => toTypeKind(t)
+ case AnnotatedType(_, t) => toTypeKind(t)
case RefinedType(parents, _) => parents map toTypeKind reduceLeft lub
// For sure WildcardTypes shouldn't reach here either, but when
// debugging such situations this may come in handy.
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
index 64ed094a47..23b9198c7b 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
@@ -518,7 +518,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
// !!! Iulian says types which make no sense after erasure should not reach here, which includes the ExistentialType, AnnotatedType, RefinedType.
case ExistentialType(_, t) => toTypeKind(t) // TODO shouldn't get here but the following does: akka-actor/src/main/scala/akka/util/WildcardTree.scala
- case AnnotatedType(_, w, _) => toTypeKind(w) // TODO test/files/jvm/annotations.scala causes an AnnotatedType to reach here.
+ case AnnotatedType(_, w) => toTypeKind(w) // TODO test/files/jvm/annotations.scala causes an AnnotatedType to reach here.
case RefinedType(parents, _) => parents map toTypeKind reduceLeft jvmWiseLUB
// For sure WildcardTypes shouldn't reach here either, but when debugging such situations this may come in handy.
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
index 1f9987c83b..5f4c4a43b3 100644
--- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
@@ -154,7 +154,6 @@ trait ScalaSettings extends AbsScalaSettings
val nopredef = BooleanSetting ("-Yno-predef", "Compile without importing Predef.")
val noAdaptedArgs = BooleanSetting ("-Yno-adapted-args", "Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver.")
val Yrecursion = IntSetting ("-Yrecursion", "Set recursion depth used when locking symbols.", 0, Some((0, Int.MaxValue)), (_: String) => None)
- val selfInAnnots = BooleanSetting ("-Yself-in-annots", "Include a \"self\" identifier inside of annotations.")
val Xshowtrees = BooleanSetting ("-Yshow-trees", "(Requires -Xprint:) Print detailed ASTs in formatted form.")
val XshowtreesCompact
= BooleanSetting ("-Yshow-trees-compact", "(Requires -Xprint:) Print detailed ASTs in compact form.")
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
index ce3e7b1bb5..90c15bca61 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
@@ -238,9 +238,8 @@ abstract class Pickler extends SubComponent {
case ExistentialType(tparams, restpe) =>
putType(restpe)
putSymbols(tparams)
- case AnnotatedType(_, underlying, selfsym) =>
+ case AnnotatedType(_, underlying) =>
putType(underlying)
- if (settings.selfInAnnots) putSymbol(selfsym)
tp.staticAnnotations foreach putAnnotation
case _ =>
throw new FatalError("bad type: " + tp + "(" + tp.getClass + ")")
@@ -450,7 +449,7 @@ abstract class Pickler extends SubComponent {
case PolyType(tparams, restpe) => writeRef(restpe); writeRefs(tparams)
case ExistentialType(tparams, restpe) => writeRef(restpe); writeRefs(tparams)
case StaticallyAnnotatedType(annots, tp) => writeRef(tp) ; writeRefs(annots)
- case AnnotatedType(_, tp, _) => writeTypeBody(tp) // write the underlying type if there are no static annotations
+ case AnnotatedType(_, tp) => writeTypeBody(tp) // write the underlying type if there are no static annotations
case CompoundType(parents, _, clazz) => writeRef(clazz); writeRefs(parents)
}
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index 6732900ef2..4bbfc945f6 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -61,7 +61,7 @@ abstract class Erasure extends AddInterfaces
parents foreach traverse
case ClassInfoType(parents, _, _) =>
parents foreach traverse
- case AnnotatedType(_, atp, _) =>
+ case AnnotatedType(_, atp) =>
traverse(atp)
case _ =>
mapOver(tp)
@@ -302,7 +302,7 @@ abstract class Erasure extends AddInterfaces
boxedSig(parent)
case ClassInfoType(parents, _, _) =>
superSig(parents)
- case AnnotatedType(_, atp, _) =>
+ case AnnotatedType(_, atp) =>
jsig(atp, existentiallyBound, toplevel, primitiveOK)
case BoundedWildcardType(bounds) =>
println("something's wrong: "+sym0+":"+sym0.tpe+" has a bounded wildcard type")
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index c505d9dc5f..3791af1629 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -438,7 +438,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
case NullaryMethodType(resTpe) => specializedTypeVars(resTpe)
case MethodType(argSyms, resTpe) => specializedTypeVars(resTpe :: argSyms.map(_.tpe))
case ExistentialType(_, res) => specializedTypeVars(res)
- case AnnotatedType(_, tp, _) => specializedTypeVars(tp)
+ case AnnotatedType(_, tp) => specializedTypeVars(tp)
case TypeBounds(lo, hi) => specializedTypeVars(lo :: hi :: Nil)
case RefinedType(parents, _) => parents flatMap specializedTypeVars toSet
case _ => immutable.Set.empty
@@ -1098,7 +1098,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
case (ThisType(_), _) => unify(tp1.widen, tp2, env, strict)
case (_, ThisType(_)) => unify(tp1, tp2.widen, env, strict)
case (RefinedType(_, _), RefinedType(_, _)) => env
- case (AnnotatedType(_, tp1, _), tp2) => unify(tp2, tp1, env, strict)
+ case (AnnotatedType(_, tp1), tp2) => unify(tp2, tp1, env, strict)
case (ExistentialType(_, res1), _) => unify(tp2, res1, env, strict)
case (TypeBounds(lo1, hi1), TypeBounds(lo2, hi2)) => unify(List(lo1, hi1), List(lo2, hi2), env, strict)
case _ =>
diff --git a/src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala b/src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala
index 73572bcae9..1f1ccbe359 100644
--- a/src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala
@@ -180,7 +180,7 @@ trait DestructureTypes {
case SuperType(thistp, supertp) => product(tp, this("this", thistp), this("super", supertp))
case ThisType(clazz) => product(tp, wrapAtom(clazz))
case TypeVar(inst, constr) => product(tp, this("inst", inst), typeConstraint(constr))
- case AnnotatedType(annotations, underlying, _) => annotatedType(annotations, underlying)
+ case AnnotatedType(annotations, underlying) => annotatedType(annotations, underlying)
case ExistentialType(tparams, underlying) => polyFunction(tparams, underlying)
case PolyType(tparams, restpe) => polyFunction(tparams, restpe)
case MethodType(params, restpe) => monoFunction(params, restpe)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index fdec1edcc0..1916a18ea1 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -389,7 +389,7 @@ trait Implicits {
private def dominates(dtor: Type, dted: Type): Boolean = {
def core(tp: Type): Type = tp.dealiasWiden match {
case RefinedType(parents, defs) => intersectionType(parents map core, tp.typeSymbol.owner)
- case AnnotatedType(annots, tp, selfsym) => core(tp)
+ case AnnotatedType(annots, tp) => core(tp)
case ExistentialType(tparams, result) => core(result).subst(tparams, tparams map (t => core(t.info.bounds.hi)))
case PolyType(tparams, result) => core(result).subst(tparams, tparams map (t => core(t.info.bounds.hi)))
case _ => tp
@@ -1060,7 +1060,7 @@ trait Implicits {
getParts(restpe)
case RefinedType(ps, _) =>
for (p <- ps) getParts(p)
- case AnnotatedType(_, t, _) =>
+ case AnnotatedType(_, t) =>
getParts(t)
case ExistentialType(_, t) =>
getParts(t)
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 95f2620061..330dc0434b 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -1431,7 +1431,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
private def checkTypeRefBounds(tp: Type, tree: Tree) = {
var skipBounds = false
tp match {
- case AnnotatedType(ann :: Nil, underlying, selfSym) if ann.symbol == UncheckedBoundsClass =>
+ case AnnotatedType(ann :: Nil, underlying) if ann.symbol == UncheckedBoundsClass =>
skipBounds = true
underlying
case TypeRef(pre, sym, args) =>
@@ -1474,7 +1474,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
}
doTypeTraversal(tree) {
- case tp @ AnnotatedType(annots, _, _) =>
+ case tp @ AnnotatedType(annots, _) =>
applyChecks(annots)
case tp =>
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
index b706e1af6b..06796eca8e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
@@ -542,7 +542,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
case TypeRef(pre, _, _) => isThisType(pre)
case SingleType(pre, _) => isThisType(pre)
case RefinedType(parents, _) => parents exists isThisType
- case AnnotatedType(_, tp, _) => isThisType(tp)
+ case AnnotatedType(_, tp) => isThisType(tp)
case _ => false
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 6b5afce993..c8e634eb4c 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1122,7 +1122,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
if (treeInfo.isMacroApplication(tree)) adapt(unmarkMacroImplRef(tree), mode, pt, original)
else tree
} else tree.tpe match {
- case atp @ AnnotatedType(_, _, _) if canAdaptAnnotations(tree, this, mode, pt) => // (-1)
+ case atp @ AnnotatedType(_, _) if canAdaptAnnotations(tree, this, mode, pt) => // (-1)
adaptAnnotations(tree, this, mode, pt)
case ct @ ConstantType(value) if mode.inNone(TYPEmode | FUNmode) && (ct <:< pt) && canAdaptConstantTypeToLiteral => // (0)
adaptConstant(value)
@@ -3470,7 +3470,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
/**
* Convert an annotation constructor call into an AnnotationInfo.
*/
- def typedAnnotation(ann: Tree, mode: Mode = EXPRmode, selfsym: Symbol = NoSymbol): AnnotationInfo = {
+ def typedAnnotation(ann: Tree, mode: Mode = EXPRmode): AnnotationInfo = {
var hasError: Boolean = false
val pending = ListBuffer[AbsTypeError]()
@@ -3519,7 +3519,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
reportAnnotationError(ArrayConstantsError(tree)); None
case ann @ Apply(Select(New(tpt), nme.CONSTRUCTOR), args) =>
- val annInfo = typedAnnotation(ann, mode, NoSymbol)
+ val annInfo = typedAnnotation(ann, mode)
val annType = annInfo.tpe
if (!annType.typeSymbol.isSubClass(pt.typeSymbol))
@@ -3631,28 +3631,11 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
}
}
else {
- val typedAnn = if (selfsym == NoSymbol) {
+ val typedAnn: Tree = {
// local dummy fixes SI-5544
val localTyper = newTyper(context.make(ann, context.owner.newLocalDummy(ann.pos)))
localTyper.typed(ann, mode, annType)
}
- else {
- // Since a selfsym is supplied, the annotation should have an extra
- // "self" identifier in scope for type checking. This is implemented
- // by wrapping the rhs in a function like "self => rhs" during type
- // checking, and then stripping the "self =>" and substituting in
- // the supplied selfsym.
- val funcparm = ValDef(NoMods, nme.self, TypeTree(selfsym.info), EmptyTree)
- // The .duplicate of annot.constr deals with problems that accur
- // if this annotation is later typed again, which the compiler
- // sometimes does. The problem is that "self" ident's within
- // annot.constr will retain the old symbol from the previous typing.
- val func = Function(funcparm :: Nil, ann.duplicate)
- val funcType = appliedType(FunctionClass(1), selfsym.info, annType)
- val Function(arg :: Nil, rhs) = typed(func, mode, funcType)
-
- rhs.substituteSymbols(arg.symbol :: Nil, selfsym :: Nil)
- }
def annInfo(t: Tree): AnnotationInfo = t match {
case Apply(Select(New(tpt), nme.CONSTRUCTOR), args) =>
AnnotationInfo(annType, args, List()).setOriginal(typedAnn).setPos(t.pos)
@@ -3770,7 +3753,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
t match {
case ExistentialType(tparams, _) =>
boundSyms ++= tparams
- case AnnotatedType(annots, _, _) =>
+ case AnnotatedType(annots, _) =>
for (annot <- annots; arg <- annot.args) {
arg match {
case Ident(_) =>
@@ -4035,39 +4018,8 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
if (arg1.isType) {
// make sure the annotation is only typechecked once
if (ann.tpe == null) {
- // an annotated type
- val selfsym =
- if (!settings.selfInAnnots)
- NoSymbol
- else
- arg1.tpe.selfsym orElse {
- /* Implementation limitation: Currently this
- * can cause cyclical reference errors even
- * when the self symbol is not referenced at all.
- * Surely at least some of these cases can be
- * fixed by proper use of LazyType's. Lex tinkered
- * on this but did not succeed, so is leaving
- * it alone for now. Example code with the problem:
- * class peer extends Annotation
- * class NPE[T <: NPE[T] @peer]
- *
- * (Note: -Yself-in-annots must be on to see the problem)
- * */
- ( context.owner
- newLocalDummy (ann.pos)
- newValue (nme.self, ann.pos)
- setInfo (arg1.tpe.withoutAnnotations)
- )
- }
-
- val ainfo = typedAnnotation(ann, annotMode, selfsym)
- val atype0 = arg1.tpe.withAnnotation(ainfo)
- val atype =
- if ((selfsym != NoSymbol) && (ainfo.refsSymbol(selfsym)))
- atype0.withSelfsym(selfsym)
- else
- atype0 // do not record selfsym if
- // this annotation did not need it
+ val ainfo = typedAnnotation(ann, annotMode)
+ val atype = arg1.tpe.withAnnotation(ainfo)
if (ainfo.isErroneous)
// Erroneous annotations were already reported in typedAnnotation
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(
diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check
index d965d8a2ff..9a106785a1 100644
--- a/test/files/run/constrained-types.check
+++ b/test/files/run/constrained-types.check
@@ -149,13 +149,3 @@ scala> val x = 3 : Int @Annot(e+f+g+h) // should have a graceful error message
^
scala>
-
-scala> class Where(condition: Boolean) extends annotation.Annotation
-defined class Where
-
-scala>
-
-scala> val x : Int @Where(self > 0 && self < 100) = 3
-x: Int @Where(self.>(0).&&(self.<(100))) = 3
-
-scala>
diff --git a/test/files/run/constrained-types.scala b/test/files/run/constrained-types.scala
index 91bd856d00..7ec8f93d38 100644
--- a/test/files/run/constrained-types.scala
+++ b/test/files/run/constrained-types.scala
@@ -72,16 +72,10 @@ object A { val x = "hello" : String @ rep }
val y = a.x // should drop the annotation
val x = 3 : Int @Annot(e+f+g+h) // should have a graceful error message
-
-class Where(condition: Boolean) extends annotation.Annotation
-
-val x : Int @Where(self > 0 && self < 100) = 3
-
"""
override def transformSettings(s: Settings): Settings = {
s.Xexperimental.value = true
- s.selfInAnnots.value = true
s.deprecation.value = true
// when running that compiler, give it a scala-library to the classpath
s.classpath.value = sys.props("java.class.path")