зеркало из https://github.com/dotnet/fsharp.git
Wrap hash postfix type in parentheses. (#15355)
* Wrap hash postfix type in parentheses. * Only add parentheses if there are any typeInstantiations. * Trigger CI * Update module names.
This commit is contained in:
Родитель
01ee95517d
Коммит
dbe12dab78
|
@ -708,7 +708,15 @@ module PrintTypes =
|
||||||
match Zmap.tryFind typar env.inplaceConstraints with
|
match Zmap.tryFind typar env.inplaceConstraints with
|
||||||
| Some typarConstraintTy ->
|
| Some typarConstraintTy ->
|
||||||
if Zset.contains typar env.singletons then
|
if Zset.contains typar env.singletons then
|
||||||
leftL (tagPunctuation "#") ^^ layoutTypeWithInfo denv env typarConstraintTy
|
let tyLayout =
|
||||||
|
match typarConstraintTy with
|
||||||
|
| TType_app (tyconRef = tc; typeInstantiation = ti)
|
||||||
|
when ti.Length > 0 && not (usePrefix denv tc) ->
|
||||||
|
layoutTypeWithInfo denv env typarConstraintTy
|
||||||
|
|> bracketL
|
||||||
|
| _ -> layoutTypeWithInfo denv env typarConstraintTy
|
||||||
|
|
||||||
|
leftL (tagPunctuation "#") ^^ tyLayout
|
||||||
else
|
else
|
||||||
(varL ^^ sepL (tagPunctuation ":>") ^^ layoutTypeWithInfo denv env typarConstraintTy) |> bracketL
|
(varL ^^ sepL (tagPunctuation ":>") ^^ layoutTypeWithInfo denv env typarConstraintTy) |> bracketL
|
||||||
|
|
||||||
|
|
|
@ -251,6 +251,7 @@
|
||||||
<Compile Include="Signatures\SigGenerationRoundTripTests.fs" />
|
<Compile Include="Signatures\SigGenerationRoundTripTests.fs" />
|
||||||
<Compile Include="Signatures\NestedTypeTests.fs" />
|
<Compile Include="Signatures\NestedTypeTests.fs" />
|
||||||
<Compile Include="Signatures\MissingDiagnostic.fs" />
|
<Compile Include="Signatures\MissingDiagnostic.fs" />
|
||||||
|
<Compile Include="Signatures\HashConstraintTests.fs" />
|
||||||
<Compile Include="StaticLinking\StaticLinking.fs" />
|
<Compile Include="StaticLinking\StaticLinking.fs" />
|
||||||
<Compile Include="FSharpChecker\CommonWorkflows.fs" />
|
<Compile Include="FSharpChecker\CommonWorkflows.fs" />
|
||||||
<Compile Include="FSharpChecker\SymbolUse.fs" />
|
<Compile Include="FSharpChecker\SymbolUse.fs" />
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module Signatures.SignatureTests
|
module Signatures.ArrayTests
|
||||||
|
|
||||||
open Xunit
|
open Xunit
|
||||||
open Signatures.TestHelpers
|
open Signatures.TestHelpers
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
module Signatures.HashConstraintTests
|
||||||
|
|
||||||
|
open Xunit
|
||||||
|
open FsUnit
|
||||||
|
open FSharp.Test.Compiler
|
||||||
|
open Signatures.TestHelpers
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``Optional hash constraint`` () =
|
||||||
|
FSharp
|
||||||
|
"""
|
||||||
|
module Foo
|
||||||
|
|
||||||
|
[<Interface>]
|
||||||
|
type Node =
|
||||||
|
abstract Children: int array
|
||||||
|
|
||||||
|
let noa<'n when 'n :> Node> (n: 'n option) =
|
||||||
|
match n with
|
||||||
|
| None -> Array.empty
|
||||||
|
| Some n -> [| n :> Node |]
|
||||||
|
"""
|
||||||
|
|> printSignatures
|
||||||
|
|> should
|
||||||
|
equal
|
||||||
|
"""
|
||||||
|
module Foo
|
||||||
|
|
||||||
|
type Node =
|
||||||
|
|
||||||
|
abstract Children: int array
|
||||||
|
|
||||||
|
val noa: n: #Node option -> Node array"""
|
|
@ -1,4 +1,4 @@
|
||||||
module FSharp.Compiler.ComponentTests.Signatures.MissingDiagnostic
|
module Signatures.MissingDiagnostic
|
||||||
|
|
||||||
open Xunit
|
open Xunit
|
||||||
open FSharp.Test
|
open FSharp.Test
|
||||||
|
|
|
@ -28,7 +28,7 @@ let ``Generate and compile`` implFileName =
|
||||||
|> withLangVersionPreview
|
|> withLangVersionPreview
|
||||||
|> withDefines ["TESTS_AS_APP";"COMPILED"]
|
|> withDefines ["TESTS_AS_APP";"COMPILED"]
|
||||||
|> ignoreWarnings
|
|> ignoreWarnings
|
||||||
|
|> withOptions [ "--warnaserror:64" ]
|
||||||
|> asExe
|
|> asExe
|
||||||
|> compile
|
|> compile
|
||||||
|> shouldSucceed
|
|> shouldSucceed
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
module Foo
|
||||||
|
|
||||||
|
open System
|
||||||
|
open System.Threading.Tasks
|
||||||
|
|
||||||
|
let mapWithAdditionalDependenies
|
||||||
|
(mapping: 'a -> 'b * #seq<#IDisposable>) = 0
|
Загрузка…
Ссылка в новой задаче