@@ -47,39 +47,61 @@ let rec TypeDefinitelySubsumesTypeNoCoercion ndeep g amap m ty1 ty2 =
4747type CanCoerce = CanCoerce | NoCoerce
4848
4949/// The feasible equivalence relation. Part of the language spec.
50- let rec TypesFeasiblyEquiv ndeep g amap m ty1 ty2 =
50+ let rec TypesFeasiblyEquivalent stripMeasures ndeep g amap m ty1 ty2 =
5151
5252 if ndeep > 100 then error( InternalError( " recursive class hierarchy (detected in TypeFeasiblySubsumesType), ty1 = " + ( DebugPrint.showType ty1), m));
53- let ty1 = stripTyEqns g ty1
54- let ty2 = stripTyEqns g ty2
55- match ty1, ty2 with
53+ let stripAll ty =
54+ if stripMeasures then
55+ ty |> stripTyEqnsWrtErasure EraseAll g |> stripMeasuresFromTType g
56+ else
57+ ty |> stripTyEqns g
58+
59+ let ty1str = stripAll ty1
60+ let ty2str = stripAll ty2
61+
62+ let _found , _tc_eq =
63+ match ty1str, ty2str with
64+ | TType_ app ( tc1, _ l1), TType_ app ( tc2, _ l2) ->
65+ let tc1_local = tc1
66+ let tc2_local = tc2
67+ true , tyconRefEq g tc1_ local tc2_ local
68+ | _ -> false , false
69+
70+ match ty1str, ty2str with
5671 | TType_ var _, _
5772 | _, TType_ var _ -> true
5873
59- | TType_ app ( tc1, l1), TType_ app ( tc2, l2) when tyconRefEq g tc1 tc2 ->
60- List.lengthsEqAndForall2 ( TypesFeasiblyEquiv ndeep g amap m) l1 l2
74+ | TType_ app ( tc1, l1), TType_ app ( tc2, l2) when tyconRefEq g tc1 tc2 ->
75+ List.lengthsEqAndForall2 ( TypesFeasiblyEquivalent stripMeasures ndeep g amap m) l1 l2
6176
6277 | TType_ anon ( anonInfo1, l1), TType_ anon ( anonInfo2, l2) ->
6378 ( evalTupInfoIsStruct anonInfo1.TupInfo = evalTupInfoIsStruct anonInfo2.TupInfo) &&
6479 ( match anonInfo1.Assembly, anonInfo2.Assembly with ccu1, ccu2 -> ccuEq ccu1 ccu2) &&
6580 ( anonInfo1.SortedNames = anonInfo2.SortedNames) &&
66- List.lengthsEqAndForall2 ( TypesFeasiblyEquiv ndeep g amap m) l1 l2
81+ List.lengthsEqAndForall2 ( TypesFeasiblyEquivalent stripMeasures ndeep g amap m) l1 l2
6782
6883 | TType_ tuple ( tupInfo1, l1), TType_ tuple ( tupInfo2, l2) ->
6984 evalTupInfoIsStruct tupInfo1 = evalTupInfoIsStruct tupInfo2 &&
70- List.lengthsEqAndForall2 ( TypesFeasiblyEquiv ndeep g amap m) l1 l2
85+ List.lengthsEqAndForall2 ( TypesFeasiblyEquivalent stripMeasures ndeep g amap m) l1 l2
7186
7287 | TType_ fun ( d1, r1), TType_ fun ( d2, r2) ->
73- ( TypesFeasiblyEquiv ndeep g amap m) d1 d2 && ( TypesFeasiblyEquiv ndeep g amap m) r1 r2
88+ ( TypesFeasiblyEquivalent stripMeasures ndeep g amap m) d1 d2 && ( TypesFeasiblyEquivalent stripMeasures ndeep g amap m) r1 r2
7489
7590 | TType_ measure _, TType_ measure _ ->
7691 true
7792
7893 | _ ->
7994 false
8095
81- /// The feasible coercion relation. Part of the language spec.
96+ /// The feasible equivalence relation. Part of the language spec.
97+ let rec TypesFeasiblyEquiv ndeep g amap m ty1 ty2 =
98+ TypesFeasiblyEquivalent false ndeep g amap m ty1 ty2
8299
100+ /// The feasible equivalence relation after stripping Measures.
101+ let TypesFeasiblyEquivStripMeasures g amap m ty1 ty2 =
102+ TypesFeasiblyEquivalent true 0 g amap m ty1 ty2
103+
104+ /// The feasible coercion relation. Part of the language spec.
83105let rec TypeFeasiblySubsumesType ndeep g amap m ty1 canCoerce ty2 =
84106 if ndeep > 100 then error( InternalError( " recursive class hierarchy (detected in TypeFeasiblySubsumesType), ty1 = " + ( DebugPrint.showType ty1), m))
85107 let ty1 = stripTyEqns g ty1
0 commit comments