From 230f9add38c6744373b017206e5a9eba1f32cc6c Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 23 Jan 2023 14:54:10 +0100 Subject: [PATCH 1/2] More testing for Static classes --- .../Language/StaticClassTests.fs | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/tests/FSharp.Compiler.ComponentTests/Language/StaticClassTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/StaticClassTests.fs index 35997564919..5869ac0c132 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/StaticClassTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/StaticClassTests.fs @@ -716,4 +716,65 @@ type T = (Warning 3554, Line 4, Col 5, Line 4, Col 33, "If a type uses both [] and [] attributes, it means it is static. Instance members are not allowed.") (Warning 3554, Line 5, Col 5, Line 5, Col 41, "If a type uses both [] and [] attributes, it means it is static. Instance members are not allowed.") (Warning 3554, Line 6, Col 5, Line 6, Col 55, "If a type uses both [] and [] attributes, it means it is static. Instance members are not allowed.") + ] + + [] + let ``Sealed and AbstractClass on a types with non static members lang version70`` () = + Fsx """ +[] +type T = + abstract A : int + abstract B : int with get, set + abstract C : i:int -> int + abstract D : i:int -> int + default _.D i = i + 3 + member _.E = 3 + val F : int + val mutable G : int + member _.H (i, j) = i + j + member _.Item with get i = 3 and set i value = () + override _.ToString () = "🙃" + new () = { F = 3; G = 3 } + new (x, y) = { F = x; G = y } + """ + |> withLangVersion70 + |> compile + |> shouldSucceed + + [] + let ``Sealed and AbstractClass on a types with non static members in lang version preview`` () = + Fsx """ +[] +type T = + abstract A : int + abstract B : int with get, set + abstract C : i:int -> int + abstract D : i:int -> int + default _.D i = i + 3 + member _.E = 3 + val F : int + val mutable G : int + member _.H (i, j) = i + j + member _.Item with get i = 3 and set i value = () + override _.ToString () = "🙃" + new () = { F = 3; G = 3 } + new (x, y) = { F = x; G = y } + """ + |> withLangVersionPreview + |> compile + |> shouldFail + |> withDiagnostics [ + (Warning 3554, Line 8, Col 5, Line 8, Col 26, "If a type uses both [] and [] attributes, it means it is static. Instance members are not allowed.") + (Warning 3554, Line 9, Col 5, Line 9, Col 19, "If a type uses both [] and [] attributes, it means it is static. Instance members are not allowed.") + (Warning 3554, Line 12, Col 5, Line 12, Col 30, "If a type uses both [] and [] attributes, it means it is static. Instance members are not allowed.") + (Warning 3554, Line 13, Col 5, Line 13, Col 54, "If a type uses both [] and [] attributes, it means it is static. Instance members are not allowed.") + (Warning 3554, Line 14, Col 5, Line 14, Col 34, "If a type uses both [] and [] attributes, it means it is static. Instance members are not allowed.") + (Warning 3553, Line 15, Col 5, Line 15, Col 30, "If a type uses both [] and [] attributes, it means it is static. Additional constructor is not allowed.") + (Warning 3553, Line 16, Col 5, Line 16, Col 34, "If a type uses both [] and [] attributes, it means it is static. Additional constructor is not allowed.") + (Warning 3557, Line 4, Col 14, Line 4, Col 15, "If a type uses both [] and [] attributes, it means it is static. Abstract member declarations are not allowed.") + (Warning 3557, Line 5, Col 14, Line 5, Col 15, "If a type uses both [] and [] attributes, it means it is static. Abstract member declarations are not allowed.") + (Warning 3557, Line 6, Col 14, Line 6, Col 15, "If a type uses both [] and [] attributes, it means it is static. Abstract member declarations are not allowed.") + (Warning 3557, Line 7, Col 14, Line 7, Col 15, "If a type uses both [] and [] attributes, it means it is static. Abstract member declarations are not allowed.") + (Warning 3558, Line 10, Col 9, Line 10, Col 10, "If a type uses both [] and [] attributes, it means it is static. Explicit field declarations are not allowed.") + (Warning 3558, Line 11, Col 17, Line 11, Col 18, "If a type uses both [] and [] attributes, it means it is static. Explicit field declarations are not allowed.") ] \ No newline at end of file From 9d0f4097f80e6f95e02d26b2a7383c261eb4a339 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 23 Jan 2023 14:49:17 +0000 Subject: [PATCH 2/2] Update tests/FSharp.Compiler.ComponentTests/Language/StaticClassTests.fs Co-authored-by: Petr --- .../FSharp.Compiler.ComponentTests/Language/StaticClassTests.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Language/StaticClassTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/StaticClassTests.fs index 5869ac0c132..aea9ede61a0 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/StaticClassTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/StaticClassTests.fs @@ -719,7 +719,7 @@ type T = ] [] - let ``Sealed and AbstractClass on a types with non static members lang version70`` () = + let ``Sealed and AbstractClass on types with non static members lang version70`` () = Fsx """ [] type T =