Skip to content

Commit c5f4563

Browse files
authored
(155363400) Fix-up newer AttributedString availability/deprecation annotations (#1413)
1 parent 6714641 commit c5f4563

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

Sources/FoundationEssentials/AttributedString/AttributedString+Runs.swift

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,26 +209,24 @@ extension AttributedString.Runs.Index: Comparable {
209209
}
210210
}
211211

212-
#if !FOUNDATION_FRAMEWORK
213-
@available(macOS, deprecated: 10000, introduced: 12, message: "AttributedString.Runs.Index should not be used as a Strideable and should instead be offset using the API provided by AttributedString.Runs")
214-
@available(iOS, deprecated: 10000, introduced: 15, message: "AttributedString.Runs.Index should not be used as a Strideable and should instead be offset using the API provided by AttributedString.Runs")
215-
@available(tvOS, deprecated: 10000, introduced: 15, message: "AttributedString.Runs.Index should not be used as a Strideable and should instead be offset using the API provided by AttributedString.Runs")
216-
@available(watchOS, deprecated: 10000, introduced: 8, message: "AttributedString.Runs.Index should not be used as a Strideable and should instead be offset using the API provided by AttributedString.Runs")
217-
@available(visionOS, deprecated: 10000, introduced: 1, message: "AttributedString.Runs.Index should not be used as a Strideable and should instead be offset using the API provided by AttributedString.Runs")
212+
@available(macOS, deprecated: 26, introduced: 12, message: "AttributedString.Runs.Index should not be used as a Strideable and should instead be offset using the API provided by AttributedString.Runs")
213+
@available(iOS, deprecated: 26, introduced: 15, message: "AttributedString.Runs.Index should not be used as a Strideable and should instead be offset using the API provided by AttributedString.Runs")
214+
@available(tvOS, deprecated: 26, introduced: 15, message: "AttributedString.Runs.Index should not be used as a Strideable and should instead be offset using the API provided by AttributedString.Runs")
215+
@available(watchOS, deprecated: 26, introduced: 8, message: "AttributedString.Runs.Index should not be used as a Strideable and should instead be offset using the API provided by AttributedString.Runs")
216+
@available(visionOS, deprecated: 26, introduced: 1, message: "AttributedString.Runs.Index should not be used as a Strideable and should instead be offset using the API provided by AttributedString.Runs")
218217
@available(*, deprecated, message: "AttributedString.Runs.Index should not be used as a Strideable and should instead be offset using the API provided by AttributedString.Runs")
219218
extension AttributedString.Runs.Index: Strideable {
220219
public func distance(to other: Self) -> Int {
221220
// This isn't perfect (since two non-sliced indices might have other sliced runs between them) but checking is better than nothing
222221
precondition(!self._withinDiscontiguous && !other._withinDiscontiguous, "AttributedString.Runs.Index's Strideable conformance may not be used with discontiguous sliced runs")
223222
return other._runOffset - self._runOffset
224223
}
225-
224+
226225
public func advanced(by n: Int) -> Self {
227226
precondition(!self._withinDiscontiguous, "AttributedString.Runs.Index's Strideable conformance may not be used with discontiguous sliced runs")
228227
return Self(_runOffset: self._runOffset + n, withinDiscontiguous: false)
229228
}
230229
}
231-
#endif
232230

233231
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
234232
extension Range<AttributedString.Runs.Index> {
@@ -332,12 +330,18 @@ extension AttributedString.Runs: BidirectionalCollection {
332330
}
333331
}
334332

335-
#if !FOUNDATION_FRAMEWORK
336333
@_alwaysEmitIntoClient
337334
public func distance(from start: Index, to end: Index) -> Int {
335+
#if FOUNDATION_FRAMEWORK
336+
if #available(macOS 26, iOS 26, tvOS 26, watchOS 26, visionOS 26, *) {
337+
_distance(from: start, to: end)
338+
} else {
339+
start.distance(to: end)
340+
}
341+
#else
338342
_distance(from: start, to: end)
343+
#endif
339344
}
340-
#endif
341345

342346
@available(FoundationPreview 6.2, *)
343347
@usableFromInline

0 commit comments

Comments
 (0)