@@ -178,14 +178,14 @@ object Macro:
178178
179179 private val tpe : TypeRepr = TypeRepr .of[T ]
180180
181- def anns : Expr [List [Any ]] =
181+ def anns : Expr [List [scala.annotation. Annotation ]] =
182182 Expr .ofList {
183183 tpe.typeSymbol.annotations
184184 .filter(filterAnnotation)
185- .map(_.asExpr.asInstanceOf [Expr [Any ]])
185+ .map(_.asExpr.asInstanceOf [Expr [scala.annotation. Annotation ]])
186186 }
187187
188- def inheritedAnns : Expr [List [Any ]] =
188+ def inheritedAnns : Expr [List [scala.annotation. Annotation ]] =
189189 Expr .ofList {
190190 tpe.baseClasses
191191 .filterNot(isObjectOrScala)
@@ -194,10 +194,10 @@ object Macro:
194194 } // skip self
195195 .flatten
196196 .filter(filterAnnotation)
197- .map(_.asExpr.asInstanceOf [Expr [Any ]])
197+ .map(_.asExpr.asInstanceOf [Expr [scala.annotation. Annotation ]])
198198 }
199199
200- def typeAnns : Expr [List [Any ]] = {
200+ def typeAnns : Expr [List [scala.annotation. Annotation ]] = {
201201
202202 def getAnnotations (t : TypeRepr ): List [Term ] = t match
203203 case AnnotatedType (inner, ann) => ann :: getAnnotations(inner)
@@ -212,28 +212,28 @@ object Macro:
212212 .collect { case t : TypeTree => t.tpe }
213213 .flatMap(getAnnotations)
214214 .filter(filterAnnotation)
215- .map(_.asExpr.asInstanceOf [Expr [Any ]])
215+ .map(_.asExpr.asInstanceOf [Expr [scala.annotation. Annotation ]])
216216 case _ =>
217217 // Best effort in case whe -Yretain-trees is not used
218218 // Does not support class parent annotations (in the extends clouse)
219219 tpe.baseClasses
220220 .map(tpe.baseType(_))
221221 .flatMap(getAnnotations(_))
222222 .filter(filterAnnotation)
223- .map(_.asExpr )
223+ .map(_.asExprOf[scala.annotation. Annotation ] )
224224 }
225225 }
226226 }
227227
228- def paramAnns : Expr [List [(String , List [Any ])]] =
228+ def paramAnns : Expr [List [(String , List [scala.annotation. Annotation ])]] =
229229 Expr .ofList {
230230 groupByParamName {
231231 (fromConstructor(tpe.typeSymbol) ++ fromDeclarations(tpe.typeSymbol))
232232 .filter { case (_, anns) => anns.nonEmpty }
233233 }
234234 }
235235
236- def inheritedParamAnns : Expr [List [(String , List [Any ])]] =
236+ def inheritedParamAnns : Expr [List [(String , List [scala.annotation. Annotation ])]] =
237237 Expr .ofList {
238238 groupByParamName {
239239 tpe.baseClasses
@@ -248,25 +248,25 @@ object Macro:
248248 }
249249 }
250250
251- private def fromConstructor (from : Symbol ): List [(String , List [Expr [Any ]])] =
251+ private def fromConstructor (from : Symbol ): List [(String , List [Expr [scala.annotation. Annotation ]])] =
252252 from.primaryConstructor.paramSymss.flatten.map { field =>
253253 field.name -> field.annotations
254254 .filter(filterAnnotation)
255- .map(_.asExpr.asInstanceOf [Expr [Any ]])
255+ .map(_.asExpr.asInstanceOf [Expr [scala.annotation. Annotation ]])
256256 }
257257
258258 private def fromDeclarations (
259259 from : Symbol ,
260260 inherited : Boolean = false
261- ): List [(String , List [Expr [Any ]])] =
261+ ): List [(String , List [Expr [scala.annotation. Annotation ]])] =
262262 from.fieldMembers.collect { case field : Symbol =>
263263 val annotations = if (! inherited) field.annotations else field.allOverriddenSymbols.flatMap(_.annotations).toList
264264 field.name -> annotations
265265 .filter(filterAnnotation)
266- .map(_.asExpr.asInstanceOf [Expr [Any ]])
266+ .map(_.asExpr.asInstanceOf [Expr [scala.annotation. Annotation ]])
267267 }
268268
269- private def groupByParamName (anns : List [(String , List [Expr [Any ]])]) =
269+ private def groupByParamName (anns : List [(String , List [Expr [scala.annotation. Annotation ]])]) =
270270 anns
271271 .groupBy { case (name, _) => name }
272272 .toList
@@ -277,7 +277,8 @@ object Macro:
277277 bc.name.contains(" java.lang.Object" ) || bc.fullName.startsWith(" scala." )
278278
279279 private def filterAnnotation (a : Term ): Boolean =
280- a.tpe.typeSymbol.maybeOwner.isNoSymbol ||
281- (a.tpe.typeSymbol.owner.fullName != " scala.annotation.internal" &&
282- a.tpe.typeSymbol.owner.fullName != " jdk.internal" )
280+ scala.util.Try (a.tpe <:< TypeRepr .of[scala.annotation.Annotation ]).toOption.contains(true ) &&
281+ (a.tpe.typeSymbol.maybeOwner.isNoSymbol ||
282+ (a.tpe.typeSymbol.owner.fullName != " scala.annotation.internal" &&
283+ a.tpe.typeSymbol.owner.fullName != " jdk.internal" ))
283284 }
0 commit comments