Skip to content

Commit

Permalink
Cleanup (dotnet#13113)
Browse files Browse the repository at this point in the history
* cleanup

* split files

* rename

* split infos.fs and SymbolHelpres.fs

* split infos.fs and SymbolHelpres.fs

* fix code formating

* rename autobox --> LowerLocalMutables

* adjust names

* block --> ImmutableArray

* format

* Error --> SRDiagnostic

* Error --> SRDiagnostic

* this -> _

* rename and cleanup

* rename Diagnostic --> FormattedDiagnostic

* format sigs

* format sigs

* fix build

* fix build
  • Loading branch information
dsyme authored and vzarytovskii committed May 10, 2022
1 parent 3814613 commit ff0deda
Show file tree
Hide file tree
Showing 183 changed files with 3,483 additions and 2,946 deletions.
3 changes: 2 additions & 1 deletion src/fsharp/AccessibilityLogic.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ module internal FSharp.Compiler.AccessibilityLogic
open Internal.Utilities.Library
open FSharp.Compiler
open FSharp.Compiler.AbstractIL.IL
open FSharp.Compiler.ErrorLogger
open FSharp.Compiler.DiagnosticsLogger
open FSharp.Compiler.Infos
open FSharp.Compiler.TcGlobals
open FSharp.Compiler.TypedTree
open FSharp.Compiler.TypedTreeBasics
open FSharp.Compiler.TypedTreeOps
open FSharp.Compiler.TypeHierarchy

#if !NO_TYPEPROVIDERS
open FSharp.Compiler.TypeProviders
Expand Down
10 changes: 6 additions & 4 deletions src/fsharp/AttributeChecking.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ open System.Collections.Generic
open Internal.Utilities.Library
open FSharp.Compiler.AbstractIL.IL
open FSharp.Compiler
open FSharp.Compiler.ErrorLogger
open FSharp.Compiler.DiagnosticsLogger
open FSharp.Compiler.Import
open FSharp.Compiler.Infos
open FSharp.Compiler.TcGlobals
open FSharp.Compiler.Text
open FSharp.Compiler.TypedTree
open FSharp.Compiler.TypedTreeOps
open FSharp.Compiler.TypeHierarchy

#if !NO_TYPEPROVIDERS
open FSharp.Compiler.TypeProviders
Expand Down Expand Up @@ -87,7 +89,7 @@ type AttribInfo =
match x with
| FSAttribInfo(_g, Attrib(tcref, _, _, _, _, _, _)) -> tcref
| ILAttribInfo (g, amap, scoref, a, m) ->
let ty = ImportILType scoref amap m [] a.Method.DeclaringType
let ty = RescopeAndImportILType scoref amap m [] a.Method.DeclaringType
tcrefOfAppTy g ty

member x.ConstructorArguments =
Expand All @@ -101,7 +103,7 @@ type AttribInfo =
| ILAttribInfo (_g, amap, scoref, cattr, m) ->
let parms, _args = decodeILAttribData cattr
[ for argTy, arg in Seq.zip cattr.Method.FormalArgTypes parms ->
let ty = ImportILType scoref amap m [] argTy
let ty = RescopeAndImportILType scoref amap m [] argTy
let obj = evalILAttribElem arg
ty, obj ]

Expand All @@ -116,7 +118,7 @@ type AttribInfo =
| ILAttribInfo (_g, amap, scoref, cattr, m) ->
let _parms, namedArgs = decodeILAttribData cattr
[ for nm, argTy, isProp, arg in namedArgs ->
let ty = ImportILType scoref amap m [] argTy
let ty = RescopeAndImportILType scoref amap m [] argTy
let obj = evalILAttribElem arg
let isField = not isProp
ty, nm, isField, obj ]
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/AttributeChecking.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module internal FSharp.Compiler.AttributeChecking
open System.Collections.Generic
open FSharp.Compiler.AbstractIL.IL
open FSharp.Compiler
open FSharp.Compiler.ErrorLogger
open FSharp.Compiler.DiagnosticsLogger
open FSharp.Compiler.Infos
open FSharp.Compiler.TcGlobals
open FSharp.Compiler.Text
Expand Down
14 changes: 7 additions & 7 deletions src/fsharp/AugmentWithHashCompare.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ module internal FSharp.Compiler.AugmentWithHashCompare

open Internal.Utilities.Library
open FSharp.Compiler.AbstractIL.IL
open FSharp.Compiler.ErrorLogger
open FSharp.Compiler.Infos
open FSharp.Compiler.DiagnosticsLogger
open FSharp.Compiler.Syntax
open FSharp.Compiler.SyntaxTrivia
open FSharp.Compiler.Xml
open FSharp.Compiler.TcGlobals
open FSharp.Compiler.TypedTree
open FSharp.Compiler.TypedTreeBasics
open FSharp.Compiler.TypedTreeOps
open FSharp.Compiler.TypeHierarchy

let mkIComparableCompareToSlotSig (g: TcGlobals) =
TSlotSig("CompareTo", g.mk_IComparable_ty, [], [], [[TSlotParam(Some("obj"), g.obj_ty, false, false, false, [])]], Some g.int_ty)
Expand Down Expand Up @@ -175,7 +175,7 @@ let mkEqualsTestConjuncts g m exprs =
List.foldBack (fun e acc -> mkCond DebugPointAtBinding.NoneAtSticky m g.bool_ty e acc (mkFalse g m)) a b

let mkMinimalTy (g: TcGlobals) (tcref: TyconRef) =
if tcref.Deref.IsExceptionDecl then [], g.exn_ty
if tcref.Deref.IsFSharpException then [], g.exn_ty
else generalizeTyconRef g tcref

// check for nulls
Expand Down Expand Up @@ -679,7 +679,7 @@ let isTrueFSharpStructTycon _g (tycon: Tycon) =
let canBeAugmentedWithEquals g (tycon: Tycon) =
tycon.IsUnionTycon ||
tycon.IsRecordTycon ||
(tycon.IsExceptionDecl && isNominalExnc tycon) ||
(tycon.IsFSharpException && isNominalExnc tycon) ||
isTrueFSharpStructTycon g tycon

let canBeAugmentedWithCompare g (tycon: Tycon) =
Expand Down Expand Up @@ -918,7 +918,7 @@ let MakeValsForEqualsAugmentation g (tcref: TyconRef) =
let tps = tcref.Typars m

let objEqualsVal = mkValSpec g tcref ty vis (Some(mkEqualsSlotSig g)) "Equals" (tps +-> (mkEqualsObjTy g ty)) unaryArg
let nocEqualsVal = mkValSpec g tcref ty vis (if tcref.Deref.IsExceptionDecl then None else Some(mkGenericIEquatableEqualsSlotSig g ty)) "Equals" (tps +-> (mkEqualsTy g ty)) unaryArg
let nocEqualsVal = mkValSpec g tcref ty vis (if tcref.Deref.IsFSharpException then None else Some(mkGenericIEquatableEqualsSlotSig g ty)) "Equals" (tps +-> (mkEqualsTy g ty)) unaryArg
objEqualsVal, nocEqualsVal

let MakeValsForEqualityWithComparerAugmentation g (tcref: TyconRef) =
Expand Down Expand Up @@ -1032,7 +1032,7 @@ let MakeBindingsForEqualityWithComparerAugmentation (g: TcGlobals) (tycon: Tycon
(mkCompGenBind withcEqualsVal.Deref withcEqualsExpr)]
if tycon.IsUnionTycon then mkStructuralEquatable mkUnionHashWithComparer mkUnionEqualityWithComparer
elif (tycon.IsRecordTycon || tycon.IsStructOrEnumTycon) then mkStructuralEquatable mkRecdHashWithComparer mkRecdEqualityWithComparer
elif tycon.IsExceptionDecl then mkStructuralEquatable mkExnHashWithComparer mkExnEqualityWithComparer
elif tycon.IsFSharpException then mkStructuralEquatable mkExnHashWithComparer mkExnEqualityWithComparer
else []

let MakeBindingsForEqualsAugmentation (g: TcGlobals) (tycon: Tycon) =
Expand Down Expand Up @@ -1066,7 +1066,7 @@ let MakeBindingsForEqualsAugmentation (g: TcGlobals) (tycon: Tycon) =

[ mkCompGenBind nocEqualsVal.Deref nocEqualsExpr
mkCompGenBind objEqualsVal.Deref objEqualsExpr ]
if tycon.IsExceptionDecl then mkEquals mkExnEquality
if tycon.IsFSharpException then mkEquals mkExnEquality
elif tycon.IsUnionTycon then mkEquals mkUnionEquality
elif tycon.IsRecordTycon || tycon.IsStructOrEnumTycon then mkEquals mkRecdEquality
else []
Expand Down
20 changes: 10 additions & 10 deletions src/fsharp/BuildGraph.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ open System.Threading
open System.Threading.Tasks
open System.Diagnostics
open System.Globalization
open FSharp.Compiler.ErrorLogger
open FSharp.Compiler.DiagnosticsLogger
open Internal.Utilities.Library

[<NoEquality;NoComparison>]
type NodeCode<'T> = Node of Async<'T>

let wrapThreadStaticInfo computation =
async {
let errorLogger = CompileThreadStatic.ErrorLogger
let errorLogger = CompileThreadStatic.DiagnosticsLogger
let phase = CompileThreadStatic.BuildPhase
try
return! computation
finally
CompileThreadStatic.ErrorLogger <- errorLogger
CompileThreadStatic.DiagnosticsLogger <- errorLogger
CompileThreadStatic.BuildPhase <- phase
}

Expand Down Expand Up @@ -72,7 +72,7 @@ type NodeCodeBuilder() =
member _.Using(value: CompilationGlobalsScope, binder: CompilationGlobalsScope -> NodeCode<'U>) =
Node(
async {
CompileThreadStatic.ErrorLogger <- value.ErrorLogger
CompileThreadStatic.DiagnosticsLogger <- value.DiagnosticsLogger
CompileThreadStatic.BuildPhase <- value.BuildPhase
try
return! binder value |> Async.AwaitNodeCode
Expand All @@ -90,19 +90,19 @@ type NodeCode private () =
Node(wrapThreadStaticInfo Async.CancellationToken)

static member RunImmediate (computation: NodeCode<'T>, ct: CancellationToken) =
let errorLogger = CompileThreadStatic.ErrorLogger
let errorLogger = CompileThreadStatic.DiagnosticsLogger
let phase = CompileThreadStatic.BuildPhase
try
try
let work =
async {
CompileThreadStatic.ErrorLogger <- errorLogger
CompileThreadStatic.DiagnosticsLogger <- errorLogger
CompileThreadStatic.BuildPhase <- phase
return! computation |> Async.AwaitNodeCode
}
Async.StartImmediateAsTask(work, cancellationToken=ct).Result
finally
CompileThreadStatic.ErrorLogger <- errorLogger
CompileThreadStatic.DiagnosticsLogger <- errorLogger
CompileThreadStatic.BuildPhase <- phase
with
| :? AggregateException as ex when ex.InnerExceptions.Count = 1 ->
Expand All @@ -112,18 +112,18 @@ type NodeCode private () =
NodeCode.RunImmediate(computation, CancellationToken.None)

static member StartAsTask_ForTesting (computation: NodeCode<'T>, ?ct: CancellationToken) =
let errorLogger = CompileThreadStatic.ErrorLogger
let errorLogger = CompileThreadStatic.DiagnosticsLogger
let phase = CompileThreadStatic.BuildPhase
try
let work =
async {
CompileThreadStatic.ErrorLogger <- errorLogger
CompileThreadStatic.DiagnosticsLogger <- errorLogger
CompileThreadStatic.BuildPhase <- phase
return! computation |> Async.AwaitNodeCode
}
Async.StartAsTask(work, cancellationToken=defaultArg ct CancellationToken.None)
finally
CompileThreadStatic.ErrorLogger <- errorLogger
CompileThreadStatic.DiagnosticsLogger <- errorLogger
CompileThreadStatic.BuildPhase <- phase

static member CancellationToken = cancellationToken
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/BuildGraph.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module internal FSharp.Compiler.BuildGraph
open System
open System.Threading
open System.Threading.Tasks
open FSharp.Compiler.ErrorLogger
open FSharp.Compiler.DiagnosticsLogger
open Internal.Utilities.Library

/// Represents code that can be run as part of the build graph.
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/CheckComputationExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ open FSharp.Compiler.AccessibilityLogic
open FSharp.Compiler.AttributeChecking
open FSharp.Compiler.CheckExpressions
open FSharp.Compiler.ConstraintSolver
open FSharp.Compiler.ErrorLogger
open FSharp.Compiler.DiagnosticsLogger
open FSharp.Compiler.Features
open FSharp.Compiler.Infos
open FSharp.Compiler.InfoReader
Expand Down
21 changes: 11 additions & 10 deletions src/fsharp/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ open FSharp.Compiler.CheckExpressions
open FSharp.Compiler.CheckComputationExpressions
open FSharp.Compiler.CompilerGlobalState
open FSharp.Compiler.ConstraintSolver
open FSharp.Compiler.ErrorLogger
open FSharp.Compiler.DiagnosticsLogger
open FSharp.Compiler.Features
open FSharp.Compiler.Infos
open FSharp.Compiler.InfoReader
Expand All @@ -35,6 +35,7 @@ open FSharp.Compiler.TcGlobals
open FSharp.Compiler.TypedTree
open FSharp.Compiler.TypedTreeBasics
open FSharp.Compiler.TypedTreeOps
open FSharp.Compiler.TypeHierarchy
open FSharp.Compiler.TypeRelations

#if !NO_TYPEPROVIDERS
Expand Down Expand Up @@ -374,7 +375,7 @@ let ImplicitlyOpenOwnNamespace tcSink g amap scopem enclosingNamespacePath (env:
// Bind elements of data definitions for exceptions and types (fields, etc.)
//-------------------------------------------------------------------------

exception NotUpperCaseConstructor of range
exception NotUpperCaseConstructor of range: range

let CheckNamespaceModuleOrTypeName (g: TcGlobals) (id: Ident) =
// type names '[]' etc. are used in fslib
Expand Down Expand Up @@ -678,7 +679,7 @@ let TcOpenDecl (cenv: cenv) mOpenDecl scopem env target =
| SynOpenDeclTarget.Type (synType, m) ->
TcOpenTypeDecl cenv mOpenDecl scopem env (synType, m)

exception ParameterlessStructCtor of range
exception ParameterlessStructCtor of range: range

let MakeSafeInitField (g: TcGlobals) env m isStatic =
let id =
Expand Down Expand Up @@ -2290,7 +2291,7 @@ module MutRecBindingChecking =
let moduleAbbrevs = decls |> List.choose (function MutRecShape.ModuleAbbrev (MutRecDataForModuleAbbrev (id, mp, m)) -> Some (id, mp, m) | _ -> None)
let opens = decls |> List.choose (function MutRecShape.Open (MutRecDataForOpen (target, m, moduleRange, openDeclsRef)) -> Some (target, m, moduleRange, openDeclsRef) | _ -> None)
let lets = decls |> List.collect (function MutRecShape.Lets binds -> getVals binds | _ -> [])
let exns = tycons |> List.filter (fun (tycon: Tycon) -> tycon.IsExceptionDecl)
let exns = tycons |> List.filter (fun (tycon: Tycon) -> tycon.IsFSharpException)

// Add the type definitions, exceptions, modules and "open" declarations.
// The order here is sensitive. The things added first will be resolved in an environment
Expand Down Expand Up @@ -2475,7 +2476,7 @@ let TcMutRecDefns_Phase2 (cenv: cenv) envInitial bindsm scopem mutRecNSInfo (env
let overridesOK = DeclKind.CanOverrideOrImplement declKind
members |> List.collect (function
| SynMemberDefn.Interface(interfaceType=intfTy; members=defnOpt) ->
let ty = if tcref.Deref.IsExceptionDecl then g.exn_ty else generalizedTyconRef g tcref
let ty = if tcref.Deref.IsFSharpException then g.exn_ty else generalizedTyconRef g tcref
let m = intfTy.Range
if tcref.IsTypeAbbrev then error(Error(FSComp.SR.tcTypeAbbreviationsCannotHaveInterfaceDeclaration(), m))
if tcref.IsEnumTycon then error(Error(FSComp.SR.tcEnumerationsCannotHaveInterfaceDeclaration(), m))
Expand Down Expand Up @@ -2600,7 +2601,7 @@ module AddAugmentationDeclarations =
if AugmentWithHashCompare.TyconIsCandidateForAugmentationWithCompare g tycon && scSet.Contains tycon.Stamp then
let tcref = mkLocalTyconRef tycon
let tcaug = tycon.TypeContents
let ty = if tcref.Deref.IsExceptionDecl then g.exn_ty else generalizedTyconRef g tcref
let ty = if tcref.Deref.IsFSharpException then g.exn_ty else generalizedTyconRef g tcref
let m = tycon.Range
let genericIComparableTy = mkAppTy g.system_GenericIComparable_tcref [ty]

Expand All @@ -2623,7 +2624,7 @@ module AddAugmentationDeclarations =

PublishInterface cenv env.DisplayEnv tcref m true g.mk_IStructuralComparable_ty
PublishInterface cenv env.DisplayEnv tcref m true g.mk_IComparable_ty
if not tycon.IsExceptionDecl && not hasExplicitGenericIComparable then
if not tycon.IsFSharpException && not hasExplicitGenericIComparable then
PublishInterface cenv env.DisplayEnv tcref m true genericIComparableTy
tcaug.SetCompare (mkLocalValRef cvspec1, mkLocalValRef cvspec2)
tcaug.SetCompareWith (mkLocalValRef cvspec3)
Expand Down Expand Up @@ -2684,7 +2685,7 @@ module AddAugmentationDeclarations =
if AugmentWithHashCompare.TyconIsCandidateForAugmentationWithEquals g tycon then
let tcref = mkLocalTyconRef tycon
let tcaug = tycon.TypeContents
let ty = if tcref.Deref.IsExceptionDecl then g.exn_ty else generalizedTyconRef g tcref
let ty = if tcref.Deref.IsFSharpException then g.exn_ty else generalizedTyconRef g tcref
let m = tycon.Range

// Note: tycon.HasOverride only gives correct results after we've done the type augmentation
Expand All @@ -2701,7 +2702,7 @@ module AddAugmentationDeclarations =

let vspec1, vspec2 = AugmentWithHashCompare.MakeValsForEqualsAugmentation g tcref
tcaug.SetEquals (mkLocalValRef vspec1, mkLocalValRef vspec2)
if not tycon.IsExceptionDecl then
if not tycon.IsFSharpException then
PublishInterface cenv env.DisplayEnv tcref m true (mkAppTy g.system_GenericIEquatable_tcref [ty])
PublishValueDefn cenv env ModuleOrMemberBinding vspec1
PublishValueDefn cenv env ModuleOrMemberBinding vspec2
Expand Down Expand Up @@ -4606,7 +4607,7 @@ module EstablishTypeDefinitionCores =
(envMutRecPrelim, withAttrs)
||> MutRecShapes.extendEnvs (fun envForDecls decls ->
let tycons = decls |> List.choose (function MutRecShape.Tycon (_, Some (tycon, _)) -> Some tycon | _ -> None)
let exns = tycons |> List.filter (fun tycon -> tycon.IsExceptionDecl)
let exns = tycons |> List.filter (fun tycon -> tycon.IsFSharpException)
let envForDecls = (envForDecls, exns) ||> List.fold (AddLocalExnDefnAndReport cenv.tcSink scopem)
envForDecls)

Expand Down
4 changes: 2 additions & 2 deletions src/fsharp/CheckDeclarations.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ val CheckOneSigFile:
ParsedSigFileInput ->
Cancellable<TcEnv * ModuleOrNamespaceType * bool>

exception ParameterlessStructCtor of range
exception ParameterlessStructCtor of range: range

exception NotUpperCaseConstructor of range
exception NotUpperCaseConstructor of range: range
Loading

0 comments on commit ff0deda

Please sign in to comment.