Skip to content
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

Fix compile errors for Swift 6 language mode #230

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion Tests/SwiftAlgorithmsTests/GroupedTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import XCTest
import Algorithms

final class GroupedTests: XCTestCase {
private class SampleError: Error {}
private final class SampleError: Error {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain, why do we need this final keyword here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was added to resolve the following error:
Non-final class 'SampleError' cannot conform to 'Sendable'; use @unchecked Sendable

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explanation. Can you please also update you branch with base branch?


// Based on https://github.com/apple/swift/blob/4d1d8a9de5ebc132a17aee9fc267461facf89bf8/validation-test/stdlib/Dictionary.swift#L1974-L1988

Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftAlgorithmsTests/KeyedTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import XCTest
import Algorithms

final class KeyedTests: XCTestCase {
private class SampleError: Error {}
private final class SampleError: Error {}

func testUniqueKeys() {
let d = ["Apple", "Banana", "Cherry"].keyed(by: { $0.first! })
Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftAlgorithmsTests/RandomSampleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func validateRandomSamples<S: Sequence>(
_ samples: [Int: Int],
elements: S,
expectedValue: Int,
file: StaticString = #file, line: UInt = #line
file: StaticString = (#file), line: UInt = #line
) where S.Element == Int {
let expectedRange = ((expectedValue / 3) * 2) ... ((expectedValue / 3) * 4)
XCTAssertEqualSequences(samples.keys.sorted(), elements,
Expand Down
8 changes: 4 additions & 4 deletions Tests/SwiftAlgorithmsTests/TestUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func XCTAssertEqualSequences<S1: Sequence, S2: Sequence>(
_ expression1: @autoclosure () throws -> S1,
_ expression2: @autoclosure () throws -> S2,
_ message: @autoclosure () -> String = "",
file: StaticString = #file, line: UInt = #line
file: StaticString = (#file), line: UInt = #line
) rethrows where S1.Element: Equatable, S1.Element == S2.Element {
try XCTAssertEqualSequences(expression1(), expression2(), by: ==,
message(), file: file, line: line)
Expand All @@ -88,7 +88,7 @@ func XCTAssertEqualSequences<S1: Sequence, S2: Sequence>(
func XCTAssertUnorderedEqualSequences<S1: Sequence, S2: Sequence>(
_ expression1: @autoclosure () throws -> S1,
_ expression2: @autoclosure () throws -> S2,
file: StaticString = #file, line: UInt = #line
file: StaticString = (#file), line: UInt = #line
) rethrows where S1.Element: Equatable, S1.Element == S2.Element {
var s1 = Array(try expression1())
var missing: [S1.Element] = []
Expand Down Expand Up @@ -116,7 +116,7 @@ func XCTAssertEqualSequences<S1: Sequence, S2: Sequence>(
_ expression2: @autoclosure () throws -> S2,
by areEquivalent: (S1.Element, S1.Element) -> Bool,
_ message: @autoclosure () -> String = "",
file: StaticString = #file, line: UInt = #line
file: StaticString = (#file), line: UInt = #line
) rethrows where S1.Element == S2.Element {

func fail(_ reason: String) {
Expand Down Expand Up @@ -153,7 +153,7 @@ func XCTAssertEqualCollections<C1: Collection, C2: Collection>(
_ expression1: @autoclosure () throws -> C1,
_ expression2: @autoclosure () throws -> C2,
_ message: @autoclosure () -> String = "",
file: StaticString = #file, line: UInt = #line
file: StaticString = (#file), line: UInt = #line
) rethrows where C1.Element: Equatable, C1.Element == C2.Element {
let c1 = try expression1()
let c2 = try expression2()
Expand Down