Skip to content

Conversation

@stmontgomery
Copy link
Contributor

@stmontgomery stmontgomery commented Nov 9, 2023

Lower the access level of the TestCases protocol from @_spi public to internal (implicitly).

Motivation:

Due to some limitations in Swift's type system, we currently need a protocol named TestCases as a workaround to type-erase our sequence of test cases so that it can be constrained to Sendable (see comment). But because the Test.testCases is public, that protocol also needs to match its access level. Since this protocol is just a workaround, we'd rather not expose the protocol and only expose a property returning a Sequence of test case instances on Test.

Modifications:

  • Add Test._testCases as a private stored property of type (any TestCases)?.
  • Change Test.testCases to a computed property which conditionally down-casts self._testCases.
  • Lower TestCases protocol to internal.

Result:

The TestCases protocol is no longer exposed, and the type of the computed Test.testCases property is any Sequence<Test.Case>.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

@stmontgomery
Copy link
Contributor Author

@swift-ci please test

@stmontgomery
Copy link
Contributor Author

@swift-ci please test

@stmontgomery stmontgomery merged commit 74e2170 into main Nov 9, 2023
@stmontgomery stmontgomery deleted the hide-TestCases-protocol branch November 9, 2023 19:32
stmontgomery added a commit that referenced this pull request Nov 16, 2023
…wer OS versions

This fixes a build failure seen when attempting to build for macOS/iOS versions older than 13.0/16.0, respectively, which was introduced in #104. This introduces a type-erasing wrapper, which fixes the failure and also improves the `Test.testCases` derived property by allowing it to use `some` instead of `any` and further constraining the return type to `Sendable`.
stmontgomery added a commit that referenced this pull request Nov 16, 2023
…wer OS versions (#121)

This fixes a build failure seen when attempting to build for macOS/iOS versions older than 13.0/16.0, respectively, which was introduced in #104. This introduces a type-erasing wrapper, which fixes the failure and also improves the `Test.testCases` derived property by allowing it to use `some` instead of `any` and further constraining the return type to `Sendable`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants