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