Skip to content

Commit 9f82e69

Browse files
committed
Drop RefiningVar
1 parent 2981ae7 commit 9f82e69

File tree

4 files changed

+14
-50
lines changed

4 files changed

+14
-50
lines changed

compiler/src/dotty/tools/dotc/cc/CaptureSet.scala

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,6 @@ object CaptureSet:
395395
def apply(elems: Refs)(using Context): CaptureSet.Const =
396396
if elems.isEmpty then empty else Const(elems)
397397

398-
/** If this context property is asserted, we conflate capture roots in subCapture
399-
* tests. Specifically, `cap` then subsumes everything and all local roots subsume `cap`.
400-
* This generally not sound. We currently use loose root checking only in self type
401-
* conformance tests in CheckCaptures.checkSelfTypes.
402-
*/
403-
val LooseRootChecking: Property.Key[Unit] = Property.Key()
404-
405398
/** The subclass of constant capture sets with given elements `elems` */
406399
class Const private[CaptureSet] (val elems: Refs, val description: String = "") extends CaptureSet:
407400
def isConst = true
@@ -618,14 +611,6 @@ object CaptureSet:
618611
override def toString = s"Var$id$elems"
619612
end Var
620613

621-
/** A variable used in refinements of class parameters. See `addCaptureRefinements`.
622-
*/
623-
class RefiningVar(owner: Symbol, val getter: Symbol)(using @constructorOnly ictx: Context) extends Var(owner):
624-
description = i"of parameter ${getter.name} of ${getter.owner}"
625-
override def optionalInfo(using Context): String =
626-
super.optionalInfo + (
627-
if ctx.settings.YprintDebug.value then "(refining)" else "")
628-
629614
/** A variable that is derived from some other variable via a map or filter. */
630615
abstract class DerivedVar(owner: Symbol, initialElems: Refs)(using @constructorOnly ctx: Context)
631616
extends Var(owner, initialElems):
@@ -1006,8 +991,6 @@ object CaptureSet:
1006991
if tp.typeSymbol == defn.Caps_Cap then universal else empty
1007992
case _: TypeParamRef =>
1008993
empty
1009-
case CapturingType(parent, refs: RefiningVar) =>
1010-
refs
1011994
case CapturingType(parent, refs) =>
1012995
recur(parent) ++ refs
1013996
case tpd @ defn.RefinedFunctionOf(rinfo: MethodType) if followResult =>

compiler/src/dotty/tools/dotc/cc/Setup.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
175175
val getterType =
176176
mapInferred(refine = false)(tp.memberInfo(getter)).strippedDealias
177177
RefinedType(core, getter.name,
178-
CapturingType(getterType, CaptureSet.RefiningVar(NoSymbol, getter)))
178+
CapturingType(getterType, CaptureSet.Var(ctx.owner)))
179179
.showing(i"add capture refinement $tp --> $result", ccSetup)
180180
else
181181
core

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -682,18 +682,6 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
682682
case tp1: RefinedType =>
683683
return isSubInfo(tp1.refinedInfo, tp2.refinedInfo)
684684
case _ =>
685-
else tp2.refinedInfo match
686-
case rinfo2 @ CapturingType(_, refs: CaptureSet.RefiningVar) =>
687-
tp1.widen match
688-
case RefinedType(parent1, tp2.refinedName, rinfo1) =>
689-
// When comparing against a Var in class instance refinement,
690-
// take the Var as the precise truth, don't also look in the parent.
691-
// The parent might have a capture root at the wrong level.
692-
// TODO: Generalize this to other refinement situations where the
693-
// lower type's refinement appears elsewhere?
694-
return isSubType(rinfo1, rinfo2) && recur(parent1, tp2.parent)
695-
case _ =>
696-
case _ =>
697685
end if
698686

699687
val skipped2 = skipMatching(tp1w, tp2)

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -834,26 +834,19 @@ object Types {
834834
pinfo recoverable_& rinfo
835835
pdenot.asSingleDenotation.derivedSingleDenotation(pdenot.symbol, jointInfo)
836836
}
837-
else rinfo match
838-
case CapturingType(_, cs: CaptureSet.RefiningVar) =>
839-
// If `rinfo` is a capturing type added by `addCaptureRefinements` it
840-
// already contains everything there is to know about the member type.
841-
// On the other hand, the member in parent might belong to an outer nesting level,
842-
// which should be ignored at the point where instances of the class are constructed.
843-
pdenot.asSingleDenotation.derivedSingleDenotation(pdenot.symbol, rinfo)
844-
case _ =>
845-
val isRefinedMethod = rinfo.isInstanceOf[MethodOrPoly]
846-
val joint = pdenot.meet(
847-
new JointRefDenotation(NoSymbol, rinfo, Period.allInRun(ctx.runId), pre, isRefinedMethod),
848-
pre,
849-
safeIntersection = ctx.base.pendingMemberSearches.contains(name))
850-
joint match
851-
case joint: SingleDenotation
852-
if isRefinedMethod && rinfo <:< joint.info =>
853-
// use `rinfo` to keep the right parameter names for named args. See i8516.scala.
854-
joint.derivedSingleDenotation(joint.symbol, rinfo, pre, isRefinedMethod)
855-
case _ =>
856-
joint
837+
else
838+
val isRefinedMethod = rinfo.isInstanceOf[MethodOrPoly]
839+
val joint = pdenot.meet(
840+
new JointRefDenotation(NoSymbol, rinfo, Period.allInRun(ctx.runId), pre, isRefinedMethod),
841+
pre,
842+
safeIntersection = ctx.base.pendingMemberSearches.contains(name))
843+
joint match
844+
case joint: SingleDenotation
845+
if isRefinedMethod && rinfo <:< joint.info =>
846+
// use `rinfo` to keep the right parameter names for named args. See i8516.scala.
847+
joint.derivedSingleDenotation(joint.symbol, rinfo, pre, isRefinedMethod)
848+
case _ =>
849+
joint
857850
}
858851

859852
def goApplied(tp: AppliedType, tycon: HKTypeLambda) =

0 commit comments

Comments
 (0)