From c8f22cd4d827536cbf1110091d0fb87a9d6c10d0 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Wed, 28 Aug 2024 03:20:35 +0200 Subject: [PATCH 1/9] Change format + fix for `--richerrors` (#17614) --- src/Compiler/Driver/CompilerDiagnostics.fs | 52 ++++++++++++++------- src/Compiler/Driver/CompilerDiagnostics.fsi | 3 +- src/Compiler/Driver/CompilerOptions.fs | 1 + 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index df5a27cabbe..1c50ca26781 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -2045,6 +2045,7 @@ type FormattedDiagnosticDetailedInfo = Canonical: FormattedDiagnosticCanonicalInformation Message: string Context: string option + DiagnosticStyle: DiagnosticStyle } [] @@ -2118,7 +2119,7 @@ let FormatDiagnosticLocation (tcConfig: TcConfig) (m: Range) : FormattedDiagnost | DiagnosticStyle.Rich -> let file = file.Replace('/', Path.DirectorySeparatorChar) let m = withStart (mkPos m.StartLine (m.StartColumn + 1)) m - (sprintf "◦→ %s (%d,%d)" file m.StartLine m.StartColumn), m, file + (sprintf "\n --> %s (%d,%d)" file m.StartLine m.StartColumn), m, file { Range = m @@ -2164,7 +2165,7 @@ let CollectFormattedDiagnostics (tcConfig: TcConfig, severity: FSharpDiagnosticS | DiagnosticStyle.Default | DiagnosticStyle.Test -> sprintf "%s FS%04d: " message errorNumber | DiagnosticStyle.VisualStudio -> sprintf "%s %s FS%04d: " subcategory message errorNumber - | DiagnosticStyle.Rich -> sprintf "\n◦→ %s FS%04d: " message errorNumber + | DiagnosticStyle.Rich -> sprintf "%s FS%04d: " message errorNumber let canonical: FormattedDiagnosticCanonicalInformation = { @@ -2179,11 +2180,8 @@ let CollectFormattedDiagnostics (tcConfig: TcConfig, severity: FSharpDiagnosticS | DiagnosticStyle.Gcc | DiagnosticStyle.Default | DiagnosticStyle.Test + | DiagnosticStyle.Rich | DiagnosticStyle.VisualStudio -> diagnostic.FormatCore(tcConfig.flatErrors, suggestNames) - | DiagnosticStyle.Rich -> - diagnostic.FormatCore(tcConfig.flatErrors, suggestNames).Split([| '\n' |]) - |> Array.map (fun msg -> "\n◦ " + msg) - |> String.Concat let context = match tcConfig.diagnosticStyle with @@ -2201,14 +2199,14 @@ let CollectFormattedDiagnostics (tcConfig: TcConfig, severity: FSharpDiagnosticS |> System.IO.File.ReadAllLines if m.StartLine = m.EndLine then - $"\n◦ {m.StartLine} |{content[m.StartLine - 1]}\n" - + $"""◦ {String.init (m.StartColumn + 3) (fun _ -> " ")}^{String.init (m.EndColumn - m.StartColumn) (fun _ -> "~")}""" + $"\n {m.StartLine} | {content[m.StartLine - 1]}\n" + + $"""{String.make (m.StartColumn + 6) ' '}{String.make (m.EndColumn - m.StartColumn) '^'}""" |> Some else content |> fun lines -> Array.sub lines (m.StartLine - 1) (m.EndLine - m.StartLine - 1) |> Array.fold - (fun (context, lineNumber) line -> (context + $"\n◦ {lineNumber} |{line}", lineNumber + 1)) + (fun (context, lineNumber) line -> (context + $"\n{lineNumber} | {line}", lineNumber + 1)) ("", (m.StartLine)) |> fst |> Some @@ -2220,6 +2218,7 @@ let CollectFormattedDiagnostics (tcConfig: TcConfig, severity: FSharpDiagnosticS Context = context Canonical = canonical Message = message + DiagnosticStyle = tcConfig.diagnosticStyle } errors.Add(FormattedDiagnostic.Long(severity, entry)) @@ -2247,16 +2246,33 @@ type PhasedDiagnostic with match e with | FormattedDiagnostic.Short(_, txt) -> buf.AppendString txt | FormattedDiagnostic.Long(_, details) -> - match details.Location with - | Some l when not l.IsEmpty -> - buf.AppendString l.TextRepresentation - // Because details.Context depends on the value of details.Location, if details.Location is not None, details.Context can be accessed directly. - if details.Context.IsSome then - buf.AppendString details.Context.Value - | _ -> () + match details.DiagnosticStyle with + | DiagnosticStyle.Emacs + | DiagnosticStyle.Gcc + | DiagnosticStyle.Test + | DiagnosticStyle.VisualStudio + | DiagnosticStyle.Default -> + match details.Location with + | Some l when not l.IsEmpty -> + buf.AppendString l.TextRepresentation + + if details.Context.IsSome then + buf.AppendString details.Context.Value + | _ -> () + + buf.AppendString details.Canonical.TextRepresentation + buf.AppendString details.Message + | DiagnosticStyle.Rich -> + buf.AppendString details.Canonical.TextRepresentation + buf.AppendString details.Message + + match details.Location with + | Some l when not l.IsEmpty -> + buf.AppendString l.TextRepresentation - buf.AppendString details.Canonical.TextRepresentation - buf.AppendString details.Message + if details.Context.IsSome then + buf.AppendString details.Context.Value + | _ -> () member diagnostic.OutputContext(buf, prefix, fileLineFunction) = match diagnostic.Range with diff --git a/src/Compiler/Driver/CompilerDiagnostics.fsi b/src/Compiler/Driver/CompilerDiagnostics.fsi index a7a088b1627..6139da434cf 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fsi +++ b/src/Compiler/Driver/CompilerDiagnostics.fsi @@ -114,7 +114,8 @@ type FormattedDiagnosticDetailedInfo = { Location: FormattedDiagnosticLocation option Canonical: FormattedDiagnosticCanonicalInformation Message: string - Context: string option } + Context: string option + DiagnosticStyle: DiagnosticStyle } /// Used internally and in LegacyHostedCompilerForTesting [] diff --git a/src/Compiler/Driver/CompilerOptions.fs b/src/Compiler/Driver/CompilerOptions.fs index c30254c99e2..96c40724ef4 100644 --- a/src/Compiler/Driver/CompilerOptions.fs +++ b/src/Compiler/Driver/CompilerOptions.fs @@ -1395,6 +1395,7 @@ let testFlag tcConfigB = let editorSpecificFlags (tcConfigB: TcConfigBuilder) = [ CompilerOption("vserrors", tagNone, OptionUnit(fun () -> tcConfigB.diagnosticStyle <- DiagnosticStyle.VisualStudio), None, None) + CompilerOption("richerrors", tagNone, OptionUnit(fun () -> tcConfigB.diagnosticStyle <- DiagnosticStyle.Rich), None, None) CompilerOption("validate-type-providers", tagNone, OptionUnit id, None, None) // preserved for compatibility's sake, no longer has any effect CompilerOption("LCID", tagInt, OptionInt ignore, None, None) CompilerOption("flaterrors", tagNone, OptionUnit(fun () -> tcConfigB.flatErrors <- true), None, None) From 74f29cdea0367482aee6bc9c02df338f5fdeb31f Mon Sep 17 00:00:00 2001 From: Martin <29605222+Martin521@users.noreply.github.com> Date: Wed, 28 Aug 2024 13:03:33 +0200 Subject: [PATCH 2/9] Move test delaying startup code to the test it belongs to (#17612) --- .../TypeChecks/Graph/CompilationTests.fs | 5 ++- .../Graph/DependencyResolutionTests.fs | 12 ++++--- .../TypeChecks/Graph/Scenarios.fs | 31 ++++++++----------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/CompilationTests.fs b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/CompilationTests.fs index 14244f46ad8..4142b10565f 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/CompilationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/CompilationTests.fs @@ -28,8 +28,7 @@ let compileAValidScenario (scenario: Scenario) (method: Method) = let cUnit = let files = scenario.Files - |> Array.map (fun (f: FileInScenario) -> SourceCodeFileKind.Create(f.FileWithAST.File, f.Content)) - |> Array.toList + |> List.map (fun (f: FileInScenario) -> SourceCodeFileKind.Create(f.FileName, f.Content)) match files with | [] -> failwith "empty files" @@ -44,7 +43,7 @@ let compileAValidScenario (scenario: Scenario) (method: Method) = |> shouldSucceed |> ignore -let scenarios = codebases |> List.map (fun c -> [| box c |]) |> Array.ofList +let scenarios = scenarios |> List.map (fun c -> [| box c |]) [] [] diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/DependencyResolutionTests.fs b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/DependencyResolutionTests.fs index 13032b88548..36a246d6ced 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/DependencyResolutionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/DependencyResolutionTests.fs @@ -5,15 +5,17 @@ open NUnit.Framework open FSharp.Compiler.GraphChecking open Scenarios -let scenarios = codebases - [] let ``Supported scenario`` (scenario: Scenario) = - let files = scenario.Files |> Array.map (fun f -> TestFileWithAST.Map f.FileWithAST) + let files = + scenario.Files + |> List.map (fun f -> + {Idx = f.Index; FileName = f.FileName; ParsedInput = parseSourceCode(f.FileName, f.Content)}) + |> List.toArray let filePairs = FilePairMap(files) let graph, _trie = DependencyResolution.mkGraph filePairs files for file in scenario.Files do let expectedDeps = file.ExpectedDependencies - let actualDeps = set graph.[file.FileWithAST.Idx] - Assert.AreEqual(expectedDeps, actualDeps, $"Dependencies don't match for {System.IO.Path.GetFileName file.FileWithAST.File}") + let actualDeps = set graph.[file.Index] + Assert.AreEqual(expectedDeps, actualDeps, $"Dependencies don't match for {System.IO.Path.GetFileName file.FileName}") diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs index 6ab98da50eb..5126282048c 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs @@ -2,41 +2,36 @@ open TestUtils +type FileInScenario = + { + Index: int + FileName: string + ExpectedDependencies: Set + Content: string + } + type Scenario = { Name: string - Files: FileInScenario array + Files: FileInScenario list } override x.ToString() = x.Name -and FileInScenario = - { - FileWithAST: TestFileWithAST - ExpectedDependencies: Set - Content: string - } - let private scenario name files = - let files = files |> List.toArray |> Array.mapi (fun idx f -> f idx) + let files = files |> List.mapi (fun idx f -> f idx) { Name = name; Files = files } let private sourceFile fileName content (dependencies: Set) = fun idx -> - let fileWithAST = - { - Idx = idx - AST = parseSourceCode (fileName, content) - File = fileName - } - { - FileWithAST = fileWithAST + Index = idx + FileName = fileName ExpectedDependencies = dependencies Content = content } -let internal codebases = +let internal scenarios = [ scenario "Link via full open statement" From 673bc4832093b56962a3e97c2fa5ca996f7a186d Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:20:37 +0200 Subject: [PATCH 3/9] Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20240826.2 (#17616) Microsoft.SourceBuild.Intermediate.source-build-reference-packages From Version 10.0.0-alpha.1.24421.1 -> To Version 10.0.0-alpha.1.24426.2 Co-authored-by: dotnet-maestro[bot] --- eng/Version.Details.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index a8e8f13c8ed..15fa9dbe840 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,9 +1,9 @@ - + https://github.com/dotnet/source-build-reference-packages - bdd698774daa248301c236f09b97015610ca2842 + 6c26545ca7999a4192df6899ea9ed4eaa950d367 From 99c200f7f3f86c42c421a818ff9d79382f41f5b8 Mon Sep 17 00:00:00 2001 From: Brian Rourke Boll Date: Wed, 28 Aug 2024 09:24:19 -0400 Subject: [PATCH 4/9] Keep extra parens around unit & tuples in arg pats (#17618) * Keep extra parens around unit & tuples in arg pats * There are several scenarios where it is impossible to know whether the parentheses are required, or whethery they may affect compilation, by looking only at the syntax. --- .../.FSharp.Compiler.Service/9.0.100.md | 1 + src/Compiler/Service/SynPat.fs | 34 ++++++------------- .../RemoveUnnecessaryParenthesesTests.fs | 22 ++++++++++-- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md index d3e795bf8b7..12adae55598 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md @@ -12,6 +12,7 @@ * MethodAccessException on equality comparison of a type private to module. ([Issue #17541](https://github.com/dotnet/fsharp/issues/17541), [PR #17548](https://github.com/dotnet/fsharp/pull/17548)) * Fixed checking failure when `global` namespace is involved with enabled GraphBasedChecking ([PR #17553](https://github.com/dotnet/fsharp/pull/17553)) * Add missing byte chars notations, enforce limits in decimal notation in byte char & string (Issues [#15867](https://github.com/dotnet/fsharp/issues/15867), [#15868](https://github.com/dotnet/fsharp/issues/15868), [#15869](https://github.com/dotnet/fsharp/issues/15869), [PR #15898](https://github.com/dotnet/fsharp/pull/15898)) +* Parentheses analysis: keep extra parentheses around unit & tuples in method definitions. ([PR #17618](https://github.com/dotnet/fsharp/pull/17618)) ### Added diff --git a/src/Compiler/Service/SynPat.fs b/src/Compiler/Service/SynPat.fs index 8ed9cd69ff1..c94448ce318 100644 --- a/src/Compiler/Service/SynPat.fs +++ b/src/Compiler/Service/SynPat.fs @@ -28,23 +28,6 @@ module SynPat = else ValueNone - /// Matches if any member in the given list is an inherit - /// or implementation of an interface with generic type args. - [] - let (|AnyGenericInheritOrInterfaceImpl|_|) members = - if - members - |> List.exists (function - | SynMemberDefn.ImplicitInherit(inheritType = SynType.App(typeArgs = _ :: _)) - | SynMemberDefn.ImplicitInherit(inheritType = SynType.LongIdentApp(typeArgs = _ :: _)) - | SynMemberDefn.Interface(interfaceType = SynType.App(typeArgs = _ :: _)) - | SynMemberDefn.Interface(interfaceType = SynType.LongIdentApp(typeArgs = _ :: _)) -> true - | _ -> false) - then - ValueSome AnyGenericInheritOrInterfaceImpl - else - ValueNone - /// Matches the rightmost potentially dangling nested pattern. let rec (|Rightmost|) pat = match pat with @@ -182,15 +165,20 @@ module SynPat = // type C<'T> = abstract M : 'T -> unit // let _ = { new C with override _.M (()) = () } // let _ = { new C with override _.M ((x, y)) = () } + // + // Single versus double parens are also compiled differently in cases like these: + // + // type T = + // static member M () = () // .method public static void M() + // static member M (()) = () // .method public static void M(class [FSharp.Core]Microsoft.FSharp.Core.Unit _arg1) + // static member M (_ : int, _ : int) = () // .method public static void M(int32 _arg1, int32 _arg2) + // static member M ((_ : int, _ : int)) = () // .method public static void M(class [System.Runtime]System.Tuple`2 _arg1) | SynPat.Paren((SynPat.Const(SynConst.Unit, _) | SynPat.Tuple(isStruct = false)), _), - SyntaxNode.SynPat(SynPat.LongIdent _) :: SyntaxNode.SynBinding _ :: SyntaxNode.SynExpr(SynExpr.ObjExpr( - objType = SynType.App(typeArgs = _ :: _) | SynType.LongIdentApp(typeArgs = _ :: _))) :: _ + SyntaxNode.SynPat(SynPat.LongIdent _) :: SyntaxNode.SynBinding _ :: _ | SynPat.Tuple(isStruct = false), - SyntaxNode.SynPat(SynPat.Paren _) :: SyntaxNode.SynPat(SynPat.LongIdent _) :: SyntaxNode.SynBinding _ :: SyntaxNode.SynExpr(SynExpr.ObjExpr( - objType = SynType.App(typeArgs = _ :: _) | SynType.LongIdentApp(typeArgs = _ :: _))) :: _ + SyntaxNode.SynPat(SynPat.Paren _) :: SyntaxNode.SynPat(SynPat.LongIdent _) :: SyntaxNode.SynBinding _ :: _ | SynPat.Paren((SynPat.Const(SynConst.Unit, _) | SynPat.Tuple(isStruct = false)), _), - SyntaxNode.SynPat(SynPat.LongIdent _) :: SyntaxNode.SynBinding _ :: SyntaxNode.SynMemberDefn _ :: SyntaxNode.SynTypeDefn(SynTypeDefn( - typeRepr = SynTypeDefnRepr.ObjectModel(members = AnyGenericInheritOrInterfaceImpl))) :: _ -> true + SyntaxNode.SynPat(SynPat.LongIdent _) :: SyntaxNode.SynBinding _ :: SyntaxNode.SynMemberDefn _ :: _ -> true // Not required: // diff --git a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs index 1994c5a7dac..b9b95bc44ac 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs @@ -2801,7 +2801,15 @@ module Patterns = expectFix code expected - let bareAtomics = fmtAllAsMemberData bareAtomics + let bareAtomics = + bareAtomics + |> List.map (function + // We can't actually reliably remove the extra parens in argument patterns, + // since they affect compilation. + // See https://github.com/dotnet/fsharp/issues/17611, https://github.com/dotnet/fsharp/issues/16254, etc. + | SynPat.Paren(SynPat.Const "()") as doubleParen, _ -> doubleParen, doubleParen + | pats -> pats) + |> fmtAllAsMemberData let bareNonAtomics = patterns @@ -2825,7 +2833,15 @@ module Patterns = let expected = $"type T () = member _.M %s{expected} = Unchecked.defaultof<_>" expectFix code expected - let bareAtomics = fmtAllAsMemberData bareAtomics + let bareAtomics = + bareAtomics + |> List.map (function + // We can't actually reliably remove the extra parens in argument patterns, + // since they affect compilation. + // See https://github.com/dotnet/fsharp/issues/17611, https://github.com/dotnet/fsharp/issues/16254, etc. + | SynPat.Paren(SynPat.Const "()") as doubleParen, _ -> doubleParen, doubleParen + | pats -> pats) + |> fmtAllAsMemberData let bareNonAtomics = patterns @@ -2959,7 +2975,7 @@ module Patterns = ", " type C = abstract M : unit -> unit - let _ = { new C with override _.M () = () } + let _ = { new C with override _.M (()) = () } " // See https://github.com/dotnet/fsharp/issues/16254. From 7b810126607015885d03cbceff91763bd879633d Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:09:30 +0000 Subject: [PATCH 5/9] Update dependencies from https://github.com/dotnet/arcade build 20240826.3 (#17615) Microsoft.SourceBuild.Intermediate.arcade , Microsoft.DotNet.Arcade.Sdk From Version 9.0.0-beta.24423.2 -> To Version 9.0.0-beta.24426.3 Co-authored-by: dotnet-maestro[bot] Co-authored-by: Tomas Grosup --- eng/Version.Details.xml | 8 ++++---- global.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 15fa9dbe840..b8542208053 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -42,14 +42,14 @@ - + https://github.com/dotnet/arcade - 91599268652b51969b8d8088d4f2f2ba7b3ebb19 + e3bdd9a0f2a65fe037ba1adb2261eea48a840fa4 - + https://github.com/dotnet/arcade - 91599268652b51969b8d8088d4f2f2ba7b3ebb19 + e3bdd9a0f2a65fe037ba1adb2261eea48a840fa4 diff --git a/global.json b/global.json index b4b05fd67f6..0735b7776bb 100644 --- a/global.json +++ b/global.json @@ -17,7 +17,7 @@ "perl": "5.38.2.2" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.24423.2", + "Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.24426.3", "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2" } } From 407658e0bc3a32a9cf33e4c1255406c975684ec8 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Thu, 29 Aug 2024 10:10:57 +0200 Subject: [PATCH 6/9] Increase Linux and macOS timeouts (#17627) --- azure-pipelines-PR.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azure-pipelines-PR.yml b/azure-pipelines-PR.yml index f182f8b9e10..f45db281b20 100644 --- a/azure-pipelines-PR.yml +++ b/azure-pipelines-PR.yml @@ -546,6 +546,7 @@ stages: - job: Linux pool: vmImage: $(UbuntuMachineQueueName) + timeoutInMinutes: 120 variables: - name: _SignType value: Test @@ -586,6 +587,7 @@ stages: - job: MacOS pool: vmImage: macos-12 + timeoutInMinutes: 120 variables: - name: _SignType value: Test From 82981fbeb280d6aaeff1542c4093bf2449ac9e2a Mon Sep 17 00:00:00 2001 From: Alex Berezhnykh Date: Thu, 29 Aug 2024 11:11:23 +0300 Subject: [PATCH 7/9] Optimize type interfaces reading from metadata (#17382) --- .../.FSharp.Compiler.Service/9.0.100.md | 2 + src/Compiler/AbstractIL/ilread.fs | 48 +++++++++++-------- ...ervice.SurfaceArea.netstandard20.debug.bsl | 17 ------- ...vice.SurfaceArea.netstandard20.release.bsl | 17 ------- 4 files changed, 29 insertions(+), 55 deletions(-) diff --git a/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md index 12adae55598..b23aae2e37a 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md @@ -36,4 +36,6 @@ * Applied nullable reference types to FSharp.Compiler.Service itself ([PR #15310](https://github.com/dotnet/fsharp/pull/15310)) * Ensure that isinteractive multi-emit backing fields are not public. ([Issue #17439](https://github.com/dotnet/fsharp/issues/17438)), ([PR #17439](https://github.com/dotnet/fsharp/pull/17439)) * Better error reporting for unions with duplicated fields. ([PR #17521](https://github.com/dotnet/fsharp/pull/17521)) +* Optimize ILTypeDef interface impls reading from metadata. ([PR #17382](https://github.com/dotnet/fsharp/pull/17382)) + ### Breaking Changes diff --git a/src/Compiler/AbstractIL/ilread.fs b/src/Compiler/AbstractIL/ilread.fs index 5dcc051ab9f..0ff6896f82d 100644 --- a/src/Compiler/AbstractIL/ilread.fs +++ b/src/Compiler/AbstractIL/ilread.fs @@ -1425,16 +1425,10 @@ let seekReadParamRow (ctxt: ILMetadataReader) mdv idx = (flags, seq, nameIdx) /// Read Table InterfaceImpl. -let private seekReadInterfaceImplRow (ctxt: ILMetadataReader) mdv idx = +let private seekReadInterfaceIdx (ctxt: ILMetadataReader) mdv idx = let mutable addr = ctxt.rowAddr TableNames.InterfaceImpl idx - let tidx = seekReadUntaggedIdx TableNames.TypeDef ctxt mdv &addr - let intfIdx = seekReadTypeDefOrRefOrSpecIdx ctxt mdv &addr - - struct {| - TypeIdx = tidx - IntfIdx = intfIdx - IntImplIdx = idx - |} + let _tidx = seekReadUntaggedIdx TableNames.TypeDef ctxt mdv &addr + seekReadTypeDefOrRefOrSpecIdx ctxt mdv &addr /// Read Table MemberRef. let seekReadMemberRefRow (ctxt: ILMetadataReader) mdv idx = @@ -1653,11 +1647,11 @@ let seekReadGenericParamRow (ctxt: ILMetadataReader) mdv idx = (idx, seq, flags, ownerIdx, nameIdx) // Read Table GenericParamConstraint. -let seekReadGenericParamConstraintRow (ctxt: ILMetadataReader) mdv idx = +let seekReadGenericParamConstraintIdx (ctxt: ILMetadataReader) mdv idx = let mutable addr = ctxt.rowAddr TableNames.GenericParamConstraint idx - let pidx = seekReadUntaggedIdx TableNames.GenericParam ctxt mdv &addr + let _pidx = seekReadUntaggedIdx TableNames.GenericParam ctxt mdv &addr let constraintIdx = seekReadTypeDefOrRefOrSpecIdx ctxt mdv &addr - (pidx, constraintIdx) + constraintIdx /// Read Table ILMethodSpec. let seekReadMethodSpecRow (ctxt: ILMetadataReader) mdv idx = @@ -2248,11 +2242,16 @@ and seekReadNestedTypeDefs (ctxt: ILMetadataReader) tidx = and seekReadInterfaceImpls (ctxt: ILMetadataReader) mdv numTypars tidx = seekReadIndexedRows ( ctxt.getNumRows TableNames.InterfaceImpl, - seekReadInterfaceImplRow ctxt mdv, - (fun x -> x.TypeIdx), - simpleIndexCompare tidx, + id, + id, + (fun idx -> + let mutable addr = ctxt.rowAddr TableNames.InterfaceImpl idx + let _tidx = seekReadUntaggedIdx TableNames.TypeDef ctxt mdv &addr + simpleIndexCompare tidx _tidx), isSorted ctxt TableNames.InterfaceImpl, - (fun x -> (seekReadTypeDefOrRef ctxt numTypars AsObject [] x.IntfIdx), (ctxt.customAttrsReader_InterfaceImpl, x.IntImplIdx)) + (fun idx -> + let intfIdx = seekReadInterfaceIdx ctxt mdv idx + seekReadTypeDefOrRef ctxt numTypars AsObject [] intfIdx, (ctxt.customAttrsReader_InterfaceImpl, idx)) ) and seekReadGenericParams ctxt numTypars (a, b) : ILGenericParameterDefs = @@ -2262,12 +2261,14 @@ and seekReadGenericParamsUncached ctxtH (GenericParamsIdx(numTypars, a, b)) = let (ctxt: ILMetadataReader) = getHole ctxtH let mdv = ctxt.mdfile.GetView() + let key = TaggedIndex(a, b) + let pars = seekReadIndexedRows ( ctxt.getNumRows TableNames.GenericParam, seekReadGenericParamRow ctxt mdv, (fun (_, _, _, tomd, _) -> tomd), - tomdCompare (TaggedIndex(a, b)), + tomdCompare key, isSorted ctxt TableNames.GenericParam, (fun (gpidx, seq, flags, _, nameIdx) -> let flags = int32 flags @@ -2299,11 +2300,16 @@ and seekReadGenericParamsUncached ctxtH (GenericParamsIdx(numTypars, a, b)) = and seekReadGenericParamConstraints (ctxt: ILMetadataReader) mdv numTypars gpidx = seekReadIndexedRows ( ctxt.getNumRows TableNames.GenericParamConstraint, - seekReadGenericParamConstraintRow ctxt mdv, - fst, - simpleIndexCompare gpidx, + id, + id, + (fun idx -> + let mutable addr = ctxt.rowAddr TableNames.GenericParamConstraint idx + let pidx = seekReadUntaggedIdx TableNames.GenericParam ctxt mdv &addr + simpleIndexCompare gpidx pidx), isSorted ctxt TableNames.GenericParamConstraint, - (snd >> seekReadTypeDefOrRef ctxt numTypars AsObject []) + (fun idx -> + let constraintIdx = seekReadGenericParamConstraintIdx ctxt mdv idx + seekReadTypeDefOrRef ctxt numTypars AsObject [] constraintIdx) ) and seekReadTypeDefAsType (ctxt: ILMetadataReader) boxity (ginst: ILTypes) idx = diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index 820f94aa28a..77a6ce3e699 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -7,23 +7,6 @@ ! AssemblyReference: System.Reflection.Emit.ILGeneration ! AssemblyReference: System.Reflection.Metadata ! AssemblyReference: netstandard -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar IntImplIdx -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar get_IntImplIdx() -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar IntfIdx -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar get_IntfIdx() -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar TypeIdx -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar get_TypeIdx() -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Boolean Equals(<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]) -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Boolean Equals(<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar], System.Collections.IEqualityComparer) -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Boolean Equals(System.Object) -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Boolean Equals(System.Object, System.Collections.IEqualityComparer) -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 CompareTo(<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]) -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 CompareTo(System.Object) -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 CompareTo(System.Object, System.Collections.IComparer) -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 GetHashCode() -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 GetHashCode(System.Collections.IEqualityComparer) -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: System.String ToString() -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Void .ctor(j__TPar, j__TPar, j__TPar) FSharp.Compiler.AbstractIL.IL+ILArgConvention+Tags: Int32 CDecl FSharp.Compiler.AbstractIL.IL+ILArgConvention+Tags: Int32 Default FSharp.Compiler.AbstractIL.IL+ILArgConvention+Tags: Int32 FastCall diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index 820f94aa28a..77a6ce3e699 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -7,23 +7,6 @@ ! AssemblyReference: System.Reflection.Emit.ILGeneration ! AssemblyReference: System.Reflection.Metadata ! AssemblyReference: netstandard -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar IntImplIdx -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar get_IntImplIdx() -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar IntfIdx -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar get_IntfIdx() -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar TypeIdx -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar get_TypeIdx() -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Boolean Equals(<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]) -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Boolean Equals(<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar], System.Collections.IEqualityComparer) -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Boolean Equals(System.Object) -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Boolean Equals(System.Object, System.Collections.IEqualityComparer) -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 CompareTo(<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]) -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 CompareTo(System.Object) -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 CompareTo(System.Object, System.Collections.IComparer) -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 GetHashCode() -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 GetHashCode(System.Collections.IEqualityComparer) -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: System.String ToString() -<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Void .ctor(j__TPar, j__TPar, j__TPar) FSharp.Compiler.AbstractIL.IL+ILArgConvention+Tags: Int32 CDecl FSharp.Compiler.AbstractIL.IL+ILArgConvention+Tags: Int32 Default FSharp.Compiler.AbstractIL.IL+ILArgConvention+Tags: Int32 FastCall From 9bf5b869b0560bf5cf2069560b1885064ead0020 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 29 Aug 2024 11:19:54 +0200 Subject: [PATCH 8/9] Fix UseLocalCompiler.Directory.Build.props (#17542) --- UseLocalCompiler.Directory.Build.props | 2 ++ 1 file changed, 2 insertions(+) diff --git a/UseLocalCompiler.Directory.Build.props b/UseLocalCompiler.Directory.Build.props index 74ac88743c0..1b03ac191a8 100644 --- a/UseLocalCompiler.Directory.Build.props +++ b/UseLocalCompiler.Directory.Build.props @@ -8,6 +8,8 @@ true true + $([System.IO.Path]::GetDirectoryName($(DOTNET_HOST_PATH))) + $([System.IO.Path]::GetFileName($(DOTNET_HOST_PATH))) $(LocalFSharpCompilerPath)/artifacts/bin/fsc/$(LocalFSharpCompilerConfiguration)/net9.0/fsc.dll $(LocalFSharpCompilerPath)/artifacts/bin/fsc/$(LocalFSharpCompilerConfiguration)/net9.0/fsc.dll From dcf7db76734be9c8119c87d6b519d95e89e55ec7 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 29 Aug 2024 21:04:06 +0200 Subject: [PATCH 9/9] Change realSig to be `false` by default (#17631) * Change realSig to be `false` by default * Adjust tests * fantomas'd * quickinfo test * Update Tests.LanguageService.QuickInfo.fs --------- Co-authored-by: Kevin Ransom (msft) --- src/Compiler/Driver/CompilerConfig.fs | 2 +- tests/FSharp.Test.Utilities/CompilerAssert.fs | 3 ++ .../EmittedIL/DelegateAndFuncOptimizations.fs | 44 +++++++++---------- .../Compiler/CodeGen/EmittedIL/Mutation.fs | 10 ++--- .../CodeGen/EmittedIL/StaticMember.fs | 14 +++--- .../CodeGen/EmittedIL/TaskGeneratedCode.fs | 24 +++++----- .../FSharp.Editor.Tests/QuickInfoTests.fs | 5 ++- .../Tests.LanguageService.QuickInfo.fs | 2 +- 8 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/Compiler/Driver/CompilerConfig.fs b/src/Compiler/Driver/CompilerConfig.fs index 6ac922f5743..345b7426c2a 100644 --- a/src/Compiler/Driver/CompilerConfig.fs +++ b/src/Compiler/Driver/CompilerConfig.fs @@ -831,7 +831,7 @@ type TcConfigBuilder = DumpGraph = false } dumpSignatureData = false - realsig = true + realsig = false strictIndentation = None } diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index 559994c1b8f..270a72764a3 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -1006,6 +1006,9 @@ Updated automatically, please check diffs in your pull request, changes must be static member CompileLibraryAndVerifyIL((source: string), (f: ILVerifier -> unit)) = compileLibraryAndVerifyILWithOptions [||] (SourceCodeFileKind.Create("test.fs", source)) f + static member CompileLibraryAndVerifyILRealSig((source: string), (f: ILVerifier -> unit)) = + compileLibraryAndVerifyILWithOptions [|"--realsig+"|] (SourceCodeFileKind.Create("test.fs", source)) f + static member RunScriptWithOptionsAndReturnResult options (source: string) = // Initialize output and input streams use inStream = new StringReader("") diff --git a/tests/fsharp/Compiler/CodeGen/EmittedIL/DelegateAndFuncOptimizations.fs b/tests/fsharp/Compiler/CodeGen/EmittedIL/DelegateAndFuncOptimizations.fs index 789603bf0d2..7eeadfca205 100644 --- a/tests/fsharp/Compiler/CodeGen/EmittedIL/DelegateAndFuncOptimizations.fs +++ b/tests/fsharp/Compiler/CodeGen/EmittedIL/DelegateAndFuncOptimizations.fs @@ -494,6 +494,8 @@ let ApplyComputedFunction(c: int) = [] // See https://github.com/fsharp/fslang-design/blob/master/tooling/FST-1034-lambda-optimizations.md + // See also https://github.com/dotnet/fsharp/issues/17607 for a regression caused by realsig+ becoming default + // This test case must keep using direct call to ReduceComputedDelegate, and not a FSharpFunc invocation. let ``Reduce Computed Delegate with let rec``() = CompilerAssert.CompileLibraryAndVerifyIL( """ @@ -506,31 +508,25 @@ let ApplyComputedDelegate(c: int) = """, (fun verifier -> verifier.VerifyIL [ """ - .method public static int32 ApplyComputedDelegate(int32 c) cil managed - { - - .maxstack 4 - .locals init (class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 V_0, - class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 V_1) - IL_0000: ldsfld class ReduceComputedDelegate/f@7 ReduceComputedDelegate/f@7::@_instance - IL_0005: stloc.0 - IL_0006: ldstr "hello" - IL_000b: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) - IL_0010: stloc.1 - IL_0011: call class [netstandard]System.IO.TextWriter [netstandard]System.Console::get_Out() - IL_0016: ldloc.1 - IL_0017: call !!0 [FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter(class [runtime]System.IO.TextWriter, - class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) - IL_001c: pop - IL_001d: ldloc.0 - IL_001e: ldarg.0 - IL_001f: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) - IL_0024: ldc.i4.3 - IL_0025: add - IL_0026: ret +.method public static int32 ApplyComputedDelegate(int32 c) cil managed +{ + + .maxstack 4 + .locals init (class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 V_0) + IL_0000: ldstr "hello" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) + IL_000a: stloc.0 + IL_000b: call class [netstandard]System.IO.TextWriter [netstandard]System.Console::get_Out() + IL_0010: ldloc.0 + IL_0011: call !!0 [FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter(class [runtime]System.IO.TextWriter, + class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_0016: pop + IL_0017: ldarg.0 + IL_0018: call int32 ReduceComputedDelegate::f@7(int32) + IL_001d: ldc.i4.3 + IL_001e: add + IL_001f: ret } - -} """ ])) diff --git a/tests/fsharp/Compiler/CodeGen/EmittedIL/Mutation.fs b/tests/fsharp/Compiler/CodeGen/EmittedIL/Mutation.fs index f2b84edbf7b..b4a6fcedc41 100644 --- a/tests/fsharp/Compiler/CodeGen/EmittedIL/Mutation.fs +++ b/tests/fsharp/Compiler/CodeGen/EmittedIL/Mutation.fs @@ -13,7 +13,7 @@ module ``Mutation`` = [] let ``Mutation 01``() = CompilerAssert.CompileLibraryAndVerifyILWithOptions( - [|"-g"; "--optimize-"|], + [|"-g"; "--optimize-";"--realsig+"|], """ module Mutation01 type Test = struct @@ -48,7 +48,7 @@ type Test = struct [] let ``Mutation 02``() = CompilerAssert.CompileLibraryAndVerifyILWithOptions( - [|"-g"; "--optimize-"|], + [|"-g"; "--optimize-";"--realsig+"|], """ module Mutation02 let x = System.TimeSpan.MinValue @@ -94,7 +94,7 @@ x.ToString() [] let ``Mutation 03``() = CompilerAssert.CompileLibraryAndVerifyILWithOptions( - [|"-g"; "--optimize-"|], + [|"-g"; "--optimize-";"--realsig+"|], """ module Mutation03 let x = System.DateTime.Now @@ -139,7 +139,7 @@ x.Day [] let ``Mutation 04``() = CompilerAssert.CompileLibraryAndVerifyILWithOptions( - [|"-g"; "--optimize-"|], + [|"-g"; "--optimize-";"--realsig+"|], """ module Mutation04 let x = System.Decimal.MaxValue @@ -185,7 +185,7 @@ x.ToString() [] let ``Mutation 05``() = CompilerAssert.CompileLibraryAndVerifyILWithOptions( - [|"-g"; "--optimize-"|], + [|"-g"; "--optimize-";"--realsig+"|], """ module Mutation05 type C() = diff --git a/tests/fsharp/Compiler/CodeGen/EmittedIL/StaticMember.fs b/tests/fsharp/Compiler/CodeGen/EmittedIL/StaticMember.fs index 07d530dfd27..340c1963fd3 100644 --- a/tests/fsharp/Compiler/CodeGen/EmittedIL/StaticMember.fs +++ b/tests/fsharp/Compiler/CodeGen/EmittedIL/StaticMember.fs @@ -10,7 +10,7 @@ module ``Static Member`` = [] let ``Action on Static Member``() = - CompilerAssert.CompileLibraryAndVerifyIL( + CompilerAssert.CompileLibraryAndVerifyILRealSig( """ module StaticMember01 @@ -74,7 +74,7 @@ type C = [] let ``Action on Static Member with lambda``() = - CompilerAssert.CompileLibraryAndVerifyIL( + CompilerAssert.CompileLibraryAndVerifyILRealSig( """ module StaticMember02 @@ -133,7 +133,7 @@ type C = [] let ``Action on Static Member with closure``() = - CompilerAssert.CompileLibraryAndVerifyIL( + CompilerAssert.CompileLibraryAndVerifyILRealSig( """ module StaticMember03 @@ -247,7 +247,7 @@ let main _ = [] let ``Func on Static Member``() = - CompilerAssert.CompileLibraryAndVerifyIL( + CompilerAssert.CompileLibraryAndVerifyILRealSig( """ module StaticMember04 @@ -313,7 +313,7 @@ type C = [] let ``Func on Static Member with lambda``() = - CompilerAssert.CompileLibraryAndVerifyIL( + CompilerAssert.CompileLibraryAndVerifyILRealSig( """ module StaticMember05 @@ -379,7 +379,7 @@ type C = [] let ``Func on Static Member with closure``() = - CompilerAssert.CompileLibraryAndVerifyIL( + CompilerAssert.CompileLibraryAndVerifyILRealSig( """ module StaticMember06 @@ -434,7 +434,7 @@ let main _ = #if !FX_NO_WINFORMS [] let ``EventHandler from Regression/83``() = - CompilerAssert.CompileLibraryAndVerifyIL( + CompilerAssert.CompileLibraryAndVerifyILRealSig( """ module StaticMember07 diff --git a/tests/fsharp/Compiler/CodeGen/EmittedIL/TaskGeneratedCode.fs b/tests/fsharp/Compiler/CodeGen/EmittedIL/TaskGeneratedCode.fs index 4d9a81be23f..4345540ad44 100644 --- a/tests/fsharp/Compiler/CodeGen/EmittedIL/TaskGeneratedCode.fs +++ b/tests/fsharp/Compiler/CodeGen/EmittedIL/TaskGeneratedCode.fs @@ -29,7 +29,7 @@ module TaskGeneratedCode = [] let ``check MoveNext of simple task debug``() = CompilerAssert.CompileLibraryAndVerifyILWithOptions( - [| "/optimize-"; "/debug:portable"; "/tailcalls-" |], + [| "/optimize-"; "/debug:portable";"--realsig+"; "/tailcalls-" |], """ module Test @@ -116,7 +116,7 @@ let testTask() = task { return 1 } [] let ``check MoveNext of simple task optimized``() = CompilerAssert.CompileLibraryAndVerifyILWithOptions( - [| "/optimize+"; "/debug:portable"; "/tailcalls+" |], + [| "/optimize+"; "/debug:portable";"--realsig+"; "/tailcalls+" |], """ module Test @@ -190,7 +190,7 @@ let testTask() = task { return 1 } [] let ``check MoveNext of simple binding task debug``() = CompilerAssert.CompileLibraryAndVerifyILWithOptions( - [| "/debug:portable"; "/optimize-"; "/tailcalls-" |], + [| "/debug:portable";"--realsig+"; "/optimize-"; "/tailcalls-" |], """ module Test open System.Threading.Tasks @@ -370,7 +370,7 @@ module TaskTryFinallyGeneration = [] let ``check MoveNext of task try/finally optimized``() = CompilerAssert.CompileLibraryAndVerifyILWithOptions( - [| "/optimize+"; "/debug:portable"; "/tailcalls+" |], + [| "/optimize+"; "/debug:portable";"--realsig+"; "/tailcalls+" |], """ module Test @@ -479,7 +479,7 @@ let testTask() = task { try 1+1 finally System.Console.WriteLine("finally") } [] let ``check MoveNext of task try/finally debug``() = CompilerAssert.CompileLibraryAndVerifyILWithOptions( - [| "/optimize-"; "/debug:portable"; "/tailcalls-" |], + [| "/optimize-"; "/debug:portable";"--realsig+"; "/tailcalls-" |], """ module Test @@ -596,7 +596,7 @@ module TaskTryWithGeneration = [] let ``check MoveNext of task try/with optimized``() = CompilerAssert.CompileLibraryAndVerifyILWithOptions( - [| "/optimize+"; "/debug:portable"; "/tailcalls+" |], + [| "/optimize+"; "/debug:portable";"--realsig+"; "/tailcalls+" |], """ module Test @@ -709,7 +709,7 @@ let testTask() = task { try 1 with e -> System.Console.WriteLine("finally"); 2 } [] let ``check MoveNext of task try/with debug``() = CompilerAssert.CompileLibraryAndVerifyILWithOptions( - [| "/optimize-"; "/debug:portable"; "/tailcalls-" |], + [| "/optimize-"; "/debug:portable";"--realsig+"; "/tailcalls-" |], """ module Test @@ -829,7 +829,7 @@ module TaskWhileLoopGeneration = [] let ``check MoveNext of task while loop optimized``() = CompilerAssert.CompileLibraryAndVerifyILWithOptions( - [| "/optimize+"; "/debug:portable"; "/tailcalls+" |], + [| "/optimize+"; "/debug:portable";"--realsig+"; "/tailcalls+" |], """ module Test @@ -927,7 +927,7 @@ let testTask() = task { while x > 4 do System.Console.WriteLine("loop") } [] let ``check MoveNext of task while loop debug``() = CompilerAssert.CompileLibraryAndVerifyILWithOptions( - [| "/optimize-"; "/debug:portable"; "/tailcalls-" |], + [| "/optimize-"; "/debug:portable";"--realsig+"; "/tailcalls-" |], """ module Test @@ -1030,7 +1030,7 @@ module TaskTypeInference = [] let ``check initially ambiguous SRTP task code ``() = CompilerAssert.CompileExeAndRunWithOptions( - [| "/optimize-"; "/debug:portable"; "/tailcalls-" |], + [| "/optimize-"; "/debug:portable";"--realsig+"; "/tailcalls-" |], """ module Test @@ -1050,7 +1050,7 @@ let myTuple : (string -> Task) * int = (fun (_s: string) -> Task.FromResul [] let ``check generic task code ``() = CompilerAssert.CompileExeAndRunWithOptions( - [| "/optimize-"; "/debug:portable"; "/tailcalls-" |], + [| "/optimize-"; "/debug:portable";"--realsig+"; "/tailcalls-" |], """ module Test @@ -1083,7 +1083,7 @@ printfn "test passed" [] let ``check generic task exact code``() = CompilerAssert.CompileLibraryAndVerifyILWithOptions( - [| "/optimize-"; "/debug:portable"; "/tailcalls-" |], + [| "/optimize-"; "/debug:portable";"--realsig+"; "/tailcalls-" |], """ module Test diff --git a/vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs b/vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs index 7754c07a002..5f658cb5155 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs @@ -31,7 +31,8 @@ module QuickInfo = let internal GetQuickInfo (code: string) caretPosition = asyncMaybe { let document = - RoslynTestHelpers.CreateSolution(code) |> RoslynTestHelpers.GetSingleDocument + RoslynTestHelpers.CreateSolution(code, extraFSharpProjectOtherOptions = [| "--realsig+" |]) + |> RoslynTestHelpers.GetSingleDocument let! _, _, _, tooltip = FSharpAsyncQuickInfoSource.TryGetToolTip(document, caretPosition) @@ -534,7 +535,7 @@ module Test = static let fu$$nc x = () """ - let expectedSignature = "val private func: x: 'a -> unit" + let expectedSignature = "val func: x: 'a -> unit" let tooltip = GetQuickInfoTextFromCode code diff --git a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.QuickInfo.fs b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.QuickInfo.fs index 60e8c9ad1e9..1d62dd3c399 100644 --- a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.QuickInfo.fs +++ b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.QuickInfo.fs @@ -790,7 +790,7 @@ Full name: Microsoft.FSharp.Control.Async""".TrimStart().Replace("\r\n", "\n") type A() = let fff n = n + 1 """ - this.AssertQuickInfoContainsAtEndOfMarker(code, "let ff", "val private fff: n: int -> int") + this.AssertQuickInfoContainsAtEndOfMarker(code, "let ff", "val fff: n: int -> int") // Regression for 2494 []