-
Notifications
You must be signed in to change notification settings - Fork 160
(#1257) Combined module link issue - public extension of dependent module causes resolution failure #1327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mgrebenets
wants to merge
1
commit into
swiftlang:main
Choose a base branch
from
mgrebenets:mg/links-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
(#1257) Combined module link issue - public extension of dependent module causes resolution failure #1327
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3126,7 +3126,103 @@ class PathHierarchyTests: XCTestCase { | |
| try assertFindsPath("/MainModule/TopLevelProtocol/extensionMember(_:)", in: tree, asSymbolID: "extensionMember1") | ||
| try assertFindsPath("/MainModule/TopLevelProtocol/InnerStruct/extensionMember(_:)", in: tree, asSymbolID: "extensionMember2") | ||
| } | ||
|
|
||
|
|
||
| func testAbsoluteLinksToOtherModuleWithExtensions() async throws { | ||
| enableFeatureFlag(\.isExperimentalLinkHierarchySerializationEnabled) | ||
|
|
||
| let importedProtocolID = "s:14ImportedModule12BaseProtocolP" | ||
| let importedTypeID = "s:14ImportedModule12ExtendedTypeV" | ||
| let extensionSymbolID = "s:e:s:14ImportedModule12ExtendedTypeV04MainC0E15extensionMethodyyF" | ||
| let extensionMethodID = "s:14ImportedModule12ExtendedTypeV04MainC0E15extensionMethodyyF" | ||
| let mainModuleTypeID = "s:10MainModule0A4TypeV" | ||
|
|
||
| let extensionMixin = SymbolGraph.Symbol.Swift.Extension( | ||
| extendedModule: "ImportedModule", | ||
| typeKind: .struct, | ||
| constraints: [] | ||
| ) | ||
|
|
||
| let catalog = Folder(name: "TestCatalog.docc", content: [ | ||
| JSONFile(name: "MainModule.symbols.json", content: makeSymbolGraph( | ||
| moduleName: "MainModule", | ||
| symbols: [ | ||
| makeSymbol(id: mainModuleTypeID, kind: .struct, pathComponents: ["MainType"]) | ||
| ] | ||
| )), | ||
| JSONFile(name: "[email protected]", content: makeSymbolGraph( | ||
| moduleName: "MainModule", | ||
| symbols: [ | ||
| makeSymbol(id: importedProtocolID, kind: .protocol, pathComponents: ["BaseProtocol"]), | ||
| makeSymbol(id: importedTypeID, kind: .struct, pathComponents: ["ExtendedType"]), | ||
| makeSymbol( | ||
| id: extensionSymbolID, | ||
| kind: .extension, | ||
| pathComponents: ["ExtendedType"], | ||
| otherMixins: [extensionMixin] | ||
| ), | ||
| makeSymbol( | ||
| id: extensionMethodID, | ||
| kind: .method, | ||
| pathComponents: ["ExtendedType", "extensionMethod()"], | ||
| otherMixins: [extensionMixin] | ||
| ) | ||
| ], | ||
| relationships: [ | ||
| .init( | ||
| source: extensionMethodID, | ||
| target: extensionSymbolID, | ||
| kind: .memberOf, | ||
| targetFallback: "ImportedModule.ExtendedType" | ||
| ), | ||
| .init( | ||
| source: extensionSymbolID, | ||
| target: importedTypeID, | ||
| kind: .extensionTo, | ||
| targetFallback: "ImportedModule.ExtendedType" | ||
| ) | ||
| ] | ||
| )) | ||
| ]) | ||
|
|
||
| let (_, context) = try await loadBundle(catalog: catalog) | ||
| let tree = context.linkResolver.localResolver.pathHierarchy | ||
|
|
||
| XCTAssertEqual(tree.modules.count, 1) | ||
| XCTAssertEqual(tree.modules.first?.name, "MainModule") | ||
|
|
||
| let paths = tree.caseInsensitiveDisambiguatedPaths() | ||
| XCTAssertEqual(paths[importedProtocolID], "/MainModule/ImportedModule/BaseProtocol") | ||
| XCTAssertEqual(paths[importedTypeID], "/MainModule/ImportedModule/ExtendedType-struct") | ||
| XCTAssertEqual( | ||
| paths[extensionMethodID], | ||
| "/MainModule/ImportedModule/ExtendedType/extensionMethod()" | ||
| ) | ||
|
|
||
| // Verify that symbols can be found at their correct paths | ||
| try assertFindsPath("/MainModule/ImportedModule/BaseProtocol", in: tree, asSymbolID: importedProtocolID) | ||
| try assertFindsPath("/MainModule/ImportedModule/ExtendedType-struct", in: tree, asSymbolID: importedTypeID) | ||
| try assertFindsPath( | ||
| "/MainModule/ImportedModule/ExtendedType/extensionMethod()", | ||
| in: tree, | ||
| asSymbolID: extensionMethodID | ||
| ) | ||
|
|
||
| // Verify that absolute paths to non-existent modules throw moduleNotFound error | ||
| // This is the fix being tested: without it, single-module fallback would trigger incorrectly | ||
| try assertPathRaisesErrorMessage( | ||
| "/ImportedModule/BaseProtocol", | ||
| in: tree, | ||
| context: context, | ||
| expectedErrorMessage: "No module named 'ImportedModule'" | ||
| ) | ||
| try assertPathRaisesErrorMessage( | ||
| "/ImportedModule/ExtendedType", | ||
| in: tree, | ||
| context: context, | ||
| expectedErrorMessage: "No module named 'ImportedModule'" | ||
| ) | ||
| } | ||
|
|
||
| func testMissingRequiredMemberOfSymbolGraphRelationshipInOneLanguageAcrossManyPlatforms() async throws { | ||
| // We make a best-effort attempt to create a valid path hierarchy, even if the symbol graph inputs are not valid. | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test passes even without the changes in PathHierarchy+Find