Skip to content

Commit f742a13

Browse files
[6.1] Support suggesting a combination of parameter types and return types as disambiguation when the function returns 'void' (#1157)
* Support suggesting a combination of parameter types and return types as disambiguation when the function returns 'void' (#1156) * Support suggesting a combination of parameter types and return types as disambiguation when the function returns 'void' rdar://143897549 * Update year in header comment for modified files * Add `2025` to allowed years in license header. (#1153) Update the `check-source` script to allow 2025 in the license header. --------- Co-authored-by: Sofía Rodríguez <sofia_rodriguez@apple.com>
1 parent 4e6ecb9 commit f742a13

File tree

3 files changed

+53
-5
lines changed

3 files changed

+53
-5
lines changed

Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+DisambiguatedPaths.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ extension PathHierarchy.DisambiguationContainer {
266266
types: { element in
267267
guard let parameterTypes = element.parameterTypes,
268268
!parameterTypes.isEmpty,
269-
let returnTypes = element.returnTypes,
270-
!returnTypes.isEmpty
269+
let returnTypes = element.returnTypes
271270
else {
272271
return nil
273272
}

Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2022-2024 Apple Inc. and the Swift project authors
4+
Copyright (c) 2022-2025 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -3467,6 +3467,55 @@ class PathHierarchyTests: XCTestCase {
34673467
])
34683468
}
34693469

3470+
// Each overload requires a combination parameters and return values to disambiguate
3471+
do {
3472+
// Int -> ()
3473+
// Bool -> ()
3474+
// Int -> Int
3475+
let catalog = Folder(name: "unit-test.docc", content: [
3476+
JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph(
3477+
moduleName: "ModuleName",
3478+
symbols: [
3479+
// Int -> Void
3480+
makeSymbol(id: "function-overload-1", kind: .func, pathComponents: ["doSomething(first:)"], signature: .init(
3481+
parameters: [
3482+
makeParameter("first", decl: [intType]), // Int
3483+
], returns: makeFragments([ // ->
3484+
voidType // ()
3485+
])
3486+
)),
3487+
3488+
// Bool -> Void
3489+
makeSymbol(id: "function-overload-2", kind: .func, pathComponents: ["doSomething(first:)"], signature: .init(
3490+
parameters: [
3491+
makeParameter("first", decl: [boolType]), // Bool
3492+
], returns: makeFragments([ // ->
3493+
voidType // ()
3494+
])
3495+
)),
3496+
3497+
// Int -> Int
3498+
makeSymbol(id: "function-overload-3", kind: .func, pathComponents: ["doSomething(first:)"], signature: .init(
3499+
parameters: [
3500+
makeParameter("first", decl: [intType]), // Int
3501+
], returns: makeFragments([ // ->
3502+
intType // Int
3503+
])
3504+
)),
3505+
]
3506+
))
3507+
])
3508+
3509+
let (_, context) = try loadBundle(catalog: catalog)
3510+
let tree = context.linkResolver.localResolver.pathHierarchy
3511+
3512+
try assertPathCollision("ModuleName/doSomething(first:)", in: tree, collisions: [
3513+
(symbolID: "function-overload-1", disambiguation: "-(Int)->()"), // ( Int ) -> ()
3514+
(symbolID: "function-overload-2", disambiguation: "-(Bool)"), // ( Bool )
3515+
(symbolID: "function-overload-3", disambiguation: "->_"), // -> _
3516+
])
3517+
}
3518+
34703519
// Two overloads with more than 64 parameters, but some unique
34713520
do {
34723521
let spellOutFormatter = NumberFormatter()

bin/check-source

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# This source file is part of the Swift.org open source project
44
#
5-
# Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
5+
# Copyright (c) 2021-2025 Apple Inc. and the Swift project authors
66
# Licensed under Apache License v2.0 with Runtime Library Exception
77
#
88
# See https://swift.org/LICENSE.txt for license information
@@ -18,7 +18,7 @@ here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1818

1919
function replace_acceptable_years() {
2020
# this needs to replace all acceptable forms with 'YEARS'
21-
sed -e 's/20[12][78901234]-20[12][8901234]/YEARS/' -e 's/20[12][8901234]/YEARS/'
21+
sed -e 's/20[12][789012345]-20[12][89012345]/YEARS/' -e 's/20[12][89012345]/YEARS/'
2222
}
2323

2424
printf "=> Checking for unacceptable language… "

0 commit comments

Comments
 (0)