Skip to content

Commit de7171a

Browse files
authored
Remove "(unknown context at $xxxxxxxx)" from fully-qualified type names. (#525)
This PR ensures that the aforementioned gunk doesn't show up in our string representations of suites and type IDs. These substrings indicate that a type is `private`, nested in a function, or otherwise might have a non-unique Swift name. We don't care: Swift Testing will treat two private types with the same (otherwise qualified) name in the same module as the same type and will ultimately disambiguate tests in them by source location if needed. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent c5b1b79 commit de7171a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Sources/Testing/Parameterization/TypeInfo.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ extension TypeInfo {
104104
result[0] = String(firstComponent.split(separator: ":", maxSplits: 1).last!)
105105
}
106106

107+
// If a type is private or embedded in a function, its fully qualified
108+
// name may include "(unknown context at $xxxxxxxx)" as a component. Strip
109+
// those out as they're uninteresting to us.
110+
result = result.filter { !$0.starts(with: "(unknown context at") }
111+
107112
return result
108113
case let .nameOnly(fullyQualifiedNameComponents, _, _):
109114
return fullyQualifiedNameComponents

0 commit comments

Comments
 (0)