Skip to content

Commit f7484ce

Browse files
committed
Small tweaks
1 parent 6093dab commit f7484ce

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ case class CaptureAnnotation(refs: CaptureSet, boxed: Boolean)(cls: Symbol) exte
4242
case cr: TermRef => ref(cr)
4343
case cr: TermParamRef => untpd.Ident(cr.paramName).withType(cr)
4444
case cr: ThisType => This(cr.cls)
45-
// TODO: Will crash if the type is an annotated type, for example `cap?`
45+
case root(_) => ref(defn.captureRoot.termRef)
46+
// TODO: Will crash if the type is an annotated type, for example `cap.rd`
4647
}
4748
val arg = repeated(elems, TypeTree(defn.AnyType))
4849
New(symbol.typeRef, arg :: Nil)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ extension (tp: Type)
437437
/** Knowing that `tp` is a function type, is it an alias to a function other
438438
* than `=>`?
439439
*/
440-
def isAliasFun(using Context) = tp match
440+
def isAliasFun(using Context): Boolean = tp match
441441
case AppliedType(tycon, _) => !defn.isFunctionSymbol(tycon.typeSymbol)
442442
case _ => false
443443

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ object root:
2525
case Result(binder: MethodType)
2626
case Fresh(hidden: CaptureSet.HiddenSet)
2727

28-
override def equals(other: Any): Boolean = this match
28+
override def equals(other: Any): Boolean =
29+
(this eq other.asInstanceOf[AnyRef]) || this.match
2930
case Kind.Result(b1) => other match
3031
case Kind.Result(b2) => b1 eq b2
3132
case _ => false
@@ -271,13 +272,14 @@ object root:
271272
case t: TermRef => t.isCap || this(x, t.widen)
272273
case x: ThisType => false
273274
case _ => foldOver(x, t)
274-
def containsFresh(x: Type | CaptureSet): Boolean = x match
275+
276+
def containsCap(x: Type | CaptureSet): Boolean = x match
275277
case tp: Type =>
276278
hasCap(false, tp)
277279
case refs: CaptureSet =>
278280
refs.elems.exists(_.stripReadOnly.isCap)
279281

280-
if refs.exists(containsFresh) then ctx.withProperty(PrintFresh, Some(()))
282+
if refs.exists(containsCap) then ctx.withProperty(PrintFresh, Some(()))
281283
else ctx
282284
end printContext
283285
end root

0 commit comments

Comments
 (0)