@@ -57,7 +57,9 @@ object CaptureOps:
57
57
getBoxed(tp, enabled = false )
58
58
59
59
/** If this type appears as an expected type of a term, does it imply
60
- * that the term should be boxed? ^^^ Special treat Any?
60
+ * that the term should be boxed?
61
+ * ^^^ Special treat Any? - but the current status is more conservative in that
62
+ * it counts free variables in expressions that have Any as expected type.
61
63
*/
62
64
def needsBox (using Context ): Boolean = tp match
63
65
case _ : TypeVar => true
@@ -73,25 +75,15 @@ object CaptureOps:
73
75
case _ => false
74
76
75
77
def canHaveInferredCapture (using Context ): Boolean = tp match
76
- case tp : CapturingType =>
77
- false
78
- case tp : TypeRef =>
79
- if tp.symbol.isClass then
80
- ! tp.symbol.isValueClass && tp.symbol != defn.AnyClass
81
- else
82
- tp.underlying.canHaveInferredCapture
78
+ case tp : TypeRef if tp.symbol.isClass =>
79
+ ! tp.symbol.isValueClass && tp.symbol != defn.AnyClass
83
80
case tp : TypeProxy =>
84
- tp.underlying .canHaveInferredCapture
81
+ tp.superType .canHaveInferredCapture
85
82
case tp : AndType =>
86
83
tp.tp1.canHaveInferredCapture && tp.tp2.canHaveInferredCapture
87
84
case tp : OrType =>
88
85
tp.tp1.canHaveInferredCapture || tp.tp2.canHaveInferredCapture
89
86
case _ =>
90
87
false
91
88
92
- def addCaptureVars (using Context ): Type =
93
- if ctx.settings.Ycc .value && canHaveInferredCapture then
94
- CapturingType (tp, CaptureSet .Var ()) // ^^^ go deep
95
- else
96
- tp
97
89
end CaptureOps
0 commit comments