Skip to content

Commit da94a67

Browse files
committed
wip: Resolving Implicit Redundancy
1 parent a2f742b commit da94a67

File tree

1 file changed

+10
-30
lines changed

1 file changed

+10
-30
lines changed

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

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,22 +2424,13 @@ extension Array: Serializable where Element: SerializableInArray {
24242424
```
24252425
-->
24262426

2427-
#### Resolving Implicit Redundancy
2427+
#### 解决隐式冗余
24282428

2429-
When a concrete type conditionally conforms to a protocol,
2430-
that type implicitly conforms to any parent protocols
2431-
with the same requirements.
2429+
当一个具体类型有条件地遵循一个协议时,该类型隐式地遵循任何具有相同要求的父协议。
24322430

2433-
If you need a type to conditionally conform to two protocols
2434-
that inherit from a single parent,
2435-
explicitly declare conformance to the parent protocol.
2436-
This avoids implicitly conforming to the parent protocol twice
2437-
with different requirements.
2431+
如果您需要一个类型有条件地遵循两个继承自单一父协议的协议,请明确声明对父协议的遵循。这可以避免以不同的要求隐式地两次遵循父协议。
24382432

2439-
The following example explicitly declares
2440-
the conditional conformance of `Array` to `Loggable`
2441-
to avoid a conflict when declaring its conditional conformance
2442-
to both `TitledLoggable` and the new `MarkedLoggable` protocol.
2433+
以下示例明确声明了`Array``Loggable`的条件遵循,以避免在声明其对`TitledLoggable`和新的`MarkedLoggable`协议的条件遵循时发生冲突。
24432434

24442435
```swift
24452436
protocol MarkedLoggable: Loggable {
@@ -2487,10 +2478,7 @@ extension Array: MarkedLoggable where Element: MarkedLoggable { }
24872478
```
24882479
-->
24892480

2490-
Without the extension
2491-
to explicitly declare conditional conformance to `Loggable`,
2492-
the other `Array` extensions would implicitly create these declarations,
2493-
resulting in an error:
2481+
在没有扩展明确声明对 `Loggable` 的条件遵循时,其他 `Array` 扩展会隐式创建这些声明,从而导致错误:
24942482

24952483
```swift
24962484
extension Array: Loggable where Element: TitledLoggable { }
@@ -2579,21 +2567,13 @@ extension Array: Loggable where Element: MarkedLoggable { }
25792567
```
25802568
-->
25812569

2582-
> Grammar of an extension declaration:
2570+
> 扩展声明的语法:
25832571
>
2584-
> *extension-declaration**attributes*_?_ *access-level-modifier*_?_ **`extension`** *type-identifier* *type-inheritance-clause*_?_ *generic-where-clause*_?_ *extension-body* \
2585-
> *extension-body***`{`** *extension-members*_?_ **`}`**
2572+
> *扩展声明**属性*_?_ *访问级别修饰符*_?_ **`扩展`** *类型标识符* *类型继承条款*_?_ *泛型约束条款*_?_ *扩展主体* \
2573+
> *扩展主体***`{`** *扩展成员*_?_ **`}`**
25862574
>
2587-
> *extension-members**extension-member* *extension-members*_?_ \
2588-
> *extension-member**declaration* | *compiler-control-statement*
2589-
2590-
## Subscript Declaration
2591-
2592-
A *subscript* declaration allows you to add subscripting support for objects
2593-
of a particular type and are typically used to provide a convenient syntax
2594-
for accessing the elements in a collection, list, or sequence.
2595-
Subscript declarations are declared using the `subscript` keyword
2596-
and have the following form:
2575+
> *扩展成员**扩展成员* *扩展成员*_?_ \
2576+
> *扩展成员**声明* | *编译器控制语句*
25972577
25982578
```swift
25992579
subscript (<#parameters#>) -> <#return type#> {

0 commit comments

Comments
 (0)