@@ -19,6 +19,7 @@ import dotty.tools.dotc.config.ScalaRelease.*
19
19
import scala .collection .mutable
20
20
import dotty .tools .dotc .core .Annotations ._
21
21
import dotty .tools .dotc .core .StdNames ._
22
+ import dotty .tools .dotc .core .TypeOps .AvoidMap
22
23
import dotty .tools .dotc .quoted ._
23
24
import dotty .tools .dotc .inlines .Inlines
24
25
@@ -135,16 +136,9 @@ class PickleQuotes extends MacroTransform {
135
136
}
136
137
137
138
/** Remove references to local types that will not be defined in this quote */
138
- private def getTermHoleType (using Context ) = new TypeMap () {
139
- override def apply (tp : Type ): Type = tp match
140
- case tp @ TypeRef (NoPrefix , _) =>
141
- // reference to term with a type defined in outer quote
142
- getTypeHoleType(tp)
143
- case tp @ TermRef (NoPrefix , _) =>
144
- // widen term refs to terms defined in outer quote
145
- apply(tp.widenTermRefExpr)
146
- case tp =>
147
- mapOver(tp)
139
+ private def getTermHoleType (using Context ) = new AvoidMap {
140
+ def toAvoid (tp : NamedType ): Boolean =
141
+ tp.prefix == NoPrefix // reference to terms and type defined in outer quote
148
142
}
149
143
150
144
/** Get the contents of the transformed tree */
@@ -210,24 +204,15 @@ class PickleQuotes extends MacroTransform {
210
204
}
211
205
212
206
/** Remove references to local types that will not be defined in this quote */
213
- private def getTypeHoleType (using Context ) = new TypeMap () {
214
- override def apply (tp : Type ): Type = tp match
215
- case tp : TypeRef if tp.typeSymbol.isTypeSplice =>
216
- apply(tp.dealias)
217
- case tp @ TypeRef (pre, _) if isLocalPath(pre) =>
218
- val hiBound = tp.typeSymbol.info match
219
- case info : ClassInfo => info.parents.reduce(_ & _)
220
- case info => info.hiBound
221
- apply(hiBound)
222
- case tp =>
223
- mapOver(tp)
207
+ private def getTypeHoleType (using Context ) = new AvoidMap {
208
+ def toAvoid (tp : NamedType ): Boolean =
209
+ tp.typeSymbol.isTypeSplice || isLocalPath(tp.prefix)
224
210
225
211
private def isLocalPath (tp : Type ): Boolean = tp match
226
212
case NoPrefix => true
227
213
case tp : TermRef if ! tp.symbol.is(Package ) => isLocalPath(tp.prefix)
228
214
case tp => false
229
215
}
230
-
231
216
}
232
217
233
218
object PickleQuotes {
0 commit comments