diff options
-rw-r--r-- | src/dotty/tools/dotc/core/Annotations.scala | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/Annotations.scala b/src/dotty/tools/dotc/core/Annotations.scala index 1bd6fc31f..fae8082bd 100644 --- a/src/dotty/tools/dotc/core/Annotations.scala +++ b/src/dotty/tools/dotc/core/Annotations.scala @@ -1,6 +1,6 @@ package dotty.tools.dotc.core -import Symbols._, Trees._, Types._, Positions._, Contexts._ +import Symbols._, Trees._, Types._, Positions._, Contexts._, Constants._ object Annotations { @@ -15,14 +15,37 @@ object Annotations { object Annotation { + def apply(cls: ClassSymbol, arg: TypedTree)(implicit ctx: Context): Annotation = + apply(cls, arg :: Nil) + + def apply(cls: ClassSymbol, arg1: TypedTree, arg2: TypedTree)(implicit ctx: Context): Annotation = + apply(cls, arg1 :: arg2 :: Nil) + def apply(cls: ClassSymbol, args: List[TypedTree])(implicit ctx: Context): Annotation = - ConcreteAnnotation(makeTypedTree.New(cls.typeConstructor, args)) + apply(cls.typeConstructor, args) - def makeAlias(sym: TermSymbol)(implicit ctx: Context) = - apply(defn.AliasAnnot, List(makeTypedTree.Ident(TermRef(sym.owner.thisType, sym)))) + def apply(atp: Type, arg: TypedTree)(implicit ctx: Context): Annotation = + apply(atp, arg :: Nil) + + def apply(atp: Type, arg1: TypedTree, arg2: TypedTree)(implicit ctx: Context): Annotation = + apply(atp, arg1 :: arg2 :: Nil) + + def apply(atp: Type, args: List[TypedTree])(implicit ctx: Context): Annotation = + ConcreteAnnotation(makeTypedTree.New(atp, args)) - def makeChild(sym: ClassSymbol)(implicit ctx: Context) = - apply(defn.ChildAnnot, List(makeTypedTree.Ident(TypeRef(sym.owner.thisType, sym)))) + def makeAlias(sym: TermSymbol)(implicit ctx: Context) = + apply(defn.AliasAnnot, List(makeTypedTree.Ident(TermRef(sym.owner.thisType, sym.name, sym.signature)))) + def makeChild(sym: Symbol)(implicit ctx: Context) = + apply(defn.ChildAnnot, List(makeTypedTree.Ident(NamedType(sym.owner.thisType, sym.name)))) } + + def makeLiteralAnnotArg(const: Constant): TypedTree = ??? + + def makeArrayAnnotArg(elems: Array[TypedTree]): TypedTree = ??? + + def makeNestedAnnotArg(annot: Annotation): TypedTree = annot.tree + + def ThrowsAnnotation(cls: ClassSymbol)(implicit ctx: Context) = + Annotation(defn.ThrowsAnnot, makeTypedTree.Ident(TypeRef(cls.owner.thisType, cls.name))) }
\ No newline at end of file |