File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,16 @@ object CapturingType:
4848 EventuallyCapturingType .unapply(tp)
4949 else None
5050
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 capture 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+
5161end CapturingType
5262
5363/** 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 {
21402140 final def baseTypeOf (tp : Type )(using Context ): Type = {
21412141 val btrCache = baseTypeCache
21422142 def inCache (tp : Type ) = tp match
2143- case EventuallyCapturingType (_, _) => false
21442143 case tp : CachedType => btrCache.contains(tp)
21452144 case _ => false
21462145 def record (tp : CachedType , baseTp : Type ) = {
21472146 if (Stats .monitored) {
21482147 Stats .record(" basetype cache entries" )
21492148 if (! baseTp.exists) Stats .record(" basetype cache NoTypes" )
21502149 }
2151- if (! tp.isProvisional && ! tp.isEventuallyCapturingType && ! Setup .isDuringSetup )
2150+ if (! tp.isProvisional && ! CapturingType .isUncachable(tp) )
21522151 btrCache(tp) = baseTp
21532152 else
21542153 btrCache.remove(tp) // Remove any potential sentinel value
You can’t perform that action at this time.
0 commit comments