diff --git a/src/Compiler/Checking/NicePrint.fs b/src/Compiler/Checking/NicePrint.fs index 7f0779c062..da4caaf7f2 100644 --- a/src/Compiler/Checking/NicePrint.fs +++ b/src/Compiler/Checking/NicePrint.fs @@ -708,7 +708,15 @@ module PrintTypes = match Zmap.tryFind typar env.inplaceConstraints with | Some typarConstraintTy -> 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 (varL ^^ sepL (tagPunctuation ":>") ^^ layoutTypeWithInfo denv env typarConstraintTy) |> bracketL diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 6c5c5f76c2..93ff861fe6 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -251,6 +251,7 @@ + diff --git a/tests/FSharp.Compiler.ComponentTests/Signatures/ArrayTests.fs b/tests/FSharp.Compiler.ComponentTests/Signatures/ArrayTests.fs index 7d74903c4e..74a69d7e70 100644 --- a/tests/FSharp.Compiler.ComponentTests/Signatures/ArrayTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Signatures/ArrayTests.fs @@ -1,4 +1,4 @@ -module Signatures.SignatureTests +module Signatures.ArrayTests open Xunit open Signatures.TestHelpers diff --git a/tests/FSharp.Compiler.ComponentTests/Signatures/HashConstraintTests.fs b/tests/FSharp.Compiler.ComponentTests/Signatures/HashConstraintTests.fs new file mode 100644 index 0000000000..beb33a8bac --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Signatures/HashConstraintTests.fs @@ -0,0 +1,33 @@ +module Signatures.HashConstraintTests + +open Xunit +open FsUnit +open FSharp.Test.Compiler +open Signatures.TestHelpers + +[] +let ``Optional hash constraint`` () = + FSharp + """ +module Foo + +[] +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""" diff --git a/tests/FSharp.Compiler.ComponentTests/Signatures/MissingDiagnostic.fs b/tests/FSharp.Compiler.ComponentTests/Signatures/MissingDiagnostic.fs index 2d263fa728..55181649b0 100644 --- a/tests/FSharp.Compiler.ComponentTests/Signatures/MissingDiagnostic.fs +++ b/tests/FSharp.Compiler.ComponentTests/Signatures/MissingDiagnostic.fs @@ -1,4 +1,4 @@ -module FSharp.Compiler.ComponentTests.Signatures.MissingDiagnostic +module Signatures.MissingDiagnostic open Xunit open FSharp.Test diff --git a/tests/FSharp.Compiler.ComponentTests/Signatures/SigGenerationRoundTripTests.fs b/tests/FSharp.Compiler.ComponentTests/Signatures/SigGenerationRoundTripTests.fs index 469fa879b4..b0ff8e995c 100644 --- a/tests/FSharp.Compiler.ComponentTests/Signatures/SigGenerationRoundTripTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Signatures/SigGenerationRoundTripTests.fs @@ -28,7 +28,7 @@ let ``Generate and compile`` implFileName = |> withLangVersionPreview |> withDefines ["TESTS_AS_APP";"COMPILED"] |> ignoreWarnings + |> withOptions [ "--warnaserror:64" ] |> asExe |> compile |> shouldSucceed - diff --git a/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/hash_constraint_seq.fsx b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/hash_constraint_seq.fsx new file mode 100644 index 0000000000..60bdb225ad --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/hash_constraint_seq.fsx @@ -0,0 +1,7 @@ +module Foo + +open System +open System.Threading.Tasks + +let mapWithAdditionalDependenies + (mapping: 'a -> 'b * #seq<#IDisposable>) = 0