未验证 提交 31803ec2 编写于 作者: D dotnet bot 提交者: GitHub

Merge pull request #12912 from dotnet/merges/main-to-release/dev17.2

Merge main to release/dev17.2
......@@ -1250,16 +1250,12 @@ let ComputeFieldSpecForVal(optIntraAssemblyInfo: IlxGenIntraAssemblyInfo option,
match optIntraAssemblyInfo with
| None -> generate()
| Some intraAssemblyInfo ->
if vspec.IsMutable && vspec.IsCompiledAsTopLevel && isStructTy g vspec.Type then
let ok, res = intraAssemblyInfo.StaticFieldInfo.TryGetValue ilGetterMethRef
if ok then
res
else
let res = generate()
intraAssemblyInfo.StaticFieldInfo.[ilGetterMethRef] <- res
res
else
generate()
match intraAssemblyInfo.StaticFieldInfo.TryGetValue ilGetterMethRef with
| true, res -> res
| _ ->
let res = generate()
intraAssemblyInfo.StaticFieldInfo.[ilGetterMethRef] <- res
res
/// Compute the representation information for an F#-declared value (not a member nor a function).
/// Mutable and literal static fields must have stable names and live in the "public" location
......
#light
[<RequireQualifiedAccess>]
module app.date
open System
open System.Threading
type T = private T of DateTime
let mutable private _today = None
let set_today (dt:DateTime) = Interlocked.Exchange(&_today, Some (T dt.Date))
let today () =
match _today with
| Some d -> d
| None -> T DateTime.Today.Date
let yesterday () =
let today = DateTime.Today.Date
T (today - TimeSpan(1, 0, 0, 0))
let inline private unwrap (T d) = d
let fromdt (dt:DateTime) = T dt.Date
let year d = (unwrap d).Year
#light
[<RequireQualifiedAccess>]
module app.env
open System
//open System.Runtime.CompilerServices
open System.Threading
let mutable private _processing_date:date.T option = None
let mutable private _irs_received_date:date.T option = None
//[<MethodImpl (MethodImplOptions.NoInlining)>]
let set_processing_date d = Interlocked.Exchange(&_processing_date, Some d)
//[<MethodImpl (MethodImplOptions.NoInlining)>]
let set_irs_received_dt d = Interlocked.Exchange(&_irs_received_date, Some d)
let processing_date () =
match _processing_date with
| Some d -> d
| None -> date.fromdt DateTime.Today
let processing_year () =
let d = processing_date ()
date.year d
let tax_year () =
let yr = processing_year ()
yr - 1
let irs_received_date () = _irs_received_date
let irs_received_date_exn () =
match _irs_received_date with
| Some d -> d
| None -> failwith "env.irs_received_date uninitialized via set_irs_received_dt"
#light
module app.main
open System
let private init_dates rdate pdate =
match rdate with
| Some d -> env.set_irs_received_dt d |> ignore
| None -> ()
match pdate with
| Some d -> env.set_processing_date d |> ignore
| None -> ()
[<EntryPoint>]
let main argv =
try
let rdate = Some (date.yesterday ())
let pdate = Some (date.today () )
init_dates rdate pdate
with
| ex -> eprintfn "Unhandled exception: %s" (ex.ToString()) ; exit 1
0
......@@ -2143,6 +2143,11 @@ module RegressionTests =
[<Test >]
let ``12383-FSC_OPTIMIZED`` () = singleTestBuildAndRun "regression/12383" FSC_OPTIMIZED
[<Test >]
let ``4715-optimized`` () =
let cfg = testConfig "regression/4715"
fsc cfg "%s -o:test.exe --optimize+" cfg.fsc_flags ["date.fs"; "env.fs"; "main.fs"]
#if NETCOREAPP
[<Test >]
let ``Large inputs 12322 fsc.dll 64-bit fsc.dll .NET SDK generating optimized code`` () =
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册