@@ -192,11 +192,9 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
192
192
case tp : TypeRef =>
193
193
tp.prefix match
194
194
case NoPrefix if level > levelOf(tp.symbol) && ! tp.typeSymbol.hasAnnotation(defn.QuotedRuntime_SplicedTypeAnnot ) =>
195
- val tp1 = tp.dealias
196
- if tp1 != tp then apply(tp1)
197
- else tryHeal(tp.symbol, tp, pos)
195
+ tryHealTypeOfType(tp.symbol, tp, pos)
198
196
case prefix : ThisType if ! tp.symbol.isStatic && level > levelOf(prefix.cls) =>
199
- tryHeal (tp.symbol, tp, pos)
197
+ tryHealTypeOfType (tp.symbol, tp, pos)
200
198
case prefix : TermRef if tp.symbol.isTypeSplice =>
201
199
prefix.symbol.info.argInfos match
202
200
case (tb : TypeBounds ) :: _ =>
@@ -205,7 +203,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
205
203
// Heal explicit type splice in the code
206
204
if level > 0 then getQuoteTypeTags.getTagRef(prefix) else tp
207
205
case prefix : TermRef if ! prefix.symbol.isStatic && level > levelOf(prefix.symbol) =>
208
- tryHeal (prefix.symbol, tp, pos)
206
+ tryHealTypeOfType (prefix.symbol, tp, pos)
209
207
case _ =>
210
208
mapOver(tp)
211
209
case tp @ TermRef (NoPrefix , _) if ! tp.symbol.isStatic && level > levelOf(tp.symbol) =>
@@ -217,6 +215,17 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
217
215
derivedAnnotatedType(tp, apply(tp.parent), tp.annot.derivedAnnotation(newAnnotTree))
218
216
case _ =>
219
217
mapOver(tp)
218
+
219
+ /** Try to dealias or heal reference to type `T` used in a higher level than its definition.
220
+ * Returns a reference to a type tag generated by `QuoteTypeTags` that contains a
221
+ * reference to a type alias containing the equivalent of `${summon[quoted.Type[T]]}`.
222
+ * Emits and error if `T` cannot be healed and returns `T`.
223
+ */
224
+ private def tryHealTypeOfType (sym : Symbol , tp : TypeRef , pos : SrcPos )(using Context ): Type = {
225
+ val tp1 = tp.dealias
226
+ if tp1 != tp then apply(tp1)
227
+ else tryHeal(tp.symbol, tp, pos)
228
+ }
220
229
}
221
230
222
231
/** Check phase consistency of terms and heal inconsistent type references. */
0 commit comments