Skip to content

Commit 8ac5131

Browse files
authored
Cleanup: remove redundant qualifiers, parens, opens, 'new' keywords (#19002)
1 parent 3828c87 commit 8ac5131

File tree

228 files changed

+2256
-2574
lines changed

Some content is hidden

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

228 files changed

+2256
-2574
lines changed

src/Compiler/AbstractIL/il.fs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ open System.Text
2121
open System.Threading
2222

2323
open FSharp.Compiler.AbstractIL.Diagnostics
24-
open Internal.Utilities.Library
2524
open Internal.Utilities
2625

2726
let logging = false
@@ -83,7 +82,7 @@ let splitNameAt (nm: string) idx =
8382
if idx > last then
8483
failwith "splitNameAt: idx > last"
8584

86-
(nm.Substring(0, idx)), (if idx < last then nm.Substring(idx + 1, last - idx) else "")
85+
nm.Substring(0, idx), (if idx < last then nm.Substring(idx + 1, last - idx) else "")
8786

8887
let rec splitNamespaceAux (nm: string) =
8988
match nm.IndexOf '.' with
@@ -771,13 +770,13 @@ type ILTypeRef =
771770
let isPrimaryY = isPrimary y
772771

773772
let xApproxId =
774-
if isPrimaryX && not (isPrimaryY) then
773+
if isPrimaryX && not isPrimaryY then
775774
ILTypeRef.ComputeHash(primaryScopeRef, x.Enclosing, x.Name)
776775
else
777776
x.ApproxId
778777

779778
let yApproxId =
780-
if isPrimaryY && not (isPrimaryX) then
779+
if isPrimaryY && not isPrimaryX then
781780
ILTypeRef.ComputeHash(primaryScopeRef, y.Enclosing, y.Name)
782781
else
783782
y.ApproxId
@@ -2284,10 +2283,10 @@ type ILEventDef
22842283
| Some attrs -> attrs)
22852284
)
22862285

2287-
member x.IsSpecialName = (x.Attributes &&& EventAttributes.SpecialName) <> enum<_> (0)
2286+
member x.IsSpecialName = (x.Attributes &&& EventAttributes.SpecialName) <> enum<_> 0
22882287

22892288
member x.IsRTSpecialName =
2290-
(x.Attributes &&& EventAttributes.RTSpecialName) <> enum<_> (0)
2289+
(x.Attributes &&& EventAttributes.RTSpecialName) <> enum<_> 0
22912290

22922291
/// For debugging
22932292
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
@@ -2362,11 +2361,10 @@ type ILPropertyDef
23622361
| Some attrs -> attrs)
23632362
)
23642363

2365-
member x.IsSpecialName =
2366-
(x.Attributes &&& PropertyAttributes.SpecialName) <> enum<_> (0)
2364+
member x.IsSpecialName = (x.Attributes &&& PropertyAttributes.SpecialName) <> enum<_> 0
23672365

23682366
member x.IsRTSpecialName =
2369-
(x.Attributes &&& PropertyAttributes.RTSpecialName) <> enum<_> (0)
2367+
(x.Attributes &&& PropertyAttributes.RTSpecialName) <> enum<_> 0
23702368

23712369
/// For debugging
23722370
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
@@ -2388,7 +2386,7 @@ type ILPropertyDefs =
23882386
let convertFieldAccess (ilMemberAccess: ILMemberAccess) =
23892387
match ilMemberAccess with
23902388
| ILMemberAccess.Assembly -> FieldAttributes.Assembly
2391-
| ILMemberAccess.CompilerControlled -> enum<FieldAttributes> (0)
2389+
| ILMemberAccess.CompilerControlled -> enum<FieldAttributes> 0
23922390
| ILMemberAccess.FamilyAndAssembly -> FieldAttributes.FamANDAssem
23932391
| ILMemberAccess.FamilyOrAssembly -> FieldAttributes.FamORAssem
23942392
| ILMemberAccess.Family -> FieldAttributes.Family
@@ -2828,7 +2826,7 @@ type ILTypeDef
28282826
events = defaultArg events x.Events,
28292827
properties = defaultArg properties x.Properties,
28302828
additionalFlags = defaultArg newAdditionalFlags additionalFlags,
2831-
customAttrs = defaultArg customAttrs (x.CustomAttrsStored)
2829+
customAttrs = defaultArg customAttrs x.CustomAttrsStored
28322830
)
28332831

28342832
member x.CustomAttrs: ILAttributes =
@@ -3017,7 +3015,7 @@ and [<NoComparison; NoEquality>] ILExportedTypeOrForwarder =
30173015

30183016
member x.Access = typeAccessOfFlags (int x.Attributes)
30193017

3020-
member x.IsForwarder = x.Attributes &&& enum<TypeAttributes> (0x00200000) <> enum 0
3018+
member x.IsForwarder = x.Attributes &&& enum<TypeAttributes> 0x00200000 <> enum 0
30213019

30223020
member x.CustomAttrs = x.CustomAttrsStored.GetCustomAttrs x.MetadataIndex
30233021

@@ -4256,7 +4254,7 @@ let mkTypeForwarder scopeRef name nested customAttrs access =
42564254
{
42574255
ScopeRef = scopeRef
42584256
Name = name
4259-
Attributes = enum<TypeAttributes> (0x00200000) ||| convertTypeAccessFlags access
4257+
Attributes = enum<TypeAttributes> 0x00200000 ||| convertTypeAccessFlags access
42604258
Nested = nested
42614259
CustomAttrsStored = storeILCustomAttrs customAttrs
42624260
MetadataIndex = NoMetadataIdx
@@ -4293,7 +4291,7 @@ let mkILStorageCtorWithParamNames (preblock: ILInstr list, ty, extraParams, flds
42934291
| Some x -> I_seqpoint x
42944292
| None -> ()
42954293
yield! preblock
4296-
for (n, (_pnm, nm, fieldTy, _attrs)) in List.indexed flds do
4294+
for n, (_pnm, nm, fieldTy, _attrs) in List.indexed flds do
42974295
mkLdarg0
42984296
mkLdarg (uint16 (n + 1))
42994297
mkNormalStfld (mkILFieldSpecInTy (ty, nm, fieldTy))
@@ -4303,7 +4301,7 @@ let mkILStorageCtorWithParamNames (preblock: ILInstr list, ty, extraParams, flds
43034301

43044302
let fieldParams =
43054303
[
4306-
for (pnm, _, ty, attrs) in flds do
4304+
for pnm, _, ty, attrs in flds do
43074305
let ilParam = mkILParamNamed (pnm, ty)
43084306

43094307
let ilParam =
@@ -5130,17 +5128,17 @@ type ILTypeSigParser(tstring: string) =
51305128
drop () // step to the number
51315129
// fetch the arity
51325130
let arity =
5133-
while (int (here ()) >= (int ('0')))
5134-
&& (int (here ()) <= (int ('9')))
5135-
&& (int (peek ()) >= (int ('0')))
5136-
&& (int (peek ()) <= (int ('9'))) do
5131+
while (int (here ()) >= (int '0'))
5132+
&& (int (here ()) <= (int '9'))
5133+
&& (int (peek ()) >= (int '0'))
5134+
&& (int (peek ()) <= (int '9')) do
51375135
step ()
51385136

51395137
Int32.Parse(take ())
51405138
// skip the '['
51415139
drop ()
51425140
// get the specializations
5143-
typeName + "`" + (arity.ToString()),
5141+
typeName + "`" + arity.ToString(),
51445142
Some
51455143
[
51465144
for _i in 0 .. arity - 1 do

src/Compiler/AbstractIL/il.fsi

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ type ILAssemblyRef =
111111

112112
member EqualsIgnoringVersion: ILAssemblyRef -> bool
113113

114-
interface System.IComparable
114+
interface IComparable
115115

116116
[<Sealed>]
117117
type ILModuleRef =
@@ -123,7 +123,7 @@ type ILModuleRef =
123123

124124
member Hash: byte[] option
125125

126-
interface System.IComparable
126+
interface IComparable
127127

128128
// Scope references
129129
[<StructuralEquality; StructuralComparison; RequireQualifiedAccess>]
@@ -239,7 +239,7 @@ type ILTypeRef =
239239

240240
override ToString: unit -> string
241241

242-
interface System.IComparable
242+
interface IComparable
243243

244244
/// Type specs and types.
245245
[<Sealed>]
@@ -267,7 +267,7 @@ type ILTypeSpec =
267267

268268
member internal EqualsWithPrimaryScopeRef: ILScopeRef * obj -> bool
269269

270-
interface System.IComparable
270+
interface IComparable
271271

272272
[<RequireQualifiedAccess; StructuralEquality; StructuralComparison>]
273273
type ILType =
@@ -371,7 +371,7 @@ type ILMethodRef =
371371

372372
member GetCallingSignature: unit -> ILCallingSignature
373373

374-
interface System.IComparable
374+
interface IComparable
375375

376376
/// Formal identities of fields.
377377
[<StructuralEquality; StructuralComparison>]
@@ -403,7 +403,7 @@ type ILMethodSpec =
403403

404404
member FormalReturnType: ILType
405405

406-
interface System.IComparable
406+
interface IComparable
407407

408408
/// Field specs. The data given for a ldfld, stfld etc. instruction.
409409
[<StructuralEquality; StructuralComparison>]
@@ -2490,7 +2490,7 @@ type internal ILPropertyRef =
24902490
static member Create: ILTypeRef * string -> ILPropertyRef
24912491
member DeclaringTypeRef: ILTypeRef
24922492
member Name: string
2493-
interface System.IComparable
2493+
interface IComparable
24942494

24952495
type ILReferences =
24962496
{ AssemblyReferences: ILAssemblyRef[]

src/Compiler/AbstractIL/ilascii.fs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ let Int32Int32Instrs: Lazy<InstrTable<Int32Int32Instr>> =
216216
let DoubleInstrs: Lazy<InstrTable<DoubleInstr>> =
217217
lazy
218218
[
219-
[ "ldc"; "r4" ], (fun x -> (AI_ldc(DT_R4, x)))
220-
[ "ldc"; "r8" ], (fun x -> (AI_ldc(DT_R8, x)))
219+
[ "ldc"; "r4" ], (fun x -> AI_ldc(DT_R4, x))
220+
[ "ldc"; "r8" ], (fun x -> AI_ldc(DT_R8, x))
221221
]
222222

223223
/// Table of parsing and pretty printing data for instructions.
@@ -245,10 +245,10 @@ let TypeInstrs: Lazy<InstrTable<TypeInstr>> =
245245
let IntTypeInstrs: Lazy<InstrTable<IntTypeInstr>> =
246246
lazy
247247
[
248-
[ "ldelem"; "multi" ], (fun (x, y) -> (I_ldelem_any(ILArrayShape.FromRank x, y)))
249-
[ "stelem"; "multi" ], (fun (x, y) -> (I_stelem_any(ILArrayShape.FromRank x, y)))
250-
[ "newarr"; "multi" ], (fun (x, y) -> (I_newarr(ILArrayShape.FromRank x, y)))
251-
[ "ldelema"; "multi" ], (fun (x, y) -> (I_ldelema(NormalAddress, false, ILArrayShape.FromRank x, y)))
248+
[ "ldelem"; "multi" ], (fun (x, y) -> I_ldelem_any(ILArrayShape.FromRank x, y))
249+
[ "stelem"; "multi" ], (fun (x, y) -> I_stelem_any(ILArrayShape.FromRank x, y))
250+
[ "newarr"; "multi" ], (fun (x, y) -> I_newarr(ILArrayShape.FromRank x, y))
251+
[ "ldelema"; "multi" ], (fun (x, y) -> I_ldelema(NormalAddress, false, ILArrayShape.FromRank x, y))
252252
]
253253

254254
/// Table of parsing and pretty printing data for instructions.

src/Compiler/AbstractIL/ilmorph.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ let rec morphILTypeRefsInILType f x =
8989
and tspec_tref2tref f (tspec: ILTypeSpec) =
9090
mkILTySpec (f tspec.TypeRef, List.map (morphILTypeRefsInILType f) tspec.GenericArgs)
9191

92-
let rec ty_scoref2scoref_tyvar2ty ((_fscope, fTyvar) as fs) ty =
92+
let rec ty_scoref2scoref_tyvar2ty (_fscope, fTyvar as fs) ty =
9393
match ty with
9494
| ILType.Ptr elemTy -> ILType.Ptr(ty_scoref2scoref_tyvar2ty fs elemTy)
9595
| ILType.FunctionPointer callsig -> ILType.FunctionPointer(callsig_scoref2scoref_tyvar2ty fs callsig)
@@ -259,7 +259,7 @@ let morphILFieldDefs f (fdefs: ILFieldDefs) =
259259
let morphILTypeDefs isInKnownSet f (tdefs: ILTypeDefs) =
260260
let filtered (tdefs: ILTypeDef array) =
261261
// The key ensures that items in the Known Set are not duplicated everything else may be.
262-
let mkKey (i, (td: ILTypeDef)) =
262+
let mkKey (i, td: ILTypeDef) =
263263
if isInKnownSet td.Name then
264264
struct (0, td.Name)
265265
else

src/Compiler/AbstractIL/ilnativeres.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ type CvtResFile() =
105105

106106
static member private ReadStringOrID(fhIn: BinaryReader) =
107107
let mutable (pstring: RESOURCE_STRING) = RESOURCE_STRING()
108-
let mutable (firstWord: WCHAR) = (fhIn.ReadChar())
108+
let mutable (firstWord: WCHAR) = fhIn.ReadChar()
109109

110110
if int firstWord = 0xFFFF then
111111
pstring.Ordinal <- fhIn.ReadUInt16()
@@ -173,7 +173,7 @@ type SectionCharacteristics =
173173

174174
type ResourceSection() =
175175
new(sectionBytes: byte[], relocations: uint32[]) as this =
176-
(ResourceSection())
176+
ResourceSection()
177177

178178
then
179179
Debug.Assert(sectionBytes :> obj <> Unchecked.defaultof<_>)
@@ -433,7 +433,7 @@ type VersionHelper() =
433433
if not (Char.IsDigit elements[i].[idx]) then
434434
invalidFormat <- true
435435

436-
VersionHelper.TryGetValue((elements[i].Substring(0, idx)), ref values[i])
436+
VersionHelper.TryGetValue(elements[i].Substring(0, idx), ref values[i])
437437
|> ignore<bool>
438438

439439
breakLoop <- true
@@ -1139,7 +1139,7 @@ type NativeResourceWriter() =
11391139
else Unchecked.defaultof<_>
11401140

11411141
dataWriter.WriteUInt32(uint32 virtualAddressBase + sizeOfDirectoryTree + 16u + uint32 dataWriter.Count)
1142-
let mutable (data: byte[]) = (List<byte>(r.Data)).ToArray()
1142+
let mutable (data: byte[]) = List<byte>(r.Data).ToArray()
11431143
dataWriter.WriteUInt32(uint32 data.Length)
11441144
dataWriter.WriteUInt32 r.CodePage
11451145
dataWriter.WriteUInt32 0u

src/Compiler/AbstractIL/ilprint.fs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ open System.Reflection
88
open FSharp.Compiler.IO
99
open Internal.Utilities.Library
1010

11-
open FSharp.Compiler.AbstractIL.AsciiConstants
1211
open FSharp.Compiler.AbstractIL.ILX.Types
1312
open FSharp.Compiler.AbstractIL.IL
1413

0 commit comments

Comments
 (0)