@@ -910,21 +910,28 @@ that are part of the function's generic type parameters.
910
910
For example, a function ` someFunction<T>() `
911
911
could return a value of type ` T ` or ` Dictionary<String, T> ` .
912
912
913
- A parameter whose type is an opaque type
914
- is syntactic sugar for a parameter of generic type,
913
+ Writing an opaque type for a parameter
914
+ is syntactic sugar for using a generic type,
915
915
without specifying a name for the generic type parameter.
916
- That is, the following declarations are equivalent,
917
- with ` T1 ` and ` T2 ` representing the unnamed generic type parameters:
916
+ The implicit generic type parameter has a constraint
917
+ that requires it to conform to the protocol named in the opaque type.
918
+ If you write multiple opaque types,
919
+ each one makes its own generic type parameter.
920
+ For example, the following declarations are equivalent:
918
921
919
922
``` swift
920
923
func someFunction (x : some MyProtocol, y : some MyProtocol) { }
921
924
func someFunction <T1 : MyProtocol , T2 : MyProtocol >(x : T1, y : T2) { }
922
925
```
923
926
924
- Because the generic types doesn't have a name,
925
- there's no way to refer to it in code.
927
+ In the second declaration,
928
+ because the generic type parameters ` T1 ` and ` T2 ` have names,
929
+ you can refer use these types elsewhere in the code.
930
+ In contrast,
931
+ the generic type parameters in the first declaration
932
+ don't have names and can't be referenced in other code.
926
933
927
- You can't use this syntactic sugar on the type of a variadic parameter.
934
+ You can't use an opaque type in the type of a variadic parameter.
928
935
929
936
You can't use an opaque type
930
937
as a parameter to a function type being returned,
0 commit comments