From 48076bb9c287d82a1259885dccfa424df16fe912 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 11 Feb 2013 14:53:24 +0100 Subject: Treating all annotations as wrappers over trees. --- src/dotty/tools/dotc/core/Annotations.scala | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/dotty/tools/dotc/core/Annotations.scala') diff --git a/src/dotty/tools/dotc/core/Annotations.scala b/src/dotty/tools/dotc/core/Annotations.scala index 8aead084d..1bd6fc31f 100644 --- a/src/dotty/tools/dotc/core/Annotations.scala +++ b/src/dotty/tools/dotc/core/Annotations.scala @@ -1,24 +1,28 @@ package dotty.tools.dotc.core -import Symbols._ +import Symbols._, Trees._, Types._, Positions._, Contexts._ object Annotations { abstract class Annotation { - def matches(cls: Symbol) = ??? + def tree: TypedTree + def symbol(implicit ctx: Context): Symbol = tree.tpe.typeSymbol + def matches(cls: Symbol)(implicit ctx: Context): Boolean = symbol.isNonBottomSubClass(cls) def appliesToModule: Boolean = ??? } - abstract class InternalAnnotation extends Annotation { + case class ConcreteAnnotation(val tree: TypedTree) extends Annotation - } + object Annotation { - case class Alias(sym: Symbol) extends InternalAnnotation { + def apply(cls: ClassSymbol, args: List[TypedTree])(implicit ctx: Context): Annotation = + ConcreteAnnotation(makeTypedTree.New(cls.typeConstructor, args)) - } + def makeAlias(sym: TermSymbol)(implicit ctx: Context) = + apply(defn.AliasAnnot, List(makeTypedTree.Ident(TermRef(sym.owner.thisType, sym)))) - case class Child(child: ClassSymbol) extends InternalAnnotation { + def makeChild(sym: ClassSymbol)(implicit ctx: Context) = + apply(defn.ChildAnnot, List(makeTypedTree.Ident(TypeRef(sym.owner.thisType, sym)))) } - } \ No newline at end of file -- cgit v1.2.3