File tree 2 files changed +11
-2
lines changed
compiler/src/dotty/tools/dotc
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,16 @@ object CapturingType:
48
48
EventuallyCapturingType .unapply(tp)
49
49
else None
50
50
51
+ /** Check whether a type is uncachable when computing `baseType`.
52
+ * - Avoid caching all the types during the setup phase, since at that point
53
+ * the captrue set variables are not fully installed yet.
54
+ * - Avoid caching capturing types when IgnoreCaptures mode is set, since the
55
+ * capture sets may be thrown away in the computed base type.
56
+ */
57
+ def isUncachable (tp : Type )(using Context ): Boolean =
58
+ ctx.phase == Phases .checkCapturesPhase &&
59
+ (Setup .isDuringSetup || ctx.mode.is(Mode .IgnoreCaptures ) && tp.isEventuallyCapturingType)
60
+
51
61
end CapturingType
52
62
53
63
/** An extractor for types that will be capturing types at phase CheckCaptures. Also
Original file line number Diff line number Diff line change @@ -2140,15 +2140,14 @@ object SymDenotations {
2140
2140
final def baseTypeOf (tp : Type )(using Context ): Type = {
2141
2141
val btrCache = baseTypeCache
2142
2142
def inCache (tp : Type ) = tp match
2143
- case EventuallyCapturingType (_, _) => false
2144
2143
case tp : CachedType => btrCache.contains(tp)
2145
2144
case _ => false
2146
2145
def record (tp : CachedType , baseTp : Type ) = {
2147
2146
if (Stats .monitored) {
2148
2147
Stats .record(" basetype cache entries" )
2149
2148
if (! baseTp.exists) Stats .record(" basetype cache NoTypes" )
2150
2149
}
2151
- if (! tp.isProvisional && ! tp.isEventuallyCapturingType && ! Setup .isDuringSetup )
2150
+ if (! tp.isProvisional && ! CapturingType .isUncachable(tp) )
2152
2151
btrCache(tp) = baseTp
2153
2152
else
2154
2153
btrCache.remove(tp) // Remove any potential sentinel value
You can’t perform that action at this time.
0 commit comments