@@ -1542,43 +1542,42 @@ and AddConstraint (csenv:ConstraintSolverEnv) ndeep m2 trace tp newConstraint =
15421542 TyparConstraint.MayResolveMember( trait2,_) ->
15431543 traitsAEquiv g aenv trait1 trait2
15441544
1545- | TyparConstraint.CoercesTo( ty1,_), TyparConstraint.CoercesTo( ty2,_) ->
1545+ | TyparConstraint.CoercesTo( ty1,_), TyparConstraint.CoercesTo( ty2,_) ->
15461546 ExistsSameHeadTypeInHierarchy g amap m ty1 ty2
15471547
1548- | TyparConstraint.IsEnum( u1,_), TyparConstraint.IsEnum( u2,_) -> typeEquiv g u1 u2
1548+ | TyparConstraint.IsEnum( u1,_), TyparConstraint.IsEnum( u2,_) -> typeEquiv g u1 u2
15491549
1550- | TyparConstraint.IsDelegate( aty1, bty1,_), TyparConstraint.IsDelegate( aty2, bty2,_) ->
1550+ | TyparConstraint.IsDelegate( aty1, bty1,_), TyparConstraint.IsDelegate( aty2, bty2,_) ->
15511551 typeEquiv g aty1 aty2&& typeEquiv g bty1 bty2
15521552
1553- | TyparConstraint.SupportsComparison_, TyparConstraint.SupportsComparison_
1554- | TyparConstraint.SupportsEquality_, TyparConstraint.SupportsEquality_
1553+ | TyparConstraint.SupportsComparison_, TyparConstraint.SupportsComparison_
1554+ | TyparConstraint.SupportsEquality_, TyparConstraint.SupportsEquality_
15551555// comparison implies equality
1556- | TyparConstraint.SupportsComparison_, TyparConstraint.SupportsEquality_
1557- | TyparConstraint.SupportsNull_, TyparConstraint.SupportsNull_
1558- | TyparConstraint.IsNonNullableStruct_, TyparConstraint.IsNonNullableStruct_
1556+ | TyparConstraint.SupportsComparison_, TyparConstraint.SupportsEquality_
1557+ | TyparConstraint.SupportsNull_, TyparConstraint.SupportsNull_
1558+ | TyparConstraint.IsNonNullableStruct_, TyparConstraint.IsNonNullableStruct_
15591559| TyparConstraint.IsUnmanaged_, TyparConstraint.IsUnmanaged_
1560- | TyparConstraint.IsReferenceType_, TyparConstraint.IsReferenceType_
1561- | TyparConstraint.RequiresDefaultConstructor_, TyparConstraint.RequiresDefaultConstructor_ -> true
1562- | TyparConstraint.SimpleChoice( tys1,_), TyparConstraint.SimpleChoice( tys2,_) -> ListSet.isSubsetOf( typeEquiv g) tys1 tys2
1560+ | TyparConstraint.IsReferenceType_, TyparConstraint.IsReferenceType_
1561+ | TyparConstraint.RequiresDefaultConstructor_, TyparConstraint.RequiresDefaultConstructor_ -> true
1562+ | TyparConstraint.SimpleChoice( tys1,_), TyparConstraint.SimpleChoice( tys2,_) -> ListSet.isSubsetOf( typeEquiv g) tys1 tys2
15631563| TyparConstraint.DefaultsTo( priority1, dty1,_), TyparConstraint.DefaultsTo( priority2, dty2,_) ->
15641564( priority1= priority2) && typeEquiv g dty1 dty2
15651565| _ -> false
1566-
15671566
15681567
15691568// First ensure constraint conforms with existing constraints
15701569// NOTE: QUADRATIC
15711570let existingConstraints = tp.Constraints
15721571
15731572let allCxs = newConstraint:: List.rev existingConstraints
1574- begin
1575- let rec enforceMutualConsistency i cxs =
1576- match cxswith
1577- | [] -> CompleteD
1578- | cx:: rest-> IterateIdxD( fun j cx2 -> if i= jthen CompleteDelse consistent cx cx2) allCxs++ ( fun () -> enforceMutualConsistency( i+ 1 ) rest)
1579-
1580- enforceMutualConsistency0 allCxs
1581- end ++ ( fun () ->
1573+
1574+ let rec enforceMutualConsistency i cxs =
1575+ match cxswith
1576+ | [] -> CompleteD
1577+ | cx:: rest-> IterateIdxD( fun j cx2 -> if i= jthen CompleteDelse consistent cx cx2) allCxs++ ( fun () -> enforceMutualConsistency( i+ 1 ) rest)
1578+
1579+ enforceMutualConsistency0 allCxs
1580+ ++ ( fun () ->
15821581
15831582let impliedByExistingConstraints = existingConstraints|> List.exists( fun tpc2 -> implies tpc2 newConstraint)
15841583
@@ -1592,7 +1591,7 @@ and AddConstraint (csenv:ConstraintSolverEnv) ndeep m2 trace tp newConstraint =
15921591elif tp.Rigidity= TyparRigidity.Rigidthen
15931592 ErrorD( ConstraintSolverMissingConstraint( denv, tp, newConstraint, m, m2))
15941593else
1595- ( // It is important that we give a warning if a constraint is missing from a
1594+ // It is important that we give a warning if a constraint is missing from a
15961595// will-be-made-rigid type variable. This is because the existence of these warnings
15971596// is relevant to the overload resolution rules (see 'candidateWarnCount' in the overload resolution
15981597// implementation). See also FSharp 1.0 bug 5461
@@ -1602,25 +1601,24 @@ and AddConstraint (csenv:ConstraintSolverEnv) ndeep m2 trace tp newConstraint =
16021601 CompleteD) ++ ( fun () ->
16031602
16041603let newConstraints =
1605- // Eliminate any constraints where one constraint implies another
1606- // Keep constraints in the left-to-right form according to the order they are asserted.
1607- // NOTE: QUADRATIC
1608- let rec eliminateRedundant cxs acc =
1609- match cxswith
1610- | [] -> acc
1611- | cx:: rest->
1612- eliminateRedundant rest( if List.exists( fun cx2 -> implies cx2 cx) accthen accelse ( cx:: acc))
1604+ // Eliminate any constraints where one constraint implies another
1605+ // Keep constraints in the left-to-right form according to the order they are asserted.
1606+ // NOTE: QUADRATIC
1607+ let rec eliminateRedundant cxs acc =
1608+ match cxswith
1609+ | [] -> acc
1610+ | cx:: rest->
1611+ eliminateRedundant rest( if List.exists( fun cx2 -> implies cx2 cx) accthen accelse ( cx:: acc))
16131612
1614- eliminateRedundant allCxs[]
1613+ eliminateRedundant allCxs[]
16151614
1616-
16171615// Write the constraint into the type variable
16181616// Record a entry in the undo trace if one is provided
16191617let d = tp.Data
16201618let orig = d.typar_ constraints
16211619 trace.Exec( fun () -> d.typar_ constraints<- newConstraints) ( fun () -> d.typar_ constraints<- orig)
16221620
1623- CompleteD)))
1621+ CompleteD))
16241622
16251623and SolveTypSupportsNull ( csenv : ConstraintSolverEnv ) ndeep m2 trace ty =
16261624let g = csenv.g