From 2f36fe6cf92ac99072404276b953496553ef9b14 Mon Sep 17 00:00:00 2001 From: ncave <777696+ncave@users.noreply.github.com> Date: Fri, 8 Dec 2023 15:06:44 -0800 Subject: [PATCH] Fixed merge --- fcs/fcs-fable/System.Collections.fs | 19 ++++++++++++++----- fcs/fcs-fable/TcImports_shim.fs | 2 +- fcs/fcs-fable/fcs-fable.fsproj | 4 ++-- fcs/fcs-fable/test/fcs-fable-test.fsproj | 2 +- global.json | 4 ++-- src/Compiler/AbstractIL/ilread.fs | 19 +++++++------------ src/Compiler/Checking/QuotationTranslator.fs | 4 ---- src/Compiler/CodeGen/IlxGen.fs | 4 ---- src/Compiler/TypedTree/TypedTreeOps.fs | 18 ------------------ src/Compiler/TypedTree/TypedTreeOps.fsi | 4 ---- src/Compiler/Utilities/Cancellable.fs | 8 ++++++++ 11 files changed, 35 insertions(+), 53 deletions(-) diff --git a/fcs/fcs-fable/System.Collections.fs b/fcs/fcs-fable/System.Collections.fs index b9776db3afa..c9cb4b270a3 100644 --- a/fcs/fcs-fable/System.Collections.fs +++ b/fcs/fcs-fable/System.Collections.fs @@ -34,6 +34,7 @@ module Immutable = type ImmutableArray<'T> = static member CreateBuilder() = ResizeArray<'T>() + [] type ImmutableHashSet<'T>(values: 'T seq) = let xs = HashSet<'T>(values) @@ -62,13 +63,21 @@ module Immutable = member _.GetEnumerator(): IEnumerator<'T> = xs.GetEnumerator() - type ImmutableDictionary<'Key, 'Value when 'Key: equality>(pairs: KeyValuePair<'Key, 'Value> seq) = - let xs = Dictionary<'Key, 'Value>() - do for pair in pairs do xs.Add(pair.Key, pair.Value) + [] + type ImmutableDictionary<'Key, 'Value when 'Key: equality>(xs: Dictionary<'Key, 'Value>) = + static member Create(comparer: IEqualityComparer<'Key>) = + ImmutableDictionary<'Key, 'Value>(Dictionary(comparer)) - static member CreateRange(items) = ImmutableDictionary<'Key, 'Value>(items) - static member Empty = ImmutableDictionary<'Key, 'Value>(Array.empty) + static member CreateRange(items: IEnumerable>) = + let xs = Dictionary<'Key, 'Value>() + for pair in items do + xs.Add(pair.Key, pair.Value) + ImmutableDictionary<'Key, 'Value>(xs) + static member Empty = + ImmutableDictionary<'Key, 'Value>(Dictionary()) + + member _.IsEmpty = xs.Count = 0 member _.Item with get (key: 'Key): 'Value = xs[key] member _.ContainsKey (key: 'Key) = xs.ContainsKey(key) diff --git a/fcs/fcs-fable/TcImports_shim.fs b/fcs/fcs-fable/TcImports_shim.fs index 226695c7aaf..b3eda77d9a2 100644 --- a/fcs/fcs-fable/TcImports_shim.fs +++ b/fcs/fcs-fable/TcImports_shim.fs @@ -176,7 +176,7 @@ module TcImports = XmlDocumentationInfo = None } - let optdata = lazy ( + let optdata = InterruptibleLazy(fun _ -> match memoize_opt.Apply ccuName with | None -> None | Some data -> diff --git a/fcs/fcs-fable/fcs-fable.fsproj b/fcs/fcs-fable/fcs-fable.fsproj index 9099407ed47..f12e26d9774 100644 --- a/fcs/fcs-fable/fcs-fable.fsproj +++ b/fcs/fcs-fable/fcs-fable.fsproj @@ -93,8 +93,8 @@ - - + + diff --git a/fcs/fcs-fable/test/fcs-fable-test.fsproj b/fcs/fcs-fable/test/fcs-fable-test.fsproj index bcc9b5414e2..ccaf13c1aaa 100644 --- a/fcs/fcs-fable/test/fcs-fable-test.fsproj +++ b/fcs/fcs-fable/test/fcs-fable-test.fsproj @@ -20,7 +20,7 @@ - + diff --git a/global.json b/global.json index 365652e8f7e..95f24805cb6 100644 --- a/global.json +++ b/global.json @@ -1,10 +1,10 @@ { "sdk": { - "version": "8.0.100-rc.1.23463.5", + "version": "8.0.100", "allowPrerelease": true }, "tools": { - "dotnet": "8.0.100-rc.1.23463.5", + "dotnet": "8.0.100", "vs": { "version": "17.6", "components": [ diff --git a/src/Compiler/AbstractIL/ilread.fs b/src/Compiler/AbstractIL/ilread.fs index bf84f039b60..854f6e0be9a 100644 --- a/src/Compiler/AbstractIL/ilread.fs +++ b/src/Compiler/AbstractIL/ilread.fs @@ -1219,19 +1219,14 @@ type ISeekReadIndexedRowReader<'RowT, 'KeyT, 'T when 'RowT: struct> = abstract CompareKey: 'KeyT -> int abstract ConvertRow: ref<'RowT> -> 'T -#if FABLE_COMPILER [] type CustomAttributeRow = val mutable parentIndex: TaggedIndex val mutable typeIndex: TaggedIndex val mutable valueIndex: int -let seekReadIndexedRowsRange numRows binaryChop (reader: ISeekReadIndexedRowReader) = +let seekReadIndexedRowsRange numRows binaryChop (reader: ISeekReadIndexedRowReader) = let mutable row = ref Unchecked.defaultof -#else -let seekReadIndexedRowsRange numRows binaryChop (reader: ISeekReadIndexedRowReader<'RowT, _, _>) = - let mutable row = Unchecked.defaultof<'RowT> -#endif let mutable startRid = -1 let mutable endRid = -1 @@ -1310,9 +1305,9 @@ let seekReadIndexedRowsRange numRows binaryChop (reader: ISeekReadIndexedRowRead let mutable fin = false while rid <= numRows && not fin do - reader.GetRow(rid, &row) + reader.GetRow(rid, row) - if reader.CompareKey(reader.GetKey(&row)) = 0 then + if reader.CompareKey(reader.GetKey(row)) = 0 then endRid <- rid else fin <- true @@ -1321,7 +1316,7 @@ let seekReadIndexedRowsRange numRows binaryChop (reader: ISeekReadIndexedRowRead startRid, endRid -let seekReadIndexedRowsByInterface numRows binaryChop (reader: ISeekReadIndexedRowReader<'RowT, _, _>) = +let seekReadIndexedRowsByInterface numRows binaryChop (reader: ISeekReadIndexedRowReader) = let startRid, endRid = seekReadIndexedRowsRange numRows binaryChop reader if startRid <= 0 || endRid < startRid then @@ -1329,9 +1324,9 @@ let seekReadIndexedRowsByInterface numRows binaryChop (reader: ISeekReadIndexedR else Array.init (endRid - startRid + 1) (fun i -> - let mutable row = Unchecked.defaultof<'RowT> - reader.GetRow(startRid + i, &row) - reader.ConvertRow(&row)) + let mutable row = ref Unchecked.defaultof + reader.GetRow(startRid + i, row) + reader.ConvertRow(row)) let inline rowAddr (ctxt: ILMetadataReader) (tn: TableName) (idx: int) = ref (ctxt.rowAddr tn idx) diff --git a/src/Compiler/Checking/QuotationTranslator.fs b/src/Compiler/Checking/QuotationTranslator.fs index 04f69016123..b7dd2b1c7f3 100644 --- a/src/Compiler/Checking/QuotationTranslator.fs +++ b/src/Compiler/Checking/QuotationTranslator.fs @@ -718,13 +718,9 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. let witnessArgInfo = if g.generateWitnesses && inWitnessPassingScope then let witnessInfo = traitInfo.GetWitnessInfo() -#if FABLE_COMPILER - env.witnessesInScope.TryFind witnessInfo -#else match env.witnessesInScope.TryGetValue witnessInfo with | true, storage -> Some storage | _ -> None -#endif else None diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 89179f27cd1..b7492a6836b 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -1318,13 +1318,9 @@ let ComputeGenerateWitnesses (g: TcGlobals) eenv = && not eenv.suppressWitnesses let TryStorageForWitness (_g: TcGlobals) eenv (w: TraitWitnessInfo) = -#if FABLE_COMPILER - eenv.witnessesInScope.TryFind w -#else match eenv.witnessesInScope.TryGetValue w with | true, storage -> Some storage | _ -> None -#endif let IsValRefIsDllImport g (vref: ValRef) = vref.Attribs |> HasFSharpAttributeOpt g g.attrib_DllImportAttribute diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs index a0253933a1d..2034d5ecb20 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.fs @@ -10293,23 +10293,6 @@ let CombineCcuContentFragments l = /// An immutable mappping from witnesses to some data. /// /// Note: this uses an immutable HashMap/Dictionary with an IEqualityComparer that captures TcGlobals, see EmptyTraitWitnessInfoHashMap -#if FABLE_COMPILER -type TraitWitnessInfoHashMap<'T> = Internal.Utilities.Collections.Tagged.Map - -/// Create an empty immutable mapping from witnesses to some data -let EmptyTraitWitnessInfoHashMap g : TraitWitnessInfoHashMap<'T> = - let comparer = - { new IComparer with - member _.Compare(x, y) = - let xhash = hash x - let yhash = hash y - let equals x y = traitKeysAEquiv g TypeEquivEnv.Empty x y - if xhash = yhash - then if equals x y then 0 else -1 - else if xhash < yhash then -1 else 1 - } - Internal.Utilities.Collections.Tagged.Map<_,_>.FromList(comparer, []) -#else //!FABLE_COMPILER type TraitWitnessInfoHashMap<'T> = ImmutableDictionary /// Create an empty immutable mapping from witnesses to some data @@ -10319,7 +10302,6 @@ let EmptyTraitWitnessInfoHashMap g : TraitWitnessInfoHashMap<'T> = member _.Equals(a, b) = traitKeysAEquiv g TypeEquivEnv.Empty a b member _.GetHashCode(a) = hash a.MemberName }) -#endif //!FABLE_COMPILER let (|WhileExpr|_|) expr = match expr with diff --git a/src/Compiler/TypedTree/TypedTreeOps.fsi b/src/Compiler/TypedTree/TypedTreeOps.fsi index 1dde299a1ff..f2fa42412e7 100755 --- a/src/Compiler/TypedTree/TypedTreeOps.fsi +++ b/src/Compiler/TypedTree/TypedTreeOps.fsi @@ -2585,11 +2585,7 @@ val GetTraitWitnessInfosOfTypars: TcGlobals -> numParentTypars: int -> typars: T /// An immutable mappping from witnesses to some data. /// /// Note: this uses an immutable HashMap/Dictionary with an IEqualityComparer that captures TcGlobals, see EmptyTraitWitnessInfoHashMap -#if FABLE_COMPILER -type TraitWitnessInfoHashMap<'T> = Internal.Utilities.Collections.Tagged.Map -#else type TraitWitnessInfoHashMap<'T> = ImmutableDictionary -#endif /// Create an empty immutable mapping from witnesses to some data val EmptyTraitWitnessInfoHashMap: TcGlobals -> TraitWitnessInfoHashMap<'T> diff --git a/src/Compiler/Utilities/Cancellable.fs b/src/Compiler/Utilities/Cancellable.fs index 81bb140f6ef..ec5036027bd 100644 --- a/src/Compiler/Utilities/Cancellable.fs +++ b/src/Compiler/Utilities/Cancellable.fs @@ -47,10 +47,14 @@ module Cancellable = if ct.IsCancellationRequested then ValueOrCancelled.Cancelled(OperationCanceledException ct) else +#if FABLE_COMPILER + oper ct +#else try oper ct with :? OperationCanceledException as e -> ValueOrCancelled.Cancelled(OperationCanceledException e.CancellationToken) +#endif let fold f acc seq = Cancellable(fun ct -> @@ -142,7 +146,11 @@ type CancellableBuilder() = | Choice2Of2 err -> Cancellable.run ct (handler err) | ValueOrCancelled.Cancelled err1 -> ValueOrCancelled.Cancelled err1) +#if FABLE_COMPILER + member inline _.Using(resource: 'Resource when 'Resource :> IDisposable, [] comp) = +#else member inline _.Using(resource, [] comp) = +#endif Cancellable(fun ct -> #if !FSHARPCORE_USE_PACKAGE __debugPoint ""