@@ -28,7 +28,7 @@ import reporting._
28
28
import ProtoTypes ._
29
29
import dotty .tools .backend .jvm .DottyBackendInterface .symExtensions
30
30
import CaptureSet .CompareResult
31
- import cc .CaptureOps .toCaptureSet
31
+ import cc .CaptureOps .*
32
32
33
33
object CheckCaptures :
34
34
case class Env (owner : Symbol , captured : CaptureSet , isBoxed : Boolean , outer : Env ):
@@ -37,41 +37,6 @@ object CheckCaptures:
37
37
/** Attachment key for printing trees with rechecked types */
38
38
val RecheckedType = Property .Key [Type ]
39
39
40
- extension (tp : Type )
41
-
42
- /** If this is type variable instantiated or upper bounded with a capturing type,
43
- * the capture set associated with that type. Extended to and-or types and
44
- * type proxies in the obvious way. If a term has a type with a boxed captureset,
45
- * that captureset counts towards the capture variables of the envirionment.
46
- */
47
- def boxedCaptured (using Context ): CaptureSet =
48
- def getBoxed (tp : Type , enabled : Boolean ): CaptureSet = tp match
49
- case tp : CapturingType if enabled => tp.refs
50
- case tp : TypeVar => getBoxed(tp.underlying, enabled = true )
51
- case tp : TypeRef if tp.symbol == defn.AnyClass && enabled => CaptureSet .universal
52
- case tp : TypeProxy => getBoxed(tp.superType, enabled)
53
- case tp : AndType => getBoxed(tp.tp1, enabled) ++ getBoxed(tp.tp2, enabled)
54
- case tp : OrType => getBoxed(tp.tp1, enabled) ** getBoxed(tp.tp2, enabled)
55
- case _ => CaptureSet .empty
56
- getBoxed(tp, enabled = false )
57
-
58
- /** If this type appears as an expected type of a term, does it imply
59
- * that the term should be boxed? ^^^ Special treat Any?
60
- */
61
- def needsBox (using Context ): Boolean = tp match
62
- case _ : TypeVar => true
63
- case tp : TypeRef =>
64
- tp.info match
65
- case TypeBounds (lo, _) => lo.needsBox
66
- case _ => false
67
- case tp : RefinedOrRecType => tp.parent.needsBox
68
- case tp : AnnotatedType => tp.parent.needsBox
69
- case tp : LazyRef => tp.ref.needsBox
70
- case tp : AndType => tp.tp1.needsBox || tp.tp2.needsBox
71
- case tp : OrType => tp.tp1.needsBox && tp.tp2.needsBox
72
- case _ => false
73
- end extension
74
-
75
40
class CheckCaptures extends Recheck :
76
41
thisPhase =>
77
42
0 commit comments