Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita1ea93f

Browse files
committed
More tryDestTyparTy
1 parent6a259c8 commita1ea93f

File tree

5 files changed

+56
-56
lines changed

5 files changed

+56
-56
lines changed

‎src/fsharp/AugmentWithHashCompare.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ let MakeBindingsForEqualsAugmentation (g: TcGlobals) (tycon:Tycon) =
10681068
let recTypeDefinitelyHasEquality g ty=
10691069
if isAppTy g ty&& HasFSharpAttribute g g.attrib_NoEqualityAttribute(tcrefOfAppTy g ty).Attribsthen
10701070
false
1071-
elif isTyparTy g ty&&(destTyparTy g ty).Constraints|> List.exists(function TyparConstraint.SupportsEquality_->true|_->false)then
1071+
elif isTyparTy g ty&&(destTyparTy g ty).Constraints|> List.exists(function TyparConstraint.SupportsEquality_->true|_->false)then
10721072
true
10731073
else
10741074
match tywith

‎src/fsharp/ConstraintSolver.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ and SolveTypSubsumesTyp (csenv:ConstraintSolverEnv) ndeep m2 (trace: OptionalTra
884884
match tinstwith
885885
|[ty1arg]->
886886
letty2arg= destArrayTy g ty2
887-
SolveTypEqualsTypKeepAbbrevsWithCxsln csenv ndeep m2 trace cxsln ty1argty2arg
887+
SolveTypEqualsTypKeepAbbrevsWithCxsln csenv ndeep m2 trace cxsln ty1arg ty2arg
888888
|_-> error(InternalError("destArrayTy",m));
889889

890890
// D<inst> :> Head<_> --> C<inst'> :> Head<_> for the

‎src/fsharp/NicePrint.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ module private PrintTypes =
10341034
letlayoutMemberTypeAndConstraints denv argInfos retTy parentTyparTys=
10351035
let_,(parentTyparTys,argInfos,retTy),cxs= PrettyTypes.PrettifyTypesNM1 denv.g(parentTyparTys,argInfos,retTy)
10361036
// Filter out the parent typars, which don't get shown in the member signature
1037-
letcxs= cxs|> List.filter(fun(tp,_)->not(parentTyparTys|> List.exists(fun ty->isTyparTydenv.g ty&&typarEq tp(destTyparTy denv.g ty))))
1037+
letcxs= cxs|> List.filter(fun(tp,_)->not(parentTyparTys|> List.exists(fun ty->match tryDestTyparTydenv.g tywith Some destTypar->typarEq tpdestTypar| None->false)))
10381038
layoutPrettifiedTypesAndConstraints denv argInfos retTy cxs
10391039

10401040
// Layout: type spec - class, datatype, record, abbrev

‎src/fsharp/TypeChecker.fs‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,12 +2252,12 @@ module GeneralizationHelpers =
22522252

22532253
let lhsConstraintTypars =
22542254
allUntupledArgTys |> List.collect (fun ty ->
2255-
if isTyparTy cenv.g tythen
2256-
lettp= destTyparTy cenv.g ty
2255+
match tryDestTyparTy cenv.g tywith
2256+
| Sometp->
22572257
match relevantUniqueSubtypeConstraint tp with
22582258
| Some cxty -> freeInTypeLeftToRight cenv.g false cxty
22592259
| None -> []
2260-
else [])
2260+
| None -> [])
22612261

22622262
let IsCondensationTypar (tp:Typar) =
22632263
// A condensation typar may not a user-generated type variable nor has it been unified with any user type variable
@@ -2269,7 +2269,7 @@ module GeneralizationHelpers =
22692269
// A condensation typar can't be used in the constraints of any candidate condensation typars
22702270
not (ListSet.contains typarEq tp lhsConstraintTypars) &&
22712271
// A condensation typar must occur precisely once in tyIJ, and must not occur free in any other tyIJ
2272-
(match allUntupledArgTysWithFreeVars |> List.partition (fun (ty,_) ->isTyparTycenv.g ty&& typarEq (destTyparTy cenv.g ty) tp) with
2272+
(match allUntupledArgTysWithFreeVars |> List.partition (fun (ty,_) ->match tryDestTyparTycenv.g tywith Some destTypar -> typarEq destTypar tp | _ -> false) with
22732273
| [_], rest -> not (rest |> List.exists (fun (_,fvs) -> ListSet.contains typarEq tp fvs))
22742274
| _ -> false)
22752275

@@ -13833,9 +13833,8 @@ module TyconConstraintInference =
1383313833
let rec checkIfFieldTypeSupportsComparison (tycon: Tycon) (ty: TType) =
1383413834

1383513835
// Is the field type a type parameter?
13836-
if isTyparTy cenv.g ty then
13837-
let tp = (destTyparTy cenv.g ty)
13838-
13836+
match tryDestTyparTy cenv.g ty with
13837+
| Some tp ->
1383913838
// Look for an explicit 'comparison' constraint
1384013839
if tp.Constraints |> List.exists (function TyparConstraint.SupportsComparison _ -> true | _ -> false) then
1384113840
true
@@ -13848,8 +13847,7 @@ module TyconConstraintInference =
1384813847

1384913848
else
1385013849
false
13851-
13852-
else
13850+
| None ->
1385313851
match ty with
1385413852
// Look for array, UIntPtr and IntPtr types
1385513853
| SpecialComparableHeadType g tinst ->
@@ -13960,9 +13958,8 @@ module TyconConstraintInference =
1396013958
// Checks if a field type supports the 'equality' constraint based on the assumptions about the type constructors
1396113959
// and type parameters.
1396213960
let rec checkIfFieldTypeSupportsEquality (tycon:Tycon) (ty: TType) =
13963-
if isTyparTy cenv.g ty then
13964-
let tp = (destTyparTy cenv.g ty)
13965-
13961+
match tryDestTyparTy cenv.g ty with
13962+
| Some tp ->
1396613963
// Look for an explicit 'equality' constraint
1396713964
if tp.Constraints |> List.exists (function TyparConstraint.SupportsEquality _ -> true | _ -> false) then
1396813965
true
@@ -13974,8 +13971,7 @@ module TyconConstraintInference =
1397413971
true
1397513972
else
1397613973
false
13977-
13978-
else
13974+
| None ->
1397913975
match ty with
1398013976
| SpecialEquatableHeadType g tinst ->
1398113977
tinst |> List.forall (checkIfFieldTypeSupportsEquality tycon)
@@ -15330,9 +15326,12 @@ module EstablishTypeDefinitionCores =
1533015326
// The special case of "static field S<'a> in struct S<'a>" is permitted. (so no (S,S) edge to be collected).
1533115327
fspec.IsStatic &&
1533215328
(structTycon === tycon2) &&
15333-
(structTyInst,tinst2) ||> List.lengthsEqAndForall2 (fun ty1 ty2 -> isTyparTy cenv.g ty1 &&
15334-
isTyparTy cenv.g ty2 &&
15335-
typarEq (destTyparTy cenv.g ty1) (destTyparTy cenv.g ty2))
15329+
(structTyInst,tinst2) ||> List.lengthsEqAndForall2 (fun ty1 ty2 -> match tryDestTyparTy cenv.g ty1 with
15330+
| Some destTypar1 ->
15331+
match tryDestTyparTy cenv.g ty2 with
15332+
| Some destTypar2 -> typarEq destTypar1 destTypar2
15333+
| _ -> false
15334+
| _ -> false)
1533615335
if specialCaseStaticField then
1533715336
doneTypes,acc // no edge collected, no recursion.
1533815337
else

‎src/fsharp/infos.fs‎

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -183,43 +183,44 @@ let private FoldHierarchyOfTypeAux followInterfaces allowMultiIntfInst skipUnref
183183
(loop(ndeep+1))
184184
(GetImmediateInterfacesOfType skipUnref g amap m typ)
185185
(loop ndeep g.obj_ty state)
186-
elif isTyparTy g typthen
187-
lettp= destTyparTy g typ
188-
letstate= loop(ndeep+1) g.obj_ty state
189-
List.foldBack
190-
(fun x vacc->
191-
match xwith
192-
| TyparConstraint.MayResolveMember_
193-
| TyparConstraint.DefaultsTo_
194-
| TyparConstraint.SupportsComparison_
195-
| TyparConstraint.SupportsEquality_
196-
| TyparConstraint.IsEnum_
197-
| TyparConstraint.IsDelegate_
198-
| TyparConstraint.SupportsNull_
199-
| TyparConstraint.IsNonNullableStruct_
200-
| TyparConstraint.IsUnmanaged_
201-
| TyparConstraint.IsReferenceType_
202-
| TyparConstraint.SimpleChoice_
203-
| TyparConstraint.RequiresDefaultConstructor_-> vacc
204-
| TyparConstraint.CoercesTo(cty,_)->
205-
loop(ndeep+1) cty vacc)
206-
tp.Constraints
207-
state
208-
else
209-
letstate=
210-
if followInterfacesthen
211-
List.foldBack
212-
(loop(ndeep+1))
213-
(GetImmediateInterfacesOfType skipUnref g amap m typ)
214-
state
215-
else
186+
else
187+
match tryDestTyparTy g typwith
188+
| Some tp->
189+
letstate= loop(ndeep+1) g.obj_ty state
190+
List.foldBack
191+
(fun x vacc->
192+
match xwith
193+
| TyparConstraint.MayResolveMember_
194+
| TyparConstraint.DefaultsTo_
195+
| TyparConstraint.SupportsComparison_
196+
| TyparConstraint.SupportsEquality_
197+
| TyparConstraint.IsEnum_
198+
| TyparConstraint.IsDelegate_
199+
| TyparConstraint.SupportsNull_
200+
| TyparConstraint.IsNonNullableStruct_
201+
| TyparConstraint.IsUnmanaged_
202+
| TyparConstraint.IsReferenceType_
203+
| TyparConstraint.SimpleChoice_
204+
| TyparConstraint.RequiresDefaultConstructor_-> vacc
205+
| TyparConstraint.CoercesTo(cty,_)->
206+
loop(ndeep+1) cty vacc)
207+
tp.Constraints
216208
state
217-
letstate=
218-
Option.foldBack
219-
(loop(ndeep+1))
220-
(GetSuperTypeOfType g amap m typ)
221-
state
222-
state
209+
| None->
210+
letstate=
211+
if followInterfacesthen
212+
List.foldBack
213+
(loop(ndeep+1))
214+
(GetImmediateInterfacesOfType skipUnref g amap m typ)
215+
state
216+
else
217+
state
218+
letstate=
219+
Option.foldBack
220+
(loop(ndeep+1))
221+
(GetSuperTypeOfType g amap m typ)
222+
state
223+
state
223224
letacc= visitor typ acc
224225
(visitedTycon,visited,acc)
225226
loop0 typ(Set.empty,TyconRefMultiMap<_>.Empty,acc)|> p33

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp