Skip to content

Commit e0d423a

Browse files
committed
Add appropriate bounds to CountableClosedRange and CountableRange.
Previously, both CountableRange and CountableClosedRange required their bound types to be Strideable with a Stride type that conforms to SignedInteger. Those constraints were not present on the generic typealiases that replaced these structs. Add them back now, which fixes the GRDB source compatibility regression. Fixes https://bugs.swift.org/browse/SR-6907 / rdar://problem/29066394.
1 parent 4797fae commit e0d423a

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

stdlib/public/core/ClosedRange.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,4 +479,5 @@ extension ClosedRange {
479479
@available(*, deprecated, renamed: "ClosedRange.Index")
480480
public typealias ClosedRangeIndex<T> = ClosedRange<T>.Index where T: Strideable, T.Stride: SignedInteger
481481
@available(*, deprecated, renamed: "ClosedRange")
482-
public typealias CountableClosedRange<T: Comparable> = ClosedRange<T>
482+
public typealias CountableClosedRange<Bound: Strideable> = ClosedRange<Bound>
483+
where Bound.Stride : SignedInteger

stdlib/public/core/Range.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,5 +878,5 @@ extension Range {
878878
}
879879

880880
@available(*, deprecated, renamed: "Range")
881-
public typealias CountableRange<Bound: Comparable> = Range<Bound>
882-
881+
public typealias CountableRange<Bound: Strideable> = Range<Bound>
882+
where Bound.Stride : SignedInteger

test/Compatibility/stdlib_generic_typealiases.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
// RUN: %target-typecheck-verify-swift
22

3-
struct RequiresComparable<T: Comparable> { }
3+
struct RequiresStrideable<T: Strideable> { }
44

55
extension CountableRange { // expected-warning{{'CountableRange' is deprecated: renamed to 'Range'}}
66
// expected-note@-1{{use 'Range' instead}}{{11-25=Range}}
7-
func testComparable() {
8-
_ = RequiresComparable<Bound>()
7+
func testStrideable() {
8+
_ = RequiresStrideable<Bound>()
99
}
10+
11+
func foo() { }
12+
}
13+
14+
extension Range {
15+
func foo() { } // not a redefinition
1016
}
1117

1218
struct RequiresHashable<T: Hashable> { }

0 commit comments

Comments
 (0)