Skip to content

Commit a1f9a6b

Browse files
authored
Merge pull request #73701 from tshortli/borrowing-switch-condfail-6.0
[6.0] stdlib: Fix a borrowing switch condfail
2 parents a87fdfc + 2fc11ed commit a1f9a6b

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

stdlib/public/core/Duration.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ extension Duration {
112112
public static func seconds<T: BinaryInteger>(_ seconds: T) -> Duration {
113113
guard let high = Int64(exactly: seconds >> 64) else { fatalError() }
114114
let low = UInt64(truncatingIfNeeded: seconds)
115-
var lowScaled = low.multipliedFullWidth(by: 1_000_000_000_000_000_000)
116-
var highScaled = high * 1_000_000_000_000_000_000
115+
let lowScaled = low.multipliedFullWidth(by: 1_000_000_000_000_000_000)
116+
let highScaled = high * 1_000_000_000_000_000_000
117117
return Duration(_high: highScaled + Int64(lowScaled.high), low: lowScaled.low)
118118
}
119119

@@ -158,8 +158,8 @@ extension Duration {
158158
) -> Duration {
159159
guard let high = Int64(exactly: milliseconds >> 64) else { fatalError() }
160160
let low = UInt64(truncatingIfNeeded: milliseconds)
161-
var lowScaled = low.multipliedFullWidth(by: 1_000_000_000_000_000)
162-
var highScaled = high * 1_000_000_000_000_000
161+
let lowScaled = low.multipliedFullWidth(by: 1_000_000_000_000_000)
162+
let highScaled = high * 1_000_000_000_000_000
163163
return Duration(_high: highScaled + Int64(lowScaled.high), low: lowScaled.low)
164164
}
165165

@@ -187,8 +187,8 @@ extension Duration {
187187
) -> Duration {
188188
guard let high = Int64(exactly: microseconds >> 64) else { fatalError() }
189189
let low = UInt64(truncatingIfNeeded: microseconds)
190-
var lowScaled = low.multipliedFullWidth(by: 1_000_000_000_000)
191-
var highScaled = high * 1_000_000_000_000
190+
let lowScaled = low.multipliedFullWidth(by: 1_000_000_000_000)
191+
let highScaled = high * 1_000_000_000_000
192192
return Duration(_high: highScaled + Int64(lowScaled.high), low: lowScaled.low)
193193
}
194194

@@ -216,8 +216,8 @@ extension Duration {
216216
) -> Duration {
217217
guard let high = Int64(exactly: nanoseconds >> 64) else { fatalError() }
218218
let low = UInt64(truncatingIfNeeded: nanoseconds)
219-
var lowScaled = low.multipliedFullWidth(by: 1_000_000_000)
220-
var highScaled = high * 1_000_000_000
219+
let lowScaled = low.multipliedFullWidth(by: 1_000_000_000)
220+
let highScaled = high * 1_000_000_000
221221
return Duration(_high: highScaled + Int64(lowScaled.high), low: lowScaled.low)
222222
}
223223
}

stdlib/public/core/Optional.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ extension Optional where Wrapped: ~Copyable {
230230
public borrowing func _borrowingMap<U: ~Copyable, E: Error>(
231231
_ transform: (borrowing Wrapped) throws(E) -> U
232232
) throws(E) -> U? {
233-
#if $NoncopyableGenerics
233+
#if compiler(>=6.0) && $NoncopyableGenerics
234234
switch self {
235235
case .some(_borrowing y):
236236
return .some(try transform(y))
@@ -289,7 +289,6 @@ extension Optional {
289289
}
290290
}
291291

292-
@_disallowFeatureSuppression(NoncopyableGenerics)
293292
extension Optional where Wrapped: ~Copyable {
294293
// FIXME(NCG): Make this public.
295294
@_alwaysEmitIntoClient
@@ -309,12 +308,16 @@ extension Optional where Wrapped: ~Copyable {
309308
public func _borrowingFlatMap<U: ~Copyable, E: Error>(
310309
_ transform: (borrowing Wrapped) throws(E) -> U?
311310
) throws(E) -> U? {
311+
#if compiler(>=6.0) && $NoncopyableGenerics
312312
switch self {
313313
case .some(_borrowing y):
314314
return try transform(y)
315315
case .none:
316316
return .none
317317
}
318+
#else
319+
fatalError("Unsupported compiler")
320+
#endif
318321
}
319322
}
320323

0 commit comments

Comments
 (0)