@@ -45,33 +45,19 @@ extends tpd.TreeTraverser:
45
45
else tp1.derivedLambdaType(resType = boxedRes)
46
46
case _ => tp
47
47
48
- private def addBoxes (using Context ) = new TypeMap :
49
- def apply (t : Type ) = mapOver(t) match
50
- case t1 @ AppliedType (tycon, args) if ! defn.isNonRefinedFunction(t1) =>
51
- t1.derivedAppliedType(tycon, args.mapConserve(box))
52
- case t1 : AliasingBounds =>
53
- t1.derivedAlias(t1.alias)
54
- case t1 @ TypeBounds (lo, hi) =>
55
- t1.derivedTypeBounds(box(lo), box(hi))
56
- case t1 =>
57
- t1
58
- override def mapCapturingType (tp : Type , parent : Type , refs : CaptureSet , v : Int ): Type =
59
- tp.derivedCapturingType(this (parent), refs)
60
- end addBoxes
61
-
62
48
/** Expand some aliases of function types to the underlying functions.
63
49
* Right now, these are only $throws aliases, but this could be generalized.
64
50
*/
65
- def expandInlineAlias (tp : Type )(using Context ) = tp match
51
+ def expandThrowsAlias (tp : Type )(using Context ) = tp match
66
52
case AppliedType (tycon, res :: exc :: Nil ) if tycon.typeSymbol == defn.throwsAlias =>
67
53
// hard-coded expansion since $throws aliases in stdlib are defined with `?=>` rather than `?->`
68
54
defn.FunctionOf (defn.CanThrowClass .typeRef.appliedTo(exc) :: Nil , res, isContextual = true , isErased = true )
69
55
case _ => tp
70
56
71
- private def expandInlineAliases (using Context ) = new TypeMap :
57
+ private def expandThrowsAliases (using Context ) = new TypeMap :
72
58
def apply (t : Type ) = t match
73
59
case _ : AppliedType =>
74
- val t1 = expandInlineAlias (t)
60
+ val t1 = expandThrowsAlias (t)
75
61
if t1 ne t then apply(t1) else mapOver(t)
76
62
case _ : LazyRef =>
77
63
t
@@ -208,7 +194,7 @@ extends tpd.TreeTraverser:
208
194
try ts.mapConserve(this ) finally isTopLevel = saved
209
195
210
196
def apply (t : Type ) =
211
- val tp = expandInlineAlias (t)
197
+ val tp = expandThrowsAlias (t)
212
198
val tp1 = tp match
213
199
case AnnotatedType (parent, annot) if annot.symbol == defn.RetainsAnnot =>
214
200
apply(parent)
@@ -296,9 +282,7 @@ extends tpd.TreeTraverser:
296
282
if boxed then box(tp1) else tp1
297
283
298
284
private def transformExplicitType (tp : Type , boxed : Boolean )(using Context ): Type =
299
- var tp1 = addBoxes(tp)
300
- if boxed then tp1 = box(tp1)
301
- tp1 = expandInlineAliases(tp1)
285
+ val tp1 = expandThrowsAliases(if boxed then box(tp) else tp)
302
286
if tp1 ne tp then capt.println(i " expanded: $tp --> $tp1" )
303
287
if ctx.settings.YccNoAbbrev .value then tp1
304
288
else expandAbbreviations(tp1)
0 commit comments