@@ -28,8 +28,12 @@ type CanCoerce =
2828[<Struct; NoComparison>]
2929type TTypeCacheKey =
3030 | TTypeCacheKey of TypeStructure * TypeStructure * CanCoerce
31- static member FromStrippedTypes ( ty1 , ty2 , canCoerce ) =
32- TTypeCacheKey( getTypeStructure ty1, getTypeStructure ty2, canCoerce)
31+ static member TryGetFromStrippedTypes ( ty1 , ty2 , canCoerce ) =
32+ let t1 , t2 = getTypeStructure ty1, getTypeStructure ty2
33+ if t1.IsPossiblyInfinite || t2.IsPossiblyInfinite then
34+ ValueNone
35+ else
36+ ValueSome ( TTypeCacheKey( t1, t2, canCoerce))
3337
3438let getTypeSubsumptionCache =
3539 let factory ( g : TcGlobals ) =
@@ -157,8 +161,10 @@ let rec TypeFeasiblySubsumesType ndeep (g: TcGlobals) (amap: ImportMap) m (ty1:
157161 List.exists ( TypeFeasiblySubsumesType ( ndeep + 1 ) g amap m ty1 NoCoerce) interfaces
158162
159163 if g.langVersion.SupportsFeature LanguageFeature.UseTypeSubsumptionCache then
160- let key = TTypeCacheKey.FromStrippedTypes( ty1, ty2, canCoerce)
161- ( getTypeSubsumptionCache g) .GetOrAdd( key, fun _ -> checkSubsumes ty1 ty2)
164+ match TTypeCacheKey.TryGetFromStrippedTypes( ty1, ty2, canCoerce) with
165+ | ValueSome key ->
166+ ( getTypeSubsumptionCache g) .GetOrAdd( key, fun _ -> checkSubsumes ty1 ty2)
167+ | _ -> checkSubsumes ty1 ty2
162168 else
163169 checkSubsumes ty1 ty2
164170
0 commit comments