You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/FSharp.Compiler.ComponentTests/Language/StaticClassTests.fs
+61Lines changed: 61 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -716,4 +716,65 @@ type T =
716
716
(Warning 3554, Line 4, Col 5, Line 4, Col 33,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed.")
717
717
(Warning 3554, Line 5, Col 5, Line 5, Col 41,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed.")
718
718
(Warning 3554, Line 6, Col 5, Line 6, Col 55,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed.")
719
+
]
720
+
721
+
[<Fact>]
722
+
let``Sealed and AbstractClass on types with non static members lang version70`` ()=
723
+
Fsx """
724
+
[<Sealed; AbstractClass>]
725
+
type T =
726
+
abstract A : int
727
+
abstract B : int with get, set
728
+
abstract C : i:int -> int
729
+
abstract D : i:int -> int
730
+
default _.D i = i + 3
731
+
member _.E = 3
732
+
val F : int
733
+
val mutable G : int
734
+
member _.H (i, j) = i + j
735
+
member _.Item with get i = 3 and set i value = ()
736
+
override _.ToString () = "🙃"
737
+
new () = { F = 3; G = 3 }
738
+
new (x, y) = { F = x; G = y }
739
+
"""
740
+
|> withLangVersion70
741
+
|> compile
742
+
|> shouldSucceed
743
+
744
+
[<Fact>]
745
+
let``Sealed and AbstractClass on a types with non static members in lang version preview`` ()=
746
+
Fsx """
747
+
[<Sealed; AbstractClass>]
748
+
type T =
749
+
abstract A : int
750
+
abstract B : int with get, set
751
+
abstract C : i:int -> int
752
+
abstract D : i:int -> int
753
+
default _.D i = i + 3
754
+
member _.E = 3
755
+
val F : int
756
+
val mutable G : int
757
+
member _.H (i, j) = i + j
758
+
member _.Item with get i = 3 and set i value = ()
759
+
override _.ToString () = "🙃"
760
+
new () = { F = 3; G = 3 }
761
+
new (x, y) = { F = x; G = y }
762
+
"""
763
+
|> withLangVersionPreview
764
+
|> compile
765
+
|> shouldFail
766
+
|> withDiagnostics [
767
+
(Warning 3554, Line 8, Col 5, Line 8, Col 26,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed.")
768
+
(Warning 3554, Line 9, Col 5, Line 9, Col 19,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed.")
769
+
(Warning 3554, Line 12, Col 5, Line 12, Col 30,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed.")
770
+
(Warning 3554, Line 13, Col 5, Line 13, Col 54,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed.")
771
+
(Warning 3554, Line 14, Col 5, Line 14, Col 34,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed.")
772
+
(Warning 3553, Line 15, Col 5, Line 15, Col 30,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Additional constructor is not allowed.")
773
+
(Warning 3553, Line 16, Col 5, Line 16, Col 34,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Additional constructor is not allowed.")
774
+
(Warning 3557, Line 4, Col 14, Line 4, Col 15,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Abstract member declarations are not allowed.")
775
+
(Warning 3557, Line 5, Col 14, Line 5, Col 15,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Abstract member declarations are not allowed.")
776
+
(Warning 3557, Line 6, Col 14, Line 6, Col 15,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Abstract member declarations are not allowed.")
777
+
(Warning 3557, Line 7, Col 14, Line 7, Col 15,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Abstract member declarations are not allowed.")
778
+
(Warning 3558, Line 10, Col 9, Line 10, Col 10,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed.")
779
+
(Warning 3558, Line 11, Col 17, Line 11, Col 18,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed.")
0 commit comments