@@ -2606,16 +2606,9 @@ subscript (<#parameters#>) -> <#return type#> {
2606
2606
2607
2607
有关下标的更多信息以及下标声明的示例,请参见 < doc:Subscripts > 。
2608
2608
2609
- ### Type Subscript Declarations
2609
+ ### 类型下标声明
2610
2610
2611
- To declare a subscript that's exposed by the type,
2612
- rather than by instances of the type,
2613
- mark the subscript declaration with the ` static ` declaration modifier.
2614
- Classes can mark type computed properties with the ` class ` declaration modifier instead
2615
- to allow subclasses to override the superclass’s implementation.
2616
- In a class declaration,
2617
- the ` static ` keyword has the same effect as marking the declaration
2618
- with both the ` class ` and ` final ` declaration modifiers.
2611
+ 要声明由类型本身而非类型实例公开的下标,可以在下标声明中使用 ` static ` 声明修饰符。类可以使用 ` class ` 声明修饰符来标记类型计算属性,以允许子类重写超类的实现。在类声明中,` static ` 关键字的效果与将声明标记为 ` class ` 和 ` final ` 声明修饰符相同。
2619
2612
2620
2613
<!--
2621
2614
- test: `cant-override-static-subscript-in-subclass`
@@ -2633,12 +2626,13 @@ with both the `class` and `final` declaration modifiers.
2633
2626
-->
2634
2627
2635
2628
> Grammar of a subscript declaration:
2629
+ > 下标声明的语法:
2636
2630
>
2637
- > * subscript-declaration * → * subscript-head * * subscript-result * * generic- where-clause * _ ?_ * code-block * \
2638
- > * subscript-declaration * → * subscript-head * * subscript-result * * generic-where-clause * _ ?_ * getter-setter-block * \
2639
- > * subscript-declaration * → * subscript-head * * subscript-result * * generic- where-clause * _ ?_ * getter-setter-keyword-block * \
2640
- > * subscript-head * → * attributes * _ ?_ * declaration-modifiers * _ ?_ ** ` subscript ` ** * generic-parameter-clause * _ ?_ * parameter-clause * \
2641
- > * subscript-result * → ** ` -> ` ** * attributes * _ ?_ * type *
2631
+ > * 下标声明 * → * 下标头 * * 下标结果 * * 通用 where 子句 * _ ?_ * 代码块 * \
2632
+ > * 下标声明 * → * 下标头 * * 下标结果 * * 通用条件子句 * _ ?_ * getter-setter块 * \
2633
+ > * 下标声明 * → * 下标头 * * 下标结果 * * 通用 where 子句 * _ ?_ * getter-setter-关键字-块 * \
2634
+ > * 下标头 * → * 属性 * _ ?_ * 声明修饰符 * _ ?_ ** ` 下标 ` ** * 泛型参数子句 * _ ?_ * 参数子句 * \
2635
+ > * 下标结果 * → ** ` -> ` ** * 属性 * _ ?_ * 类型 *
2642
2636
2643
2637
## Macro Declaration
2644
2638
0 commit comments