@@ -12,8 +12,9 @@ A *class_declaration* is a *type_declaration* ([§13.7](namespaces.md#137-type-d
12
12
13
13
``` ANTLR
14
14
class_declaration
15
- : attributes? class_modifier* 'partial'? 'class' identifier type_parameter_list?
16
- class_base? type_parameter_constraints_clause* class_body ';'?
15
+ : attributes? class_modifier* 'partial'? 'class' identifier
16
+ type_parameter_list? class_base? type_parameter_constraints_clause*
17
+ class_body ';'?
17
18
;
18
19
```
19
20
@@ -213,9 +214,15 @@ The base class specified in a class declaration can be a constructed class type
213
214
>
214
215
> ```csharp
215
216
> class Base <T > {}
216
- > class Extend : Base <int > // Valid, non-constructed class with constructed base class
217
- > class Extend <V > : V {} // Error, type parameter used as base class
218
- > class Extend <V > : Base <V > {} // Valid, type parameter used as type argument for base class
217
+ >
218
+ > // Valid, non-constructed class with constructed base class
219
+ > class Extend : Base <int >
220
+ >
221
+ > // Error, type parameter used as base class
222
+ > class Extend <V > : V {}
223
+ >
224
+ > // Valid, type parameter used as type argument for base class
225
+ > class Extend <V > : Base <V > {}
219
226
> ```
220
227
>
221
228
> * end example *
@@ -956,10 +963,10 @@ When a field, method, property, event, indexer, constructor, or finalizer declar
956
963
> static void Main ()
957
964
> {
958
965
> Test t = new Test ();
959
- > t .x = 1 ; // Ok
960
- > t .y = 1 ; // Error, cannot access static member through instance
961
- > Test .x = 1 ; // Error, cannot access instance member through type
962
- > Test .y = 1 ; // Ok
966
+ > t .x = 1 ; // Ok
967
+ > t .y = 1 ; // Error, cannot access static member through instance
968
+ > Test .x = 1 ; // Error, cannot access instance member through type
969
+ > Test .y = 1 ; // Ok
963
970
> }
964
971
> }
965
972
> ```
@@ -1214,10 +1221,10 @@ Every type declaration contained within a generic class declaration is implicitl
1214
1221
>
1215
1222
> static void F (T t )
1216
1223
> {
1217
- > Outer <T >.Inner <string >.F (t , " abc" ); // These two statements have
1218
- > Inner <string >.F (t , " abc" ); // the same effect
1219
- > Outer <int >.Inner <string >.F (3 , " abc" ); // This type is different
1220
- > Outer .Inner <string >.F (t , " abc" ); // Error, Outer needs type arg
1224
+ > Outer <T >.Inner <string >.F (t , " abc" ); // These two statements have
1225
+ > Inner <string >.F (t , " abc" ); // the same effect
1226
+ > Outer <int >.Inner <string >.F (3 , " abc" ); // This type is different
1227
+ > Outer .Inner <string >.F (t , " abc" ); // Error, Outer needs type arg
1221
1228
> }
1222
1229
> }
1223
1230
> ```
@@ -1620,7 +1627,8 @@ These restrictions ensure that all threads will observe volatile writes performe
1620
1627
> // Run Thread2() in a new thread
1621
1628
> new Thread (new ThreadStart (Thread2 )).Start ();
1622
1629
>
1623
- > // Wait for Thread2() to signal that it has a result by setting finished to true.
1630
+ > // Wait for Thread2() to signal that it has a result
1631
+ > // by setting finished to true.
1624
1632
> for (;;)
1625
1633
> {
1626
1634
> if (finished )
@@ -1868,8 +1876,9 @@ method_declaration
1868
1876
;
1869
1877
1870
1878
method_header
1871
- : attributes ? method_modifier * 'partial' ? return_type member_name type_parameter_list ?
1872
- '(' formal_parameter_list ? ')' type_parameter_constraints_clause *
1879
+ : attributes ? method_modifier * 'partial' ? return_type member_name
1880
+ type_parameter_list ? '(' formal_parameter_list ? ')'
1881
+ type_parameter_constraints_clause *
1873
1882
;
1874
1883
1875
1884
method_modifier
@@ -2239,9 +2248,14 @@ When performing overload resolution, a method with a parameter array might be ap
2239
2248
> using System ;
2240
2249
> class Test
2241
2250
> {
2242
- > static void F (params object [] a ) => Console .WriteLine (" F(object[])" );
2243
- > static void F () => Console .WriteLine (" F()" );>
2244
- > static void F (object a0 , object a1 ) => Console .WriteLine (" F(object,object)" );
2251
+ > static void F (params object [] a ) =>
2252
+ > Console .WriteLine (" F(object[])" );
2253
+ >
2254
+ > static void F () =>
2255
+ > Console .WriteLine (" F()" );>
2256
+ >
2257
+ > static void F (object a0 , object a1 ) =>
2258
+ > Console .WriteLine (" F(object,object)" );
2245
2259
>
2246
2260
> static void Main ()
2247
2261
> {
@@ -2501,16 +2515,16 @@ A compile-time error occurs unless all of the following are true for an override
2501
2515
>
2502
2516
> class D : C <string >
2503
2517
> {
2504
- > public override string F () {.. .} // Ok
2505
- > public override C <string > G () {.. .} // Ok
2506
- > public override void H (C <T > x ) {.. .} // Error, should be C<string>
2518
+ > public override string F () {.. .} // Ok
2519
+ > public override C <string > G () {.. .} // Ok
2520
+ > public override void H (C <T > x ) {.. .} // Error, should be C<string>
2507
2521
> }
2508
2522
>
2509
2523
> class E <T ,U > : C <U >
2510
2524
> {
2511
- > public override U F () {.. .} // Ok
2512
- > public override C <U > G () {.. .} // Ok
2513
- > public override void H (C <T > x ) {.. .} // Error, should be C<U>
2525
+ > public override U F () {.. .} // Ok
2526
+ > public override C <U > G () {.. .} // Ok
2527
+ > public override void H (C <T > x ) {.. .} // Error, should be C<U>
2514
2528
> }
2515
2529
> ```
2516
2530
>
@@ -3607,7 +3621,8 @@ Events are declared using *event_declaration*s:
3607
3621
```ANTLR
3608
3622
event_declaration
3609
3623
: attributes ? event_modifier * 'event' type variable_declarators ';'
3610
- | attributes ? event_modifier * 'event' type member_name '{' event_accessor_declarations '}'
3624
+ | attributes ? event_modifier * 'event' type member_name
3625
+ '{' event_accessor_declarations '}'
3611
3626
;
3612
3627
3613
3628
event_modifier
@@ -4125,7 +4140,8 @@ overloadable_unary_operator
4125
4140
;
4126
4141
4127
4142
binary_operator_declarator
4128
- : type 'operator' overloadable_binary_operator '(' fixed_parameter ',' fixed_parameter ')'
4143
+ : type 'operator' overloadable_binary_operator
4144
+ '(' fixed_parameter ',' fixed_parameter ')'
4129
4145
;
4130
4146
4131
4147
overloadable_binary_operator
@@ -4208,8 +4224,8 @@ The `true` and `false` unary operators require pair-wise declaration. A compile-
4208
4224
> {
4209
4225
> IntVector iv1 = new IntVector (4 ); // Vector of 4 x 0
4210
4226
> IntVector iv2 ;
4211
- > iv2 = iv1 ++ ; // iv2 contains 4 x 0, iv1 contains 4 x 1
4212
- > iv2 = ++ iv1 ; // iv2 contains 4 x 2, iv1 contains 4 x 2
4227
+ > iv2 = iv1 ++ ; // iv2 contains 4 x 0, iv1 contains 4 x 1
4228
+ > iv2 = ++ iv1 ; // iv2 contains 4 x 2, iv1 contains 4 x 2
4213
4229
> }
4214
4230
> }
4215
4231
> ```
@@ -4637,7 +4653,8 @@ A ***static constructor*** is a member that implements the actions required to i
4637
4653
4638
4654
```ANTLR
4639
4655
static_constructor_declaration
4640
- : attributes ? static_constructor_modifiers identifier '(' ')' static_constructor_body
4656
+ : attributes ? static_constructor_modifiers identifier '(' ')'
4657
+ static_constructor_body
4641
4658
;
4642
4659
4643
4660
static_constructor_modifiers
@@ -4796,8 +4813,10 @@ A ***finalizer*** is a member that implements the actions required to finalize a
4796
4813
```ANTLR
4797
4814
finalizer_declaration
4798
4815
: attributes ? '~' identifier '(' ')' finalizer_body
4799
- | attributes ? 'extern' unsafe_modifier ? '~' identifier '(' ')' finalizer_body
4800
- | attributes ? unsafe_modifier 'extern' ? '~' identifier '(' ')' finalizer_body
4816
+ | attributes ? 'extern' unsafe_modifier ? '~' identifier '(' ')'
4817
+ finalizer_body
4818
+ | attributes ? unsafe_modifier 'extern' ? '~' identifier '(' ')'
4819
+ finalizer_body
4801
4820
;
4802
4821
4803
4822
finalizer_body
0 commit comments