Skip to content

[6.0] stdlib: Fix a borrowing switch condfail #73701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions stdlib/public/core/Duration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ extension Duration {
public static func seconds<T: BinaryInteger>(_ seconds: T) -> Duration {
guard let high = Int64(exactly: seconds >> 64) else { fatalError() }
let low = UInt64(truncatingIfNeeded: seconds)
var lowScaled = low.multipliedFullWidth(by: 1_000_000_000_000_000_000)
var highScaled = high * 1_000_000_000_000_000_000
let lowScaled = low.multipliedFullWidth(by: 1_000_000_000_000_000_000)
let highScaled = high * 1_000_000_000_000_000_000
return Duration(_high: highScaled + Int64(lowScaled.high), low: lowScaled.low)
}

Expand Down Expand Up @@ -158,8 +158,8 @@ extension Duration {
) -> Duration {
guard let high = Int64(exactly: milliseconds >> 64) else { fatalError() }
let low = UInt64(truncatingIfNeeded: milliseconds)
var lowScaled = low.multipliedFullWidth(by: 1_000_000_000_000_000)
var highScaled = high * 1_000_000_000_000_000
let lowScaled = low.multipliedFullWidth(by: 1_000_000_000_000_000)
let highScaled = high * 1_000_000_000_000_000
return Duration(_high: highScaled + Int64(lowScaled.high), low: lowScaled.low)
}

Expand Down Expand Up @@ -187,8 +187,8 @@ extension Duration {
) -> Duration {
guard let high = Int64(exactly: microseconds >> 64) else { fatalError() }
let low = UInt64(truncatingIfNeeded: microseconds)
var lowScaled = low.multipliedFullWidth(by: 1_000_000_000_000)
var highScaled = high * 1_000_000_000_000
let lowScaled = low.multipliedFullWidth(by: 1_000_000_000_000)
let highScaled = high * 1_000_000_000_000
return Duration(_high: highScaled + Int64(lowScaled.high), low: lowScaled.low)
}

Expand Down Expand Up @@ -216,8 +216,8 @@ extension Duration {
) -> Duration {
guard let high = Int64(exactly: nanoseconds >> 64) else { fatalError() }
let low = UInt64(truncatingIfNeeded: nanoseconds)
var lowScaled = low.multipliedFullWidth(by: 1_000_000_000)
var highScaled = high * 1_000_000_000
let lowScaled = low.multipliedFullWidth(by: 1_000_000_000)
let highScaled = high * 1_000_000_000
return Duration(_high: highScaled + Int64(lowScaled.high), low: lowScaled.low)
}
}
Expand Down
7 changes: 5 additions & 2 deletions stdlib/public/core/Optional.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ extension Optional where Wrapped: ~Copyable {
public borrowing func _borrowingMap<U: ~Copyable, E: Error>(
_ transform: (borrowing Wrapped) throws(E) -> U
) throws(E) -> U? {
#if $NoncopyableGenerics
#if compiler(>=6.0) && $NoncopyableGenerics
switch self {
case .some(_borrowing y):
return .some(try transform(y))
Expand Down Expand Up @@ -289,7 +289,6 @@ extension Optional {
}
}

@_disallowFeatureSuppression(NoncopyableGenerics)
extension Optional where Wrapped: ~Copyable {
// FIXME(NCG): Make this public.
@_alwaysEmitIntoClient
Expand All @@ -309,12 +308,16 @@ extension Optional where Wrapped: ~Copyable {
public func _borrowingFlatMap<U: ~Copyable, E: Error>(
_ transform: (borrowing Wrapped) throws(E) -> U?
) throws(E) -> U? {
#if compiler(>=6.0) && $NoncopyableGenerics
switch self {
case .some(_borrowing y):
return try transform(y)
case .none:
return .none
}
#else
fatalError("Unsupported compiler")
#endif
}
}

Expand Down