Skip to content

Commit dd6e1e4

Browse files
committed
Make isCapSetCap reject cap* and cap.rd
1 parent 241e02d commit dd6e1e4

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

local/project/dummy/capturevars.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ trait Test:
2525
def baz2(x: U[{caps.cap}]): Unit
2626
def test[E^, F^ >: {caps.cap} <: {}, G <: [C^ >: {a,b} <: {a,b}] =>> AnyRef^{C}](x: T[{E,a,b}], y: U[F]): Unit
2727
val poly: [C^ >: {a,b}] => (f: () ->{C} Unit) -> Int ->{C} Unit
28+
29+
def readup[T^ <: {cap.rd}]() = ()
30+
def readlo[T^ >: {cap.rd}]() = ()

scaladoc/src/dotty/tools/scaladoc/cc/CaptureOps.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ extension (using qctx: Quotes)(ann: qctx.reflect.Symbol)
7474
end extension
7575

7676
extension (using qctx: Quotes)(tpe: qctx.reflect.TypeRepr) // FIXME clean up and have versions on Symbol for those
77-
def isCaptureRoot: Boolean = tpe.termSymbol == CaptureDefs.captureRoot
77+
def isCaptureRoot: Boolean =
78+
import qctx.reflect.*
79+
tpe match
80+
case TermRef(ThisType(TypeRef(NoPrefix(), "caps")), "cap") => true
81+
case TermRef(TermRef(ThisType(TypeRef(NoPrefix(), "scala")), "caps"), "cap") => true
82+
case TermRef(TermRef(TermRef(TermRef(NoPrefix(), "_root_"), "scala"), "caps"), "cap") => true
83+
case _ => false
7884

7985
// NOTE: There's something horribly broken with Symbols, and we can't rely on tests like .isContextFunctionType either,
8086
// so we do these lame string comparisons instead.
@@ -182,4 +188,4 @@ object CapturingType:
182188
case AnnotatedType(base, Apply(Select(New(annot), _), Nil)) if annot.symbol == CaptureDefs.retainsCap =>
183189
Some((base, List(CaptureDefs.captureRoot.termRef)))
184190
case _ => None
185-
end CapturingType
191+
end CapturingType

0 commit comments

Comments
 (0)