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
+51-21Lines changed: 51 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ type T(x: int) = class end
55
55
|> compile
56
56
|> shouldFail
57
57
|> withDiagnostics [
58
-
(Error3552, Line 3, Col 8, Line 3, Col 14,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Constructor with arguments is not allowed.")
58
+
(Warning3552, Line 3, Col 8, Line 3, Col 14,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Constructor with arguments is not allowed.")
59
59
]
60
60
61
61
[<Fact>]
@@ -79,7 +79,7 @@ type T =
79
79
|> compile
80
80
|> shouldFail
81
81
|> withDiagnostics [
82
-
(Error3553, Line 4, Col 5, Line 4, Col 16,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Additional constructor is not allowed.")
82
+
(Warning3553, Line 4, Col 5, Line 4, Col 16,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Additional constructor is not allowed.")
83
83
]
84
84
85
85
[<Fact>]
@@ -104,8 +104,8 @@ type T(x: int) =
104
104
|> compile
105
105
|> shouldFail
106
106
|> withDiagnostics [
107
-
(Error3552, Line 3, Col 8, Line 3, Col 14,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Constructor with arguments is not allowed.")
108
-
(Error3553, Line 4, Col 5, Line 4, Col 19,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Additional constructor is not allowed.")
107
+
(Warning3552, Line 3, Col 8, Line 3, Col 14,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Constructor with arguments is not allowed.")
108
+
(Warning3553, Line 4, Col 5, Line 4, Col 19,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Additional constructor is not allowed.")
109
109
]
110
110
111
111
[<Fact>]
@@ -140,7 +140,7 @@ type ListDebugView<'T>(l: 'T list) = class end
140
140
|> compile
141
141
|> shouldFail
142
142
|> withDiagnostics [
143
-
(Error3552, Line 3, Col 24, Line 3, Col 34,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Constructor with arguments is not allowed.")
143
+
(Warning3552, Line 3, Col 24, Line 3, Col 34,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Constructor with arguments is not allowed.")
144
144
]
145
145
146
146
[<Fact>]
@@ -156,9 +156,9 @@ type B =
156
156
|> compile
157
157
|> shouldFail
158
158
|> withDiagnostics [
159
-
(Error3553, Line 6, Col 5, Line 6, Col 30,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Additional constructor is not allowed.")
160
-
(Error3558, Line 4, Col 9, Line 4, Col 10,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed.")
161
-
(Error3558, Line 5, Col 17, Line 5, Col 18,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed.")
159
+
(Warning3553, Line 6, Col 5, Line 6, Col 30,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Additional constructor is not allowed.")
160
+
(Warning3558, Line 4, Col 9, Line 4, Col 10,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed.")
161
+
(Warning3558, Line 5, Col 17, Line 5, Col 18,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed.")
162
162
]
163
163
164
164
[<Theory>]
@@ -229,7 +229,7 @@ type T() =
229
229
|> compile
230
230
|> shouldFail
231
231
|> withDiagnostics [
232
-
(Error3554, Line 4, Col 5, Line 4, Col 25,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed.")
232
+
(Warning3554, Line 4, Col 5, Line 4, Col 25,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance members are not allowed.")
233
233
]
234
234
235
235
[<Fact>]
@@ -316,7 +316,7 @@ type C() =
316
316
|> compile
317
317
|> shouldFail
318
318
|> withDiagnostics [
319
-
(Error3555, Line 4, Col 5, Line 4, Col 14,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed.")
319
+
(Warning3555, Line 4, Col 5, Line 4, Col 14,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed.")
320
320
]
321
321
322
322
[<Fact>]
@@ -331,7 +331,7 @@ type C() =
331
331
|> compile
332
332
|> shouldFail
333
333
|> withDiagnostics [
334
-
(Error3555, Line 4, Col 5, Line 4, Col 18,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed.")
334
+
(Warning3555, Line 4, Col 5, Line 4, Col 18,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Instance let bindings are not allowed.")
335
335
]
336
336
337
337
[<Fact>]
@@ -403,7 +403,7 @@ type C() =
403
403
|> compile
404
404
|> shouldFail
405
405
|> withDiagnostics [
406
-
(Error3556, Line 8, Col 9, Line 8, Col 29,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Implementing interfaces is not allowed.")
406
+
(Warning3556, Line 8, Col 9, Line 8, Col 29,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Implementing interfaces is not allowed.")
407
407
]
408
408
409
409
[<Fact>]
@@ -421,7 +421,7 @@ type C =
421
421
|> compile
422
422
|> shouldFail
423
423
|> withDiagnostics [
424
-
(Error3556, Line 8, Col 9, Line 8, Col 29,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Implementing interfaces is not allowed.")
424
+
(Warning3556, Line 8, Col 9, Line 8, Col 29,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Implementing interfaces is not allowed.")
425
425
]
426
426
427
427
[<Fact>]
@@ -464,8 +464,8 @@ type T =
464
464
|> compile
465
465
|> shouldFail
466
466
|> withDiagnostics [
467
-
(Error3557, 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.")
468
-
(Error3557, 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.")
467
+
(Warning3557, 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.")
468
+
(Warning3557, 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.")
469
469
]
470
470
471
471
[<Fact>]
@@ -480,8 +480,8 @@ type T() =
480
480
|> compile
481
481
|> shouldFail
482
482
|> withDiagnostics [
483
-
(Error3557, 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.")
484
-
(Error3557, 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.")
483
+
(Warning3557, 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.")
484
+
(Warning3557, 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.")
485
485
]
486
486
487
487
#if!NETCOREAPP
@@ -665,8 +665,8 @@ type B =
665
665
|> compile
666
666
|> shouldFail
667
667
|> withDiagnostics [
668
-
(Error3558, Line 4, Col 9, Line 4, Col 10,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed.")
669
-
(Error3558, Line 5, Col 17, Line 5, Col 18,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed.")
668
+
(Warning3558, Line 4, Col 9, Line 4, Col 10,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed.")
669
+
(Warning3558, Line 5, Col 17, Line 5, Col 18,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed.")
670
670
]
671
671
672
672
[<Fact>]
@@ -683,7 +683,37 @@ type B() =
683
683
|> withDiagnostics [
684
684
(Error 880, Line 4, Col 9, Line 4, Col 16,"Uninitialized 'val' fields must be mutable and marked with the '[<DefaultValue>]' attribute. Consider using a 'let' binding instead of a 'val' field.")
685
685
(Error 880, Line 5, Col 17, Line 5, Col 24,"Uninitialized 'val' fields must be mutable and marked with the '[<DefaultValue>]' attribute. Consider using a 'let' binding instead of a 'val' field.")
686
-
(Error3558, Line 4, Col 9, Line 4, Col 10,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed.")
687
-
(Error3558, Line 5, Col 17, Line 5, Col 18,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed.")
686
+
(Warning3558, Line 4, Col 9, Line 4, Col 10,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed.")
687
+
(Warning3558, Line 5, Col 17, Line 5, Col 18,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed.")
688
688
]
689
+
690
+
[<Fact>]
691
+
let``Sealed and AbstractClass on a types with instance member properties on lang version70`` ()=
692
+
Fsx """
693
+
[<Sealed; AbstractClass>]
694
+
type T =
695
+
member _.Item with get i = 3
696
+
member _.Item1 with set i value = ()
697
+
member _.Item2 with get i = 3 and set i value = ()
698
+
"""
699
+
|> withLangVersion70
700
+
|> compile
701
+
|> shouldSucceed
689
702
703
+
[<Fact>]
704
+
let``Sealed and AbstractClass on a types with instance member properties on lang preview`` ()=
705
+
Fsx """
706
+
[<Sealed; AbstractClass>]
707
+
type T =
708
+
member _.Item with get i = 3
709
+
member _.Item1 with set i value = ()
710
+
member _.Item2 with get i = 3 and set i value = ()
711
+
"""
712
+
|> withLangVersionPreview
713
+
|> compile
714
+
|> shouldFail
715
+
|> withDiagnostics [
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
+
(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
+
(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.")
0 commit comments