diff --git a/Tests/TaggedNodeCorpusRoundTripTests.swift b/Tests/TaggedNodeCorpusRoundTripTests.swift index 2f571f3..6fea503 100644 --- a/Tests/TaggedNodeCorpusRoundTripTests.swift +++ b/Tests/TaggedNodeCorpusRoundTripTests.swift @@ -20,11 +20,19 @@ struct TaggedNodeCorpusRoundTripTests { var accepted = 0 var rejected = 0 // `URL.lastPathComponent` is `String` on Darwin's Foundation but `String?` on this - // toolchain's swift-corelibs-foundation. Left deliberately untyped (no explicit `URL` - // parameter anywhere below) since a fixed `Bundle.module.urls(...)` result element type - // also varies across those two Foundations; the `as String?` coercion after the property - // access, not before, is what stays valid on both. - for url in urls.sorted(by: { ($0.lastPathComponent as String? ?? "") < ($1.lastPathComponent as String? ?? "") }) { + // toolchain's swift-corelibs-foundation. A cast or function call INSIDE the `sorted(by:)` + // trailing closure itself (tried first: an `as String?` coercion, then a named helper) + // sent this toolchain's overload resolution down a path that inferred the closure's + // parameters as `NSURL` instead of `URL`, breaking every other `URL`-typed use below -- + // even though a bare `$0.lastPathComponent < $1.lastPathComponent` comparison (no cast, no + // call) resolved fine. Precomputing the sort key in a separate `map` keeps the `sorted(by:)` + // closure itself exactly that simple (comparing two already-plain `String`s), sidestepping + // whatever in the trailing closure was confusing the resolver. + let sortedURLs = urls + .map { url in (url: url, name: (url.lastPathComponent as String?) ?? "") } + .sorted { $0.name < $1.name } + .map(\.url) + for url in sortedURLs { let source = try String(contentsOf: url, encoding: .utf8) let parsed: PureYAML.Tagged.Node do {