11package dotty .dokka .tasty
22
3- import scala .tasty . Reflection
3+ import scala .quoted . _
44
55trait SyntheticsSupport :
66 self : TastyParser =>
@@ -31,11 +31,11 @@ trait SyntheticsSupport:
3131
3232 def isDefaultHelperMethod : Boolean = " .*\\ $default\\ $\\ d+$" .r.matches(s.name)
3333
34- def isOpaque : Boolean = hackIsOpaque(qctx.reflect )(s)
34+ def isOpaque : Boolean = hackIsOpaque(using qctx)(s)
3535
36- def isInfix : Boolean = hackIsInfix(qctx.reflect )(s)
36+ def isInfix : Boolean = hackIsInfix(using qctx)(s)
3737
38- def getAllMembers : List [Symbol ] = hackGetAllMembers(qctx.reflect )(s)
38+ def getAllMembers : List [Symbol ] = hackGetAllMembers(using qctx)(s)
3939
4040 def isSyntheticField (c : Symbol ) =
4141 c.flags.is(Flags .CaseAccessor ) || c.flags.is(Flags .Object )
@@ -52,53 +52,57 @@ trait SyntheticsSupport:
5252 }
5353
5454 // TODO: #49 Remove it after TASTY-Reflect release with published flag Extension
55- def hackIsInfix (r : Reflection )(rsym : r.Symbol ): Boolean = {
55+ def hackIsInfix (using QuoteContext )(rsym : qctx.reflect.Symbol ): Boolean = {
56+ import qctx .reflect ._
5657 import dotty .tools .dotc
57- given ctx as dotc .core.Contexts .Context = r. rootContext.asInstanceOf
58+ given ctx as dotc .core.Contexts .Context = rootContext.asInstanceOf
5859 val sym = rsym.asInstanceOf [dotc.core.Symbols .Symbol ]
5960 ctx.definitions.isInfix(sym)
6061 }
6162 /* We need there to filter out symbols with certain flagsets, because these symbols come from compiler and TASTY can't handle them well.
6263 They are valdefs that describe case companion objects and cases from enum.
6364 TASTY crashed when calling _.tree on them.
6465 */
65- def hackGetAllMembers (r : Reflection )(rsym : r.Symbol ): List [r.Symbol ] = {
66+ def hackGetAllMembers (using QuoteContext )(rsym : qctx.reflect.Symbol ): List [qctx.reflect.Symbol ] = {
67+ import qctx .reflect ._
6668 import dotty .tools .dotc
67- given ctx as dotc .core.Contexts .Context = r. rootContext.asInstanceOf
69+ given ctx as dotc .core.Contexts .Context = rootContext.asInstanceOf
6870 val sym = rsym.asInstanceOf [dotc.core.Symbols .Symbol ]
6971 sym.typeRef.appliedTo(sym.typeParams.map(_.typeRef)).allMembers.iterator.map(_.symbol)
7072 .collect {
7173 case sym if
7274 ! sym.is(dotc.core.Flags .ModuleVal ) &&
7375 ! sym.flags.isAllOf(dotc.core.Flags .Enum | dotc.core.Flags .Case | dotc.core.Flags .JavaStatic ) =>
74- sym.asInstanceOf [r. Symbol ]
76+ sym.asInstanceOf [Symbol ]
7577 }.toList
7678 }
7779
78- def hackIsOpaque (r : Reflection )(rsym : r .Symbol ): Boolean = {
80+ def hackIsOpaque (using QuoteContext )(rsym : qctx.reflect .Symbol ): Boolean = {
7981 import dotty .tools .dotc
80- given dotc .core.Contexts .Context = r .rootContext.asInstanceOf
82+ given dotc .core.Contexts .Context = qctx.reflect .rootContext.asInstanceOf
8183 val sym = rsym.asInstanceOf [dotc.core.Symbols .Symbol ]
8284 sym.is(dotc.core.Flags .Opaque )
8385 }
8486
85- def hackGetSupertypes (r : Reflection )(rdef : r.ClassDef ) = {
87+ def hackGetSupertypes (using QuoteContext )(rdef : qctx.reflect.ClassDef ) = {
88+ import qctx .reflect ._
8689 import dotty .tools .dotc
87- given dotc .core.Contexts .Context = r .rootContext.asInstanceOf
90+ given dotc .core.Contexts .Context = qctx.reflect .rootContext.asInstanceOf
8891 val classdef = rdef.asInstanceOf [dotc.ast.tpd.TypeDef ]
8992 val ref = classdef.symbol.info.asInstanceOf [dotc.core.Types .ClassInfo ].appliedRef
9093 val baseTypes : List [(dotc.core.Symbols .Symbol , dotc.core.Types .Type )] =
9194 ref.baseClasses.map(b => b -> ref.baseType(b))
92- baseTypes.asInstanceOf [List [(r. Symbol , r. TypeRepr )]]
95+ baseTypes.asInstanceOf [List [(Symbol , TypeRepr )]]
9396 }
9497
95- def getSupertypes (c : ClassDef ) = hackGetSupertypes(qctx.reflect) (c).tail
98+ def getSupertypes (using QuoteContext )( c : ClassDef ) = hackGetSupertypes(c).tail
9699
97- def typeForClass (c : ClassDef ): r.TypeRepr =
100+ def typeForClass (c : ClassDef ): TypeRepr =
101+ import qctx .reflect ._
98102 import dotty .tools .dotc
99- given dotc .core.Contexts .Context = r. rootContext.asInstanceOf
103+ given dotc .core.Contexts .Context = rootContext.asInstanceOf
100104 val cSym = c.symbol.asInstanceOf [dotc.core.Symbols .Symbol ]
101- cSym.typeRef.appliedTo(cSym.typeParams.map(_.typeRef)).asInstanceOf [r. TypeRepr ]
105+ cSym.typeRef.appliedTo(cSym.typeParams.map(_.typeRef)).asInstanceOf [TypeRepr ]
102106
103107 object MatchTypeCase :
104108 def unapply (tpe : TypeRepr ): Option [(TypeRepr , TypeRepr )] =
0 commit comments