diff options
author | Martin Odersky <odersky@gmail.com> | 2013-02-11 14:53:24 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-02-11 14:53:24 +0100 |
commit | 48076bb9c287d82a1259885dccfa424df16fe912 (patch) | |
tree | 34e0d3b9dd3e3ab1d8e083da5ad48ae2db860b10 /src/dotty/tools/dotc/core/Annotations.scala | |
parent | 952d4a29c3e55d44defa70ab15f0137a51320de2 (diff) | |
download | dotty-48076bb9c287d82a1259885dccfa424df16fe912.tar.gz dotty-48076bb9c287d82a1259885dccfa424df16fe912.tar.bz2 dotty-48076bb9c287d82a1259885dccfa424df16fe912.zip |
Treating all annotations as wrappers over trees.
Diffstat (limited to 'src/dotty/tools/dotc/core/Annotations.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Annotations.scala | 20 |
1 files changed, 12 insertions, 8 deletions
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 |