@@ -99,6 +99,11 @@ trait MacroCommons { bundle =>
9999 def indent (str : String , indent : String ): String =
100100 str.replaceAllLiterally(" \n " , s " \n $indent" )
101101
102+ private def annotations (s : Symbol ): List [Annotation ] = {
103+ s.info // srsly scalac, load these goddamned annotations
104+ s.annotations
105+ }
106+
102107 def treeAsSeenFrom (tree : Tree , seenFrom : Type ): Tree = seenFrom match {
103108 case NoType => tree
104109 case TypeRef (_, sym, Nil ) if sym.isStatic => tree
@@ -191,7 +196,7 @@ trait MacroCommons { bundle =>
191196 lazy val aggregated : List [Annot ] = {
192197 if (tpe <:< AnnotationAggregateType ) {
193198 val impliedMember = tpe.member(TypeName (" Implied" ))
194- impliedMember. annotations.map { a =>
199+ annotations(impliedMember) .map { a =>
195200 new Annot (argsInliner.transform(treeAsSeenFrom(a.tree, tpe)), subject, impliedMember, Some (this ))
196201 }
197202 } else Nil
@@ -226,7 +231,7 @@ trait MacroCommons { bundle =>
226231 ! (superSym != initSym && isSealedHierarchyRoot(superSym) && annot.tree.tpe <:< NotInheritedFromSealedTypes )
227232
228233 val nonFallback = maybeWithSuperSymbols(initSym, withInherited)
229- .flatMap(ss => ss. annotations.filter(inherited(_, ss))
234+ .flatMap(ss => annotations(ss) .filter(inherited(_, ss))
230235 .map(a => new Annot (treeAsSeenFrom(a.tree, seenFrom), s, ss, None )))
231236
232237 (nonFallback ++ fallback.iterator.map(t => new Annot (t, s, s, None )))
@@ -258,7 +263,7 @@ trait MacroCommons { bundle =>
258263 ! (superSym != initSym && isSealedHierarchyRoot(superSym) && annot.tree.tpe <:< NotInheritedFromSealedTypes )
259264
260265 maybeWithSuperSymbols(initSym, withInherited)
261- .map(ss => find(ss. annotations.filter(inherited(_, ss))
266+ .map(ss => find(annotations(ss) .filter(inherited(_, ss))
262267 .map(a => new Annot (treeAsSeenFrom(a.tree, seenFrom), s, ss, None ))))
263268 .collectFirst { case Some (annot) => annot }
264269 .orElse(find(fallback.map(t => new Annot (t, s, s, None ))))
@@ -407,7 +412,7 @@ trait MacroCommons { bundle =>
407412 symbolImplicitNotFoundMsg(tpe, tpe.typeSymbol, tpe.typeSymbol.typeSignature.typeParams, tpe.typeArgs)
408413
409414 private def symbolImplicitNotFoundMsg (tpe : Type , sym : Symbol , tparams : List [Symbol ], typeArgs : List [Type ]): String =
410- sym. annotations.find(_.tree.tpe <:< ImplicitNotFoundAT )
415+ annotations(sym) .find(_.tree.tpe <:< ImplicitNotFoundAT )
411416 .map(_.tree.children.tail.head).collect { case StringLiteral (error) => error }
412417 .map { error =>
413418 val tpNames = tparams.map(_.name.decodedName.toString)
@@ -773,19 +778,19 @@ trait MacroCommons { bundle =>
773778 def paramSymbolToValDef (sym : Symbol ): ValDef = {
774779 val ts = sym.asTerm
775780 val implicitFlag = if (sym.isImplicit) Flag .IMPLICIT else NoFlags
776- val mods = Modifiers (Flag .PARAM | implicitFlag, typeNames.EMPTY , ts. annotations.map(_.tree))
781+ val mods = Modifiers (Flag .PARAM | implicitFlag, typeNames.EMPTY , annotations(ts) .map(_.tree))
777782 ValDef (mods, ts.name, treeForType(sym.typeSignature), EmptyTree )
778783 }
779784
780785 def getterSymbolToValDef (sym : Symbol ): ValDef = {
781786 val ms = sym.asMethod
782787 val mutableFlag = if (ms.isVar) Flag .MUTABLE else NoFlags
783- val mods = Modifiers (Flag .DEFERRED | mutableFlag, typeNames.EMPTY , ms. annotations.map(_.tree))
788+ val mods = Modifiers (Flag .DEFERRED | mutableFlag, typeNames.EMPTY , annotations(ms) .map(_.tree))
784789 ValDef (mods, ms.name, treeForType(sym.typeSignature), EmptyTree )
785790 }
786791
787792 def existentialSingletonToValDef (sym : Symbol , name : TermName , tpe : Type ): ValDef = {
788- val mods = Modifiers (Flag .DEFERRED , typeNames.EMPTY , sym. annotations.map(_.tree))
793+ val mods = Modifiers (Flag .DEFERRED , typeNames.EMPTY , annotations(sym) .map(_.tree))
789794 ValDef (mods, name, treeForType(tpe), EmptyTree )
790795 }
791796
@@ -804,7 +809,7 @@ trait MacroCommons { bundle =>
804809 else NoFlags
805810
806811 val flags = paramOrDeferredFlag | syntheticFlag | varianceFlag
807- val mods = Modifiers (flags, typeNames.EMPTY , ts. annotations.map(_.tree))
812+ val mods = Modifiers (flags, typeNames.EMPTY , annotations(ts) .map(_.tree))
808813 val (typeParams, signature) = sym.typeSignature match {
809814 case PolyType (polyParams, resultType) => (polyParams, resultType)
810815 case sig => (ts.typeParams, sig)
@@ -1038,7 +1043,7 @@ trait MacroCommons { bundle =>
10381043 def positionPoint (sym : Symbol ): Int =
10391044 if (c.enclosingPosition.source == sym.pos.source) sym.pos.point
10401045 else positionCache.getOrElseUpdate(sym,
1041- sym. annotations.find(_.tree.tpe <:< PositionedAT ).map(_.tree).map {
1046+ annotations(sym) .find(_.tree.tpe <:< PositionedAT ).map(_.tree).map {
10421047 case Apply (_, List (MaybeTyped (Lit (point : Int ), _))) => point
10431048 case t => abort(s " expected literal int as argument of @positioned annotation on $sym, got $t" )
10441049 } getOrElse {
0 commit comments