Skip to content

Commit 01e5bbb

Browse files
authored
More cleanup (#13109)
* cleanup * cleanup * cleanup * cleanup * cleanup * cleanup * cleanup * cleanup * cleanup * cleanup * cleanup * cleanup
1 parent f9b7206 commit 01e5bbb

File tree

126 files changed

+2555
-2198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+2555
-2198
lines changed

src/fsharp/AttributeChecking.fs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ type AttribInfo =
100100
ty, obj)
101101
| ILAttribInfo (_g, amap, scoref, cattr, m) ->
102102
let parms, _args = decodeILAttribData cattr
103-
[ for argty, argval in Seq.zip cattr.Method.FormalArgTypes parms ->
104-
let ty = ImportILType scoref amap m [] argty
105-
let obj = evalILAttribElem argval
103+
[ for argTy, arg in Seq.zip cattr.Method.FormalArgTypes parms ->
104+
let ty = ImportILType scoref amap m [] argTy
105+
let obj = evalILAttribElem arg
106106
ty, obj ]
107107

108108
member x.NamedArguments =
@@ -115,9 +115,9 @@ type AttribInfo =
115115
ty, nm, isField, obj)
116116
| ILAttribInfo (_g, amap, scoref, cattr, m) ->
117117
let _parms, namedArgs = decodeILAttribData cattr
118-
[ for nm, argty, isProp, argval in namedArgs ->
119-
let ty = ImportILType scoref amap m [] argty
120-
let obj = evalILAttribElem argval
118+
[ for nm, argTy, isProp, arg in namedArgs ->
119+
let ty = ImportILType scoref amap m [] argTy
120+
let obj = evalILAttribElem arg
121121
let isField = not isProp
122122
ty, nm, isField, obj ]
123123

@@ -251,7 +251,7 @@ let langVersionPrefix = "--langversion:preview"
251251
/// returning errors and warnings as data
252252
let CheckFSharpAttributes (g:TcGlobals) attribs m =
253253
let isExperimentalAttributeDisabled (s:string) =
254-
if g.compilingFslib then
254+
if g.compilingFSharpCore then
255255
true
256256
else
257257
g.langVersion.IsPreviewEnabled && (s.IndexOf(langVersionPrefix, StringComparison.OrdinalIgnoreCase) >= 0)
@@ -282,7 +282,7 @@ let CheckFSharpAttributes (g:TcGlobals) attribs m =
282282
// If we are using a compiler that supports nameof then error 3501 is always suppressed.
283283
// See attribute on FSharp.Core 'nameof'
284284
if n = 3501 then CompleteD
285-
elif isError && (not g.compilingFslib || n <> 1204) then ErrorD msg
285+
elif isError && (not g.compilingFSharpCore || n <> 1204) then ErrorD msg
286286
else WarnD msg
287287
| _ ->
288288
CompleteD

src/fsharp/AugmentWithHashCompare.fs

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,9 @@ let mkRecdCompare g tcref (tycon: Tycon) =
205205
let thisv, thataddrv, thise, thataddre = mkThisVarThatVar g m ty
206206
let compe = mkILCallGetComparer g m
207207
let mkTest (fspec: RecdField) =
208-
let fty = fspec.FormalType
209208
let fref = tcref.MakeNestedRecdFieldRef fspec
210209
let m = fref.Range
211-
mkCallGenericComparisonWithComparerOuter g m fty
210+
mkCallGenericComparisonWithComparerOuter g m fspec.FormalType
212211
compe
213212
(mkRecdFieldGetViaExprAddr (thise, fref, tinst, m))
214213
(mkRecdFieldGetViaExprAddr (thataddre, fref, tinst, m))
@@ -228,10 +227,9 @@ let mkRecdCompareWithComparer g tcref (tycon: Tycon) (_thisv, thise) (_, thate)
228227
let thataddrv, thataddre = mkThatAddrLocal g m ty // let thataddrv = &tcv, if a struct
229228

230229
let mkTest (fspec: RecdField) =
231-
let fty = fspec.FormalType
232230
let fref = tcref.MakeNestedRecdFieldRef fspec
233231
let m = fref.Range
234-
mkCallGenericComparisonWithComparerOuter g m fty
232+
mkCallGenericComparisonWithComparerOuter g m fspec.FormalType
235233
compe
236234
(mkRecdFieldGetViaExprAddr (thise, fref, tinst, m))
237235
(mkRecdFieldGetViaExprAddr (thataddre, fref, tinst, m))
@@ -251,10 +249,9 @@ let mkRecdEquality g tcref (tycon: Tycon) =
251249
let tinst, ty = mkMinimalTy g tcref
252250
let thisv, thataddrv, thise, thataddre = mkThisVarThatVar g m ty
253251
let mkTest (fspec: RecdField) =
254-
let fty = fspec.FormalType
255252
let fref = tcref.MakeNestedRecdFieldRef fspec
256253
let m = fref.Range
257-
mkCallGenericEqualityEROuter g m fty
254+
mkCallGenericEqualityEROuter g m fspec.FormalType
258255
(mkRecdFieldGetViaExprAddr (thise, fref, tinst, m))
259256
(mkRecdFieldGetViaExprAddr (thataddre, fref, tinst, m))
260257
let expr = mkEqualsTestConjuncts g m (List.map mkTest fields)
@@ -272,11 +269,10 @@ let mkRecdEqualityWithComparer g tcref (tycon: Tycon) (_thisv, thise) thatobje (
272269
let thataddrv, thataddre = mkThatAddrLocal g m ty
273270

274271
let mkTest (fspec: RecdField) =
275-
let fty = fspec.FormalType
276272
let fref = tcref.MakeNestedRecdFieldRef fspec
277273
let m = fref.Range
278274

279-
mkCallGenericEqualityWithComparerOuter g m fty
275+
mkCallGenericEqualityWithComparerOuter g m fspec.FormalType
280276
compe
281277
(mkRecdFieldGetViaExprAddr (thise, fref, tinst, m))
282278
(mkRecdFieldGetViaExprAddr (thataddre, fref, tinst, m))
@@ -295,8 +291,7 @@ let mkExnEquality (g: TcGlobals) exnref (exnc: Tycon) =
295291
let thatv, thate = mkCompGenLocal m "obj" g.exn_ty
296292
let thisv, thise = mkThisVar g m g.exn_ty
297293
let mkTest i (rfield: RecdField) =
298-
let fty = rfield.FormalType
299-
mkCallGenericEqualityEROuter g m fty
294+
mkCallGenericEqualityEROuter g m rfield.FormalType
300295
(mkExnCaseFieldGet(thise, exnref, i, m))
301296
(mkExnCaseFieldGet(thate, exnref, i, m))
302297
let expr = mkEqualsTestConjuncts g m (List.mapi mkTest exnc.AllInstanceFieldsAsList)
@@ -317,8 +312,7 @@ let mkExnEqualityWithComparer g exnref (exnc: Tycon) (_thisv, thise) thatobje (t
317312
let m = exnc.Range
318313
let thataddrv, thataddre = mkThatAddrLocal g m g.exn_ty
319314
let mkTest i (rfield: RecdField) =
320-
let fty = rfield.FormalType
321-
mkCallGenericEqualityWithComparerOuter g m fty
315+
mkCallGenericEqualityWithComparerOuter g m rfield.FormalType
322316
compe
323317
(mkExnCaseFieldGet(thise, exnref, i, m))
324318
(mkExnCaseFieldGet(thataddre, exnref, i, m))
@@ -353,8 +347,8 @@ let mkUnionCompare g tcref (tycon: Tycon) =
353347
let m = cref.Range
354348
let rfields = ucase.RecdFields
355349
if isNil rfields then None else
356-
let mkTest thise thataddre j (argty: RecdField) =
357-
mkCallGenericComparisonWithComparerOuter g m argty.FormalType
350+
let mkTest thise thataddre j (fld: RecdField) =
351+
mkCallGenericComparisonWithComparerOuter g m fld.FormalType
358352
compe
359353
(mkUnionCaseFieldGetProvenViaExprAddr (thise, cref, tinst, j, m))
360354
(mkUnionCaseFieldGetProvenViaExprAddr (thataddre, cref, tinst, j, m))
@@ -413,8 +407,8 @@ let mkUnionCompareWithComparer g tcref (tycon: Tycon) (_thisv, thise) (_thatobjv
413407
let rfields = ucase.RecdFields
414408
if isNil rfields then None else
415409

416-
let mkTest thise thataddre j (argty: RecdField) =
417-
mkCallGenericComparisonWithComparerOuter g m argty.FormalType
410+
let mkTest thise thataddre j (fld: RecdField) =
411+
mkCallGenericComparisonWithComparerOuter g m fld.FormalType
418412
compe
419413
(mkUnionCaseFieldGetProvenViaExprAddr (thise, cref, tinst, j, m))
420414
(mkUnionCaseFieldGetProvenViaExprAddr (thataddre, cref, tinst, j, m))
@@ -475,8 +469,8 @@ let mkUnionEquality g tcref (tycon: Tycon) =
475469
let rfields = ucase.RecdFields
476470
if isNil rfields then None else
477471

478-
let mkTest thise thataddre j (argty: RecdField) =
479-
mkCallGenericEqualityEROuter g m argty.FormalType
472+
let mkTest thise thataddre j (fld: RecdField) =
473+
mkCallGenericEqualityEROuter g m fld.FormalType
480474
(mkUnionCaseFieldGetProvenViaExprAddr (thise, cref, tinst, j, m))
481475
(mkUnionCaseFieldGetProvenViaExprAddr (thataddre, cref, tinst, j, m))
482476

@@ -536,8 +530,8 @@ let mkUnionEqualityWithComparer g tcref (tycon: Tycon) (_thisv, thise) thatobje
536530
let rfields = ucase.RecdFields
537531
if isNil rfields then None else
538532

539-
let mkTest thise thataddre j (argty: RecdField) =
540-
mkCallGenericEqualityWithComparerOuter g m argty.FormalType
533+
let mkTest thise thataddre j (fld: RecdField) =
534+
mkCallGenericEqualityWithComparerOuter g m fld.FormalType
541535
compe
542536
(mkUnionCaseFieldGetProvenViaExprAddr (thise, cref, tinst, j, m))
543537
(mkUnionCaseFieldGetProvenViaExprAddr (thataddre, cref, tinst, j, m))
@@ -593,12 +587,11 @@ let mkRecdHashWithComparer g tcref (tycon: Tycon) compe =
593587
let tinst, ty = mkMinimalTy g tcref
594588
let thisv, thise = mkThisVar g m ty
595589
let mkFieldHash (fspec: RecdField) =
596-
let fty = fspec.FormalType
597590
let fref = tcref.MakeNestedRecdFieldRef fspec
598591
let m = fref.Range
599592
let e = mkRecdFieldGetViaExprAddr (thise, fref, tinst, m)
600593

601-
mkCallGenericHashWithComparerOuter g m fty compe e
594+
mkCallGenericHashWithComparerOuter g m fspec.FormalType compe e
602595

603596
let accv, acce = mkMutableCompGenLocal m "i" g.int_ty
604597
let stmt = mkCombineHashGenerators g m (List.map mkFieldHash fields) (mkLocalValRef accv) acce
@@ -612,10 +605,9 @@ let mkExnHashWithComparer g exnref (exnc: Tycon) compe =
612605
let thisv, thise = mkThisVar g m g.exn_ty
613606

614607
let mkHash i (rfield: RecdField) =
615-
let fty = rfield.FormalType
616608
let e = mkExnCaseFieldGet(thise, exnref, i, m)
617609

618-
mkCallGenericHashWithComparerOuter g m fty compe e
610+
mkCallGenericHashWithComparerOuter g m rfield.FormalType compe e
619611

620612
let accv, acce = mkMutableCompGenLocal m "i" g.int_ty
621613
let stmt = mkCombineHashGenerators g m (List.mapi mkHash exnc.AllInstanceFieldsAsList) (mkLocalValRef accv) acce
@@ -637,9 +629,8 @@ let mkUnionHashWithComparer g tcref (tycon: Tycon) compe =
637629
if ucase1.IsNullary then None
638630
else
639631
let mkHash thise j (rfield: RecdField) =
640-
let fty = rfield.FormalType
641632
let e = mkUnionCaseFieldGetProvenViaExprAddr (thise, c1ref, tinst, j, m)
642-
mkCallGenericHashWithComparerOuter g m fty compe e
633+
mkCallGenericHashWithComparerOuter g m rfield.FormalType compe e
643634

644635
let test =
645636
if tycon.IsStructOrEnumTycon then
@@ -826,7 +817,7 @@ let CheckAugmentationAttribs isImplementation g amap (tycon: Tycon) =
826817

827818
let TyconIsCandidateForAugmentationWithCompare (g: TcGlobals) (tycon: Tycon) =
828819
// This type gets defined in prim-types, before we can add attributes to F# type definitions
829-
let isUnit = g.compilingFslib && tycon.DisplayName = "Unit"
820+
let isUnit = g.compilingFSharpCore && tycon.DisplayName = "Unit"
830821
not isUnit &&
831822
not (isByrefLikeTyconRef g tycon.Range (mkLocalTyconRef tycon)) &&
832823
match getAugmentationAttribs g tycon with
@@ -841,7 +832,7 @@ let TyconIsCandidateForAugmentationWithCompare (g: TcGlobals) (tycon: Tycon) =
841832

842833
let TyconIsCandidateForAugmentationWithEquals (g: TcGlobals) (tycon: Tycon) =
843834
// This type gets defined in prim-types, before we can add attributes to F# type definitions
844-
let isUnit = g.compilingFslib && tycon.DisplayName = "Unit"
835+
let isUnit = g.compilingFSharpCore && tycon.DisplayName = "Unit"
845836
not isUnit &&
846837
not (isByrefLikeTyconRef g tycon.Range (mkLocalTyconRef tycon)) &&
847838

@@ -885,55 +876,58 @@ let nonVirtualMethod c : ValMemberInfo =
885876
ApparentEnclosingEntity=c}
886877

887878
let unitArg = ValReprInfo.unitArgData
879+
888880
let unaryArg = [ ValReprInfo.unnamedTopArg ]
881+
889882
let tupArg = [ [ ValReprInfo.unnamedTopArg1; ValReprInfo.unnamedTopArg1 ] ]
890-
let mkValSpec g (tcref: TyconRef) tmty vis slotsig methn ty argData =
883+
884+
let mkValSpec g (tcref: TyconRef) ty vis slotsig methn valTy argData =
891885
let m = tcref.Range
892886
let tps = tcref.Typars m
893887
let membInfo =
894888
match slotsig with
895889
| None -> nonVirtualMethod tcref
896890
| Some slotsig ->
897-
let final = isUnionTy g tmty || isRecdTy g tmty || isStructTy g tmty
891+
let final = isUnionTy g ty || isRecdTy g ty || isStructTy g ty
898892
slotImplMethod(final, tcref, slotsig)
899893
let inl = ValInline.Optional
900894
let args = ValReprInfo.unnamedTopArg :: argData
901895
let topValInfo = Some (ValReprInfo (ValReprInfo.InferTyparInfo tps, args, ValReprInfo.unnamedRetVal))
902-
Construct.NewVal (methn, m, None, ty, Immutable, true, topValInfo, vis, ValNotInRecScope, Some membInfo, NormalVal, [], inl, XmlDoc.Empty, true, false, false, false, false, false, None, Parent tcref)
896+
Construct.NewVal (methn, m, None, valTy, Immutable, true, topValInfo, vis, ValNotInRecScope, Some membInfo, NormalVal, [], inl, XmlDoc.Empty, true, false, false, false, false, false, None, Parent tcref)
903897

904898
let MakeValsForCompareAugmentation g (tcref: TyconRef) =
905899
let m = tcref.Range
906-
let _, tmty = mkMinimalTy g tcref
900+
let _, ty = mkMinimalTy g tcref
907901
let tps = tcref.Typars m
908902
let vis = tcref.TypeReprAccessibility
909903

910-
mkValSpec g tcref tmty vis (Some(mkIComparableCompareToSlotSig g)) "CompareTo" (tps +-> (mkCompareObjTy g tmty)) unaryArg,
911-
mkValSpec g tcref tmty vis (Some(mkGenericIComparableCompareToSlotSig g tmty)) "CompareTo" (tps +-> (mkCompareTy g tmty)) unaryArg
904+
mkValSpec g tcref ty vis (Some(mkIComparableCompareToSlotSig g)) "CompareTo" (tps +-> (mkCompareObjTy g ty)) unaryArg,
905+
mkValSpec g tcref ty vis (Some(mkGenericIComparableCompareToSlotSig g ty)) "CompareTo" (tps +-> (mkCompareTy g ty)) unaryArg
912906

913907
let MakeValsForCompareWithComparerAugmentation g (tcref: TyconRef) =
914908
let m = tcref.Range
915-
let _, tmty = mkMinimalTy g tcref
909+
let _, ty = mkMinimalTy g tcref
916910
let tps = tcref.Typars m
917911
let vis = tcref.TypeReprAccessibility
918-
mkValSpec g tcref tmty vis (Some(mkIStructuralComparableCompareToSlotSig g)) "CompareTo" (tps +-> (mkCompareWithComparerTy g tmty)) tupArg
912+
mkValSpec g tcref ty vis (Some(mkIStructuralComparableCompareToSlotSig g)) "CompareTo" (tps +-> (mkCompareWithComparerTy g ty)) tupArg
919913

920914
let MakeValsForEqualsAugmentation g (tcref: TyconRef) =
921915
let m = tcref.Range
922-
let _, tmty = mkMinimalTy g tcref
916+
let _, ty = mkMinimalTy g tcref
923917
let vis = tcref.TypeReprAccessibility
924918
let tps = tcref.Typars m
925919

926-
let objEqualsVal = mkValSpec g tcref tmty vis (Some(mkEqualsSlotSig g)) "Equals" (tps +-> (mkEqualsObjTy g tmty)) unaryArg
927-
let nocEqualsVal = mkValSpec g tcref tmty vis (if tcref.Deref.IsExceptionDecl then None else Some(mkGenericIEquatableEqualsSlotSig g tmty)) "Equals" (tps +-> (mkEqualsTy g tmty)) unaryArg
920+
let objEqualsVal = mkValSpec g tcref ty vis (Some(mkEqualsSlotSig g)) "Equals" (tps +-> (mkEqualsObjTy g ty)) unaryArg
921+
let nocEqualsVal = mkValSpec g tcref ty vis (if tcref.Deref.IsExceptionDecl then None else Some(mkGenericIEquatableEqualsSlotSig g ty)) "Equals" (tps +-> (mkEqualsTy g ty)) unaryArg
928922
objEqualsVal, nocEqualsVal
929923

930924
let MakeValsForEqualityWithComparerAugmentation g (tcref: TyconRef) =
931-
let _, tmty = mkMinimalTy g tcref
925+
let _, ty = mkMinimalTy g tcref
932926
let vis = tcref.TypeReprAccessibility
933927
let tps = tcref.Typars tcref.Range
934-
let objGetHashCodeVal = mkValSpec g tcref tmty vis (Some(mkGetHashCodeSlotSig g)) "GetHashCode" (tps +-> (mkHashTy g tmty)) unitArg
935-
let withcGetHashCodeVal = mkValSpec g tcref tmty vis (Some(mkIStructuralEquatableGetHashCodeSlotSig g)) "GetHashCode" (tps +-> (mkHashWithComparerTy g tmty)) unaryArg
936-
let withcEqualsVal = mkValSpec g tcref tmty vis (Some(mkIStructuralEquatableEqualsSlotSig g)) "Equals" (tps +-> (mkEqualsWithComparerTy g tmty)) tupArg
928+
let objGetHashCodeVal = mkValSpec g tcref ty vis (Some(mkGetHashCodeSlotSig g)) "GetHashCode" (tps +-> (mkHashTy g ty)) unitArg
929+
let withcGetHashCodeVal = mkValSpec g tcref ty vis (Some(mkIStructuralEquatableGetHashCodeSlotSig g)) "GetHashCode" (tps +-> (mkHashWithComparerTy g ty)) unaryArg
930+
let withcEqualsVal = mkValSpec g tcref ty vis (Some(mkIStructuralEquatableEqualsSlotSig g)) "Equals" (tps +-> (mkEqualsWithComparerTy g ty)) tupArg
937931
objGetHashCodeVal, withcGetHashCodeVal, withcEqualsVal
938932

939933
let MakeBindingsForCompareAugmentation g (tycon: Tycon) =

src/fsharp/CheckComputationExpressions.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,7 +2166,7 @@ let TcSequenceExpressionEntry (cenv: cenv) env (overallTy: OverallTy) tpenv (has
21662166
| _ ->
21672167
()
21682168

2169-
if not hasBuilder && not cenv.g.compilingFslib then
2169+
if not hasBuilder && not cenv.g.compilingFSharpCore then
21702170
error(Error(FSComp.SR.tcInvalidSequenceExpressionSyntaxForm(), m))
21712171

21722172
TcSequenceExpression cenv env tpenv comp overallTy m
@@ -2191,7 +2191,7 @@ let TcArrayOrListComputedExpression (cenv: cenv) env (overallTy: OverallTy) tpen
21912191
let expr, tpenv = TcExpr cenv (MustEqual exprTy) env tpenv replacementExpr
21922192

21932193
let expr =
2194-
if cenv.g.compilingFslib then
2194+
if cenv.g.compilingFSharpCore then
21952195
expr
21962196
else
21972197
// We add a call to 'seq ... ' to make sure sequence expression compilation gets applied to the contents of the
@@ -2257,7 +2257,7 @@ let TcArrayOrListComputedExpression (cenv: cenv) env (overallTy: OverallTy) tpen
22572257
let expr = mkCoerceIfNeeded cenv.g exprTy (tyOfExpr cenv.g expr) expr
22582258

22592259
let expr =
2260-
if cenv.g.compilingFslib then
2260+
if cenv.g.compilingFSharpCore then
22612261
//warning(Error(FSComp.SR.fslibUsingComputedListOrArray(), expr.Range))
22622262
expr
22632263
else

0 commit comments

Comments
 (0)