Skip to content

Commit ac13ed5

Browse files
committed
wip: Type Subscript Declarations
1 parent 86e2d62 commit ac13ed5

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

swift-6-beta.docc/ReferenceManual/Declarations.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,16 +2606,9 @@ subscript (<#parameters#>) -> <#return type#> {
26062606

26072607
有关下标的更多信息以及下标声明的示例,请参见 <doc:Subscripts>
26082608

2609-
### Type Subscript Declarations
2609+
### 类型下标声明
26102610

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` 声明修饰符相同。
26192612

26202613
<!--
26212614
- test: `cant-override-static-subscript-in-subclass`
@@ -2633,12 +2626,13 @@ with both the `class` and `final` declaration modifiers.
26332626
-->
26342627

26352628
> Grammar of a subscript declaration:
2629+
> 下标声明的语法:
26362630
>
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+
> *下标结果***`->`** *属性*_?_ *类型*
26422636
26432637
## Macro Declaration
26442638

0 commit comments

Comments
 (0)