Skip to content

Commit 13421df

Browse files
committed
Convert context functions in Types to CFTs
1 parent cfa02e2 commit 13421df

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
537537
// HKLambdas are hash-consed, need to create an artificial difference by adding
538538
// a LazyRef to a bound.
539539
val TypeBounds(lo, hi) :: pinfos1 = tl.paramInfos
540-
paramInfos = TypeBounds(lo, LazyRef(_ => hi)) :: pinfos1
540+
paramInfos = TypeBounds(lo, LazyRef(hi)) :: pinfos1
541541
}
542542
ensureFresh(tl.newLikeThis(tl.paramNames, paramInfos, tl.resultType))
543543
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ class TypeApplications(val self: Type) extends AnyVal {
337337
case dealiased: TypeBounds =>
338338
dealiased.derivedTypeBounds(dealiased.lo.appliedTo(args), dealiased.hi.appliedTo(args))
339339
case dealiased: LazyRef =>
340-
LazyRef(c => dealiased.ref(using c).appliedTo(args)(using c))
340+
LazyRef(dealiased.ref.appliedTo(args))
341341
case dealiased: WildcardType =>
342342
WildcardType(dealiased.optBounds.orElse(TypeBounds.empty).appliedTo(args).bounds)
343343
case dealiased: TypeRef if dealiased.symbol == defn.NothingClass =>

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ object Types {
12091209
case Atoms.Unknown => Atoms.Unknown
12101210
case _ => Atoms.Unknown
12111211

1212-
private def dealias1(keep: AnnotatedType => Context => Boolean)(using Context): Type = this match {
1212+
private def dealias1(keep: AnnotatedType => Context ?=> Boolean)(using Context): Type = this match {
12131213
case tp: TypeRef =>
12141214
if (tp.symbol.isClass) tp
12151215
else tp.info match {
@@ -1225,7 +1225,7 @@ object Types {
12251225
if (tp1.exists) tp1.dealias1(keep) else tp
12261226
case tp: AnnotatedType =>
12271227
val tp1 = tp.parent.dealias1(keep)
1228-
if (keep(tp)(ctx)) tp.derivedAnnotatedType(tp1, tp.annot) else tp1
1228+
if keep(tp) then tp.derivedAnnotatedType(tp1, tp.annot) else tp1
12291229
case tp: LazyRef =>
12301230
tp.ref.dealias1(keep)
12311231
case _ => this
@@ -1260,7 +1260,7 @@ object Types {
12601260
*/
12611261
def tryNormalize(using Context): Type = NoType
12621262

1263-
private def widenDealias1(keep: AnnotatedType => Context => Boolean)(using Context): Type = {
1263+
private def widenDealias1(keep: AnnotatedType => Context ?=> Boolean)(using Context): Type = {
12641264
val res = this.widen.dealias1(keep)
12651265
if (res eq this) res else res.widenDealias1(keep)
12661266
}
@@ -2627,7 +2627,7 @@ object Types {
26272627
}
26282628
}
26292629

2630-
case class LazyRef(private var refFn: Context => Type, reportCycles: Boolean = false) extends UncachedProxyType with ValueType {
2630+
case class LazyRef(private var refFn: Context ?=> Type, reportCycles: Boolean = false) extends UncachedProxyType with ValueType {
26312631
private var myRef: Type = null
26322632
private var computed = false
26332633

@@ -2640,7 +2640,7 @@ object Types {
26402640
throw CyclicReference(NoDenotation)
26412641
else
26422642
computed = true
2643-
val result = refFn(ctx)
2643+
val result = refFn
26442644
refFn = null
26452645
if result != null then myRef = result
26462646
else assert(myRef != null) // must have been `update`d
@@ -4431,7 +4431,7 @@ object Types {
44314431
else defn.AnyType // dummy type in case of errors
44324432
def refineSelfType(selfType: Type) =
44334433
RefinedType(selfType, sym.name,
4434-
TypeAlias(LazyRef(force(using _), reportCycles = true)))
4434+
TypeAlias(LazyRef(force, reportCycles = true)))
44354435
cinfo.selfInfo match
44364436
case self: Type =>
44374437
cinfo.derivedClassInfo(
@@ -4990,14 +4990,14 @@ object Types {
49904990
derivedSuperType(tp, this(thistp), this(supertp))
49914991

49924992
case tp: LazyRef =>
4993-
LazyRef { c =>
4994-
val ref1 = tp.ref(using c)
4995-
if currentRunId(using c) == currentRunId(using mapCtx) then this(ref1)
4993+
LazyRef {
4994+
val ref1 = tp.ref
4995+
if currentRunId == currentRunId(using mapCtx) then this(ref1)
49964996
else // splice in new run into map context
49974997
val saved = mapCtx
49984998
mapCtx = mapCtx.fresh
4999-
.setPeriod(Period(currentRunId(using c), currentPhaseId(using mapCtx)))
5000-
.setRun(c.run)
4999+
.setPeriod(Period(currentRunId, currentPhaseId(using mapCtx)))
5000+
.setRun(ctx.run)
50015001
try this(ref1) finally mapCtx = saved
50025002
}
50035003

@@ -5658,9 +5658,9 @@ object Types {
56585658
}
56595659
}
56605660

5661-
private val keepAlways: AnnotatedType => Context => Boolean = _ => _ => true
5662-
private val keepNever: AnnotatedType => Context => Boolean = _ => _ => false
5663-
private val keepIfRefining: AnnotatedType => Context => Boolean = tp => ctx => tp.isRefining(using ctx)
5661+
private val keepAlways: AnnotatedType => Context ?=> Boolean = _ => true
5662+
private val keepNever: AnnotatedType => Context ?=> Boolean = _ => false
5663+
private val keepIfRefining: AnnotatedType => Context ?=> Boolean = _.isRefining
56645664

56655665
val isBounds: Type => Boolean = _.isInstanceOf[TypeBounds]
56665666
}

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ object Checking {
300300
catch {
301301
case ex: CyclicReference =>
302302
report.debuglog(i"cycle detected for $tp, $nestedCycleOK, $cycleOK")
303-
if (cycleOK) LazyRef(_ => tp)
303+
if (cycleOK) LazyRef(tp)
304304
else if (reportErrors) throw ex
305305
else tp
306306
}

0 commit comments

Comments
 (0)