Skip to content

Commit fc41883

Browse files
committed
Revert "Fix inline proxy generation for opaque types referencing other opaque types"
This reverts commit bf7bfa5.
1 parent 05b102a commit fc41883

File tree

4 files changed

+2
-93
lines changed

4 files changed

+2
-93
lines changed

compiler/src/dotty/tools/dotc/inlines/Inliner.scala

+2-44
Original file line numberDiff line numberDiff line change
@@ -162,28 +162,9 @@ object Inliner:
162162
else Nil
163163
case _ => Nil
164164
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-
179165
val refinedType = refinements.foldLeft(ref: Type): (parent, refinement) =>
180166
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)
187168
refiningSym.termRef
188169

189170
def unapply(refiningRef: TermRef)(using Context): Option[TermRef] =
@@ -438,9 +419,7 @@ class Inliner(val call: tpd.Tree)(using Context):
438419
val refiningRef = OpaqueProxy(ref, cls, call.span)
439420
val refiningSym = refiningRef.symbol.asTerm
440421
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)
444423
inlining.println(i"add opaque alias proxy $refiningDef for $ref in $tp")
445424
bindingsBuf += refiningDef
446425
opaqueProxies += ((ref, refiningSym.termRef))
@@ -460,27 +439,6 @@ class Inliner(val call: tpd.Tree)(using Context):
460439
}
461440
)
462441

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-
484442
/** If `binding` contains TermRefs that refer to objects with opaque
485443
* type aliases, add proxy definitions that expose these aliases
486444
* and substitute such TermRefs with theproxies. Example from pos/opaque-inline1.scala:

tests/pos/22359a.scala

-15
This file was deleted.

tests/pos/22359b.scala

-17
This file was deleted.

tests/pos/i17243.scala

-17
This file was deleted.

0 commit comments

Comments
 (0)