@@ -162,28 +162,9 @@ object Inliner:
162
162
else Nil
163
163
case _ => Nil
164
164
val refinements = openOpaqueAliases(cls.givenSelfType)
165
-
166
- // Map references in the refinements from the proxied termRef
167
- // to the recursive type of the refined type
168
- // e.g.: Obj.type{type A = Obj.B; type B = Int} -> Obj.type{type A = <recthis>.B; type B = Int}
169
- def mapRecTermRefReferences (recType : RecType , refinedType : Type ) =
170
- new TypeMap {
171
- def apply (tp : Type ) = tp match
172
- case RefinedType (a : RefinedType , b, info) => RefinedType (apply(a), b, apply(info))
173
- case RefinedType (a, b, info) => RefinedType (a, b, apply(info))
174
- case TypeRef (prefix, des) => TypeRef (apply(prefix), des)
175
- case termRef : TermRef if termRef == ref => recType.recThis
176
- case _ => mapOver(tp)
177
- }.apply(refinedType)
178
-
179
165
val refinedType = refinements.foldLeft(ref : Type ): (parent, refinement) =>
180
166
RefinedType (parent, refinement._1, TypeAlias (refinement._2))
181
-
182
- val recType = RecType .closeOver ( recType =>
183
- mapRecTermRefReferences(recType, refinedType)
184
- )
185
-
186
- val refiningSym = newSym(InlineBinderName .fresh(), Synthetic , recType, span)
167
+ val refiningSym = newSym(InlineBinderName .fresh(), Synthetic , refinedType, span)
187
168
refiningSym.termRef
188
169
189
170
def unapply (refiningRef : TermRef )(using Context ): Option [TermRef ] =
@@ -438,9 +419,7 @@ class Inliner(val call: tpd.Tree)(using Context):
438
419
val refiningRef = OpaqueProxy (ref, cls, call.span)
439
420
val refiningSym = refiningRef.symbol.asTerm
440
421
val refinedType = refiningRef.info
441
- val refiningDef = addProxiesForRecurrentOpaques(
442
- ValDef (refiningSym, tpd.ref(ref).cast(refinedType), inferred = true ).withSpan(span)
443
- )
422
+ val refiningDef = ValDef (refiningSym, tpd.ref(ref).cast(refinedType), inferred = true ).withSpan(span)
444
423
inlining.println(i " add opaque alias proxy $refiningDef for $ref in $tp" )
445
424
bindingsBuf += refiningDef
446
425
opaqueProxies += ((ref, refiningSym.termRef))
@@ -460,27 +439,6 @@ class Inliner(val call: tpd.Tree)(using Context):
460
439
}
461
440
)
462
441
463
- /** Transforms proxies that reference other opaque types, like for:
464
- * object Obj1 { opaque type A = Int }
465
- * object Obj2 { opaque type B = A }
466
- * and proxy$1 of type Obj2.type{type B = Obj1.A}
467
- * creates proxy$2 of type Obj1.type{type A = Int}
468
- * and transforms proxy$1 into Obj2.type{type B = proxy$2.A}
469
- */
470
- private def addProxiesForRecurrentOpaques (binding : ValDef )(using Context ): ValDef =
471
- def fixRefinedTypes (ref : Type ): Unit =
472
- ref match
473
- case recType : RecType => fixRefinedTypes(recType.underlying)
474
- case RefinedType (parent, name, info) =>
475
- addOpaqueProxies(info.widen, binding.span, true )
476
- fixRefinedTypes(parent)
477
- case _ =>
478
- fixRefinedTypes(binding.symbol.info)
479
- binding.symbol.info = mapOpaques.typeMap(binding.symbol.info)
480
- mapOpaques.transform(binding).asInstanceOf [ValDef ]
481
- .showing(i " transformed this binding exposing opaque aliases: $result" , inlining)
482
- end addProxiesForRecurrentOpaques
483
-
484
442
/** If `binding` contains TermRefs that refer to objects with opaque
485
443
* type aliases, add proxy definitions that expose these aliases
486
444
* and substitute such TermRefs with theproxies. Example from pos/opaque-inline1.scala:
0 commit comments