The FIXME say that was due to the bug of SR-6474
return nil
}
}
extension StrideTo: CustomReflectable {
public var customMirror: Mirror {
return Mirror(self, children: ["from": _start, "to": _end, "by": _stride])
}
}
// FIXME(conditional-conformances): This does not yet compile (SR-6474).
#if false
extension StrideTo: RandomAccessCollection
where Element.Stride: BinaryInteger {
public typealias Index = Int
public typealias SubSequence = Slice<StrideTo<Element>>
public typealias Indices = Range<Int>
@inlinable
public var startIndex: Index { return 0 }
and the bug was fixed in 2018.
opened 05:28PM - 25 Nov 17 UTC
closed 05:08AM - 21 Mar 21 UTC
bug
Compiler
ConditionalConformance
| | |
|------------------|-----------------|…
|Previous ID | SR-6474 |
|Radar | rdar://problem/38754177 |
|Original Reporter | @xwu |
|Type | Bug |
|Status | Closed |
|Resolution | Done |
<details>
<summary>Environment</summary>
Swift snapshot 2017-11-24 (a)
</details>
<details>
<summary>Additional Detail from JIRA</summary>
| | |
|------------------|-----------------|
|Votes | 0 |
|Component/s | Compiler |
|Labels | Bug, ConditionalConformance |
|Assignee | @DougGregor |
|Priority | Medium |
md5: 831a0c9866177c91e932d3d199ddbb0c
</details>
**duplicates**:
* [SR-7327](https://bugs.swift.org/browse/SR-7327) Conditional conformance does not conform to inherited protocol
**is duplicated by**:
* [SR-6914](https://bugs.swift.org/browse/SR-6914) Extensions don't add conformance to inherited protocols
* [SR-7253](https://bugs.swift.org/browse/SR-7253) Conditional conformance to P fails if P inherits from two other protocols, but not for eg Array
**relates to**:
* [SR-6840](https://bugs.swift.org/browse/SR-6840) Confusing error in conditional conformance
* [SR-6650](https://bugs.swift.org/browse/SR-6650) Conditional conformance not identifying protocol extension implementation
* [SR-6922](https://bugs.swift.org/browse/SR-6922) [SE-0143] [release mode] type ... does not conform to protocol ...
**Issue Description:**
The following code fails to compile with the 2017-11-24 snapshot.
``` java
protocol P {
var count: Int { get }
}
protocol Q : P { }
// ---
struct S<T> { }
extension S : Q where T : Equatable {
var count: Int { return 1 }
}
// ---
func f<T : P>(_ p: T) {
print(p.count)
}
f(S<Int>())
```
Changing `extension S : Q where...` to `extension S : P where...` allows the code to compile, but of course `S : Q` should imply `S : P`.
Meanwhile, that workaround never permits `S` to conform to `Q`. That is, the following fails to compile:
``` java
struct S<T> { }
extension S : P where T : Equatable {
var count: Int { return 1 }
}
extension S : Q where T : Equatable { }
```
(The practical upshot of this is that `StrideTo` cannot conditionally conform to `RandomAccessCollection` because that protocol exists in a hierarchy refining other protocols.)
glessard
(Guillaume Lessard)
March 19, 2020, 10:24am
2
If it works, which you could presumably find out by building a toolchain, it would be a change in api which would presumably require an evolution proposal.