Skip to content

Commit e9265d8

Browse files
authored
Merge pull request #1315 from dsyme/semis-2
cosmetic cleanup
2 parents d1837c8 + 49941f3 commit e9265d8

28 files changed

+964
-1335
lines changed

VisualFSharp.sln

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
126126
EndProjectSection
127127
EndProject
128128
Global
129-
GlobalSection(Performance) = preSolution
130-
HasPerformanceSessions = true
131-
EndGlobalSection
132129
GlobalSection(SolutionConfigurationPlatforms) = preSolution
133130
Debug|Any CPU = Debug|Any CPU
134131
Debug|x86 = Debug|x86

src/absil/ildiag.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ module internal Microsoft.FSharp.Compiler.AbstractIL.Diagnostics
77
open Internal.Utilities
88

99
let diagnosticsLog = ref (Some stdout)
10+
11+
let setDiagnosticsChannel s = diagnosticsLog := s
12+
1013
let dflushn () = match !diagnosticsLog with None -> () | Some d -> d.WriteLine(); d.Flush()
1114
let dflush () = match !diagnosticsLog with None -> () | Some d -> d.Flush()
1215
let dprintn (s:string) =
@@ -18,4 +21,3 @@ let dprintf (fmt: Format<_,_,_,_>) =
1821
let dprintfn (fmt: Format<_,_,_,_>) =
1922
Printf.kfprintf dflushn (match !diagnosticsLog with None -> System.IO.TextWriter.Null | Some d -> d) fmt
2023

21-
let setDiagnosticsChannel s = diagnosticsLog := s

src/absil/ildiag.fsi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ module internal Microsoft.FSharp.Compiler.AbstractIL.Diagnostics
1111
open System.IO
1212
open Microsoft.FSharp.Core.Printf
1313

14-
val public setDiagnosticsChannel: TextWriter option -> unit
14+
val public setDiagnosticsChannel: TextWriter option -> unit
1515

1616
val public dprintfn: TextWriterFormat<'a> -> 'a
1717
val public dprintf: TextWriterFormat<'a> -> 'a
18-
1918
val public dprintn: string -> unit

src/absil/ilread.fs

Lines changed: 784 additions & 797 deletions
Large diffs are not rendered by default.

src/fsharp/CompileOps.fs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,10 +1476,10 @@ let CollectErrorOrWarning (implicitIncludeDir,showFullPaths,flattenErrors,errorS
14761476

14771477
match err.Exception with
14781478
| ReportedError _ ->
1479-
dprintf "Unexpected ReportedError" (* this should actually never happen *)
1479+
assert ("" = "Unexpected ReportedError") // this should never happen
14801480
Seq.empty
14811481
| StopProcessing ->
1482-
dprintf "Unexpected StopProcessing" (* this should actually never happen *)
1482+
assert ("" = "Unexpected StopProcessing") // this should never happen
14831483
Seq.empty
14841484
| _ ->
14851485
let errors = ResizeArray()
@@ -2962,6 +2962,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
29622962
let logmessage showMessages =
29632963
if showMessages && tcConfig.showReferenceResolutions then (fun (message:string)->dprintf "%s\n" message)
29642964
else ignore
2965+
29652966
let logwarning showMessages =
29662967
(fun code message->
29672968
if showMessages && mode = ReportErrors then
@@ -2975,6 +2976,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
29752976
| _ ->
29762977
(if code = "MSB3245" then errorR else warning)
29772978
(MSBuildReferenceResolutionWarning(code,message,errorAndWarningRange)))
2979+
29782980
let logerror showMessages =
29792981
(fun code message ->
29802982
if showMessages && mode = ReportErrors then
@@ -2988,10 +2990,12 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
29882990
| Some(X86) -> "x86"
29892991
| Some(AMD64) -> "amd64"
29902992
| Some(IA64) -> "ia64"
2993+
29912994
let outputDirectory =
29922995
match tcConfig.outputFile with
29932996
| Some(outputFile) -> tcConfig.MakePathAbsolute outputFile
29942997
| None -> tcConfig.implicitIncludeDir
2998+
29952999
let targetFrameworkDirectories =
29963000
match tcConfig.clrRoot with
29973001
| Some(clrRoot) -> [tcConfig.MakePathAbsolute clrRoot]
@@ -3033,6 +3037,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
30333037
|> Array.map(fun i->(p13 groupedReferences.[i]),(p23 groupedReferences.[i]),i)
30343038
|> Array.filter (fun (_,i0,_)->resolvedAsFile|>Array.exists(fun (i1,_) -> i0=i1)|>not)
30353039
|> Array.map(fun (ref,_,i)->ref,string i)
3040+
30363041
let resolutions = Resolve(toMsBuild,(*showMessages*)true)
30373042

30383043
// Map back to original assembly resolutions.

src/fsharp/ConstraintSolver.fs

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -160,44 +160,45 @@ type TcValF = (ValRef -> ValUseFlag -> TType list -> range -> Expr * TType)
160160

161161
type ConstraintSolverState =
162162
{
163-
g: TcGlobals;
164-
amap: Import.ImportMap;
165-
InfoReader : InfoReader;
163+
g: TcGlobals
164+
amap: Import.ImportMap
165+
InfoReader : InfoReader
166166
TcVal : TcValF
167167
/// This table stores all unsolved, ungeneralized trait constraints, indexed by free type variable.
168168
/// That is, there will be one entry in this table for each free type variable in
169169
/// each outstanding, unsolved, ungeneralized trait constraint. Constraints are removed from the table and resolved
170170
/// each time a solution to an index variable is found.
171-
mutable ExtraCxs: HashMultiMap<Stamp, (TraitConstraintInfo * range)>;
171+
mutable ExtraCxs: HashMultiMap<Stamp, (TraitConstraintInfo * range)>
172172
}
173173

174174
static member New(g,amap,infoReader, tcVal) =
175-
{ g=g; amap=amap;
175+
{ g=g
176+
amap=amap
176177
ExtraCxs= HashMultiMap(10, HashIdentity.Structural)
177178
InfoReader=infoReader
178-
TcVal = tcVal } ;
179+
TcVal = tcVal }
179180

180181

181182
type ConstraintSolverEnv =
182183
{
183-
SolverState: ConstraintSolverState;
184+
SolverState: ConstraintSolverState
184185
eContextInfo: ContextInfo
185186
MatchingOnly : bool
186-
m: range;
187-
EquivEnv: TypeEquivEnv;
187+
m: range
188+
EquivEnv: TypeEquivEnv
188189
DisplayEnv : DisplayEnv
189190
}
190191
member csenv.InfoReader = csenv.SolverState.InfoReader
191192
member csenv.g = csenv.SolverState.g
192193
member csenv.amap = csenv.SolverState.amap
193194

194195
let MakeConstraintSolverEnv contextInfo css m denv =
195-
{ SolverState=css;
196-
m=m;
196+
{ SolverState=css
197+
m=m
197198
eContextInfo = contextInfo
198199
// Indicates that when unifiying ty1 = ty2, only type variables in ty1 may be solved
199-
MatchingOnly=false;
200-
EquivEnv=TypeEquivEnv.Empty;
200+
MatchingOnly=false
201+
EquivEnv=TypeEquivEnv.Empty
201202
DisplayEnv = denv }
202203

203204

@@ -303,9 +304,10 @@ let BakedInTraitConstraintNames =
303304
// Run the constraint solver with undo (used during method overload resolution)
304305

305306
type Trace =
306-
| Trace of (unit -> unit) list ref
307-
static member New () = Trace (ref [])
308-
member t.Undo () = let (Trace trace) = t in List.iter (fun a -> a ()) !trace
307+
{ mutable actions: (unit -> unit) list }
308+
static member New () = { actions = [] }
309+
member t.Undo () = List.iter (fun a -> a ()) t.actions
310+
member t.Push f = t.actions <- f :: t.actions
309311

310312
type OptionalTrace =
311313
| NoTrace
@@ -417,7 +419,7 @@ let rec TransactStaticReq (csenv:ConstraintSolverEnv) trace (tpr:Typar) req =
417419
let orig = tpr.StaticReq
418420
match trace with
419421
| NoTrace -> ()
420-
| WithTrace (Trace actions) -> actions := (fun () -> tpr.SetStaticReq orig) :: !actions
422+
| WithTrace trace -> trace.Push (fun () -> tpr.SetStaticReq orig)
421423
tpr.SetStaticReq req;
422424
CompleteD
423425

@@ -446,7 +448,7 @@ let rec TransactDynamicReq trace (tpr:Typar) req =
446448
let orig = tpr.DynamicReq
447449
match trace with
448450
| NoTrace -> ()
449-
| WithTrace (Trace actions) -> actions := (fun () -> tpr.SetDynamicReq orig) :: !actions
451+
| WithTrace trace -> trace.Push (fun () -> tpr.SetDynamicReq orig)
450452
tpr.SetDynamicReq req;
451453
CompleteD
452454

@@ -673,7 +675,7 @@ let rec SolveTyparEqualsTyp (csenv:ConstraintSolverEnv) ndeep m2 trace ty1 ty =
673675
let tpdata = r.Data
674676
match trace with
675677
| NoTrace -> ()
676-
| WithTrace (Trace actions) -> actions := (fun () -> tpdata.typar_solution <- None) :: !actions
678+
| WithTrace trace -> trace.Push (fun () -> tpdata.typar_solution <- None)
677679
tpdata.typar_solution <- Some ty;
678680

679681
(* dprintf "setting typar %d to type %s at %a\n" r.Stamp ((DebugPrint.showType ty)) outputRange m; *)
@@ -1343,7 +1345,7 @@ and TransactMemberConstraintSolution traitInfo trace sln =
13431345
traitInfo.Solution <- Some sln
13441346
match trace with
13451347
| NoTrace -> ()
1346-
| WithTrace (Trace actions) -> actions := (fun () -> traitInfo.Solution <- prev) :: !actions
1348+
| WithTrace trace -> trace.Push (fun () -> traitInfo.Solution <- prev)
13471349

13481350
/// Only consider overload resolution if canonicalizing or all the types are now nominal.
13491351
/// That is, don't perform resolution if more nominal information may influence the set of available overloads
@@ -1410,7 +1412,7 @@ and SolveRelevantMemberConstraintsForTypar (csenv:ConstraintSolverEnv) ndeep per
14101412

14111413
match trace with
14121414
| NoTrace -> ()
1413-
| WithTrace (Trace actions) -> actions := (fun () -> cxs |> List.iter (fun cx -> cxst.Add(tpn,cx))) :: !actions
1415+
| WithTrace trace -> trace.Push (fun () -> cxs |> List.iter (fun cx -> cxst.Add(tpn,cx)))
14141416

14151417
cxs |> AtLeastOneD (fun (traitInfo,m2) ->
14161418
let csenv = { csenv with m = m2 }
@@ -1437,7 +1439,7 @@ and AddMemberConstraint (csenv:ConstraintSolverEnv) ndeep m2 trace traitInfo sup
14371439
if not (cxs |> List.exists (fun (traitInfo2,_) -> traitsAEquiv g aenv traitInfo traitInfo2)) then
14381440
match trace with
14391441
| NoTrace -> ()
1440-
| WithTrace (Trace actions) -> actions := (fun () -> csenv.SolverState.ExtraCxs.Remove tpn) :: !actions
1442+
| WithTrace trace -> trace.Push (fun () -> csenv.SolverState.ExtraCxs.Remove tpn)
14411443
csenv.SolverState.ExtraCxs.Add (tpn,(traitInfo,m2))
14421444
);
14431445

@@ -1613,7 +1615,7 @@ and AddConstraint (csenv:ConstraintSolverEnv) ndeep m2 trace tp newConstraint =
16131615
let orig = d.typar_constraints
16141616
begin match trace with
16151617
| NoTrace -> ()
1616-
| WithTrace (Trace actions) -> actions := (fun () -> d.typar_constraints <- orig) :: !actions
1618+
| WithTrace trace -> trace.Push (fun () -> d.typar_constraints <- orig)
16171619
end;
16181620
d.typar_constraints <- newConstraints;
16191621

@@ -2404,7 +2406,7 @@ let EliminateConstraintsForGeneralizedTypars csenv trace (generalizedTypars: Typ
24042406
cxst.Remove tpn;
24052407
match trace with
24062408
| NoTrace -> ()
2407-
| WithTrace (Trace actions) -> actions := (fun () -> (csenv.SolverState.ExtraCxs.Add (tpn,cx))) :: !actions)
2409+
| WithTrace trace -> trace.Push (fun () -> (csenv.SolverState.ExtraCxs.Add (tpn,cx))))
24082410
)
24092411

24102412

src/fsharp/ConstraintSolver.fsi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ val BakedInTraitConstraintNames : string list
9898

9999
val MakeConstraintSolverEnv : ContextInfo -> ConstraintSolverState -> range -> DisplayEnv -> ConstraintSolverEnv
100100

101-
type Trace = Trace of (unit -> unit) list ref
101+
[<Sealed; NoEquality; NoComparison>]
102+
type Trace
102103

103104
type OptionalTrace =
104105
| NoTrace

src/fsharp/FSharp.Compiler-proto/FSharp.Compiler-proto.fsproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,6 @@
434434
<Compile Include="..\IlxGen.fs">
435435
<Link>IlxGen.fs</Link>
436436
</Compile>
437-
<Compile Include="..\TraceCall.fsi">
438-
<Link>TraceCall.fsi</Link>
439-
</Compile>
440-
<Compile Include="..\TraceCall.fs">
441-
<Link>TraceCall.fs</Link>
442-
</Compile>
443437
<Compile Include="..\CompileOps.fsi">
444438
<Link>CompileOps.fsi</Link>
445439
</Compile>

src/fsharp/FSharp.Compiler/FSharp.Compiler.fsproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,6 @@
141141
<Compile Include="..\lib.fs">
142142
<Link>Utilities\lib.fs</Link>
143143
</Compile>
144-
<Compile Include="..\TraceCall.fsi">
145-
<Link>Utilities\TraceCall.fsi</Link>
146-
</Compile>
147-
<Compile Include="..\TraceCall.fs">
148-
<Link>Utilities\TraceCall.fs</Link>
149-
</Compile>
150144
<Compile Include="..\rational.fsi">
151145
<Link>Utilities\rational.fsi</Link>
152146
</Compile>

src/fsharp/FSharp.LanguageService.Compiler/FSharp.LanguageService.Compiler.fsproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@
151151
<Compile Include="..\rational.fs">
152152
<Link>Utilities\rational.fs</Link>
153153
</Compile>
154-
<Compile Include="..\TraceCall.fs">
155-
<Link>Utilities\TraceCall.fs</Link>
156-
</Compile>
157154
<Compile Include="..\range.fsi">
158155
<Link>ErrorLogging\range.fsi</Link>
159156
</Compile>
@@ -564,7 +561,6 @@
564561
<Reference Include="System.Numerics" />
565562
<Reference Include="System.Drawing" />
566563
<Reference Include="System.Windows.Forms" />
567-
<Reference Include="System.Runtime.Remoting" />
568564
<Reference Include="Microsoft.VisualStudio.OLE.Interop.dll" />
569565
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0.dll" />
570566
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.11.0.dll" />

0 commit comments

Comments
 (0)