You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Constructing the instance of the struct `GenericStruct` with type `AnotherProtocol` will not compile because there is no concrete implementation for the static requirement of the protocol.
40
40
There is no implementation for for() used above.
41
41
42
+
We, however have an exception for `@objc` protocols that conforms to itself as shown below
43
+
44
+
```swift
45
+
importFoundation
46
+
47
+
@objcprotocolSomeProtocol {
48
+
funcfoo()
49
+
}
50
+
51
+
classSomeClass : SomeProtocol {
52
+
funcfoo() {
53
+
print("foo called")
54
+
}
55
+
}
56
+
57
+
funcfaz<T : SomeProtocol>(_t: T) {
58
+
t.foo()
59
+
}
60
+
61
+
let c: SomeProtocol =SomeClass()
62
+
faz(c)
63
+
```
64
+
65
+
The function `faz` requires that `T` conforms to `SomeProtocol` and we can easily substitute in `SomeProtocol` for `T` because it has no static requirements.
0 commit comments