Skip to content

Commit 34df7e4

Browse files
committed
Complification, the recent simplification did not flow measures / erasure striping.
1 parent 8701c47 commit 34df7e4

2 files changed

Lines changed: 38 additions & 17 deletions

File tree

src/fsharp/PostInferenceChecks.fs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -699,14 +699,13 @@ type TTypeEquality =
699699

700700
let compareTypesWithRegardToTypeVariablesAndMeasures g amap m typ1 typ2 =
701701

702-
if (typeEquiv g typ1 typ2) then ExactlyEqual else
703-
704-
let typ1 = typ1 |> stripTyEqnsWrtErasure EraseAll g |> stripMeasuresFromTType g
705-
let typ2 = typ2 |> stripTyEqnsWrtErasure EraseAll g |> stripMeasuresFromTType g
706-
if (typeEquiv g typ1 typ2 || TypesFeasiblyEquiv 0 g amap m typ1 typ2) then
707-
FeasiblyEqual
702+
if (typeEquiv g typ1 typ2) then
703+
ExactlyEqual
708704
else
709-
NotEqual
705+
if (typeEquiv g typ1 typ2 || TypesFeasiblyEquivStripMeasures g amap m typ1 typ2) then
706+
FeasiblyEqual
707+
else
708+
NotEqual
710709

711710
let CheckMultipleInterfaceInstantiations cenv (typ:TType) (interfaces:TType list) isObjectExpression m =
712711
let keyf ty = assert isAppTy cenv.g ty; (tcrefOfAppTy cenv.g ty).Stamp

src/fsharp/TypeRelations.fs

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,39 +47,61 @@ let rec TypeDefinitelySubsumesTypeNoCoercion ndeep g amap m ty1 ty2 =
4747
type 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.
83105
let 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

Comments
 (0)