|
1 | 1 | /*
|
2 | 2 | This source file is part of the Swift.org open source project
|
3 | 3 |
|
4 |
| - Copyright (c) 2022-2024 Apple Inc. and the Swift project authors |
| 4 | + Copyright (c) 2022-2025 Apple Inc. and the Swift project authors |
5 | 5 | Licensed under Apache License v2.0 with Runtime Library Exception
|
6 | 6 |
|
7 | 7 | See https://swift.org/LICENSE.txt for license information
|
@@ -3467,6 +3467,55 @@ class PathHierarchyTests: XCTestCase {
|
3467 | 3467 | ])
|
3468 | 3468 | }
|
3469 | 3469 |
|
| 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 | + |
3470 | 3519 | // Two overloads with more than 64 parameters, but some unique
|
3471 | 3520 | do {
|
3472 | 3521 | let spellOutFormatter = NumberFormatter()
|
|
0 commit comments