-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SymbolGraph] add sourceOrigin field for symbols implementing remote protocol requirements #37351
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
Merged
QuietMisdreavus
merged 2 commits into
main
from
QuietMisdreavus/protocol-req-sourceOrigin
May 13, 2021
Merged
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
14 changes: 14 additions & 0 deletions
14
test/SymbolGraph/Relationships/Synthesized/Inputs/RemoteP.swift
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/// Some Protocol | ||
public protocol P { | ||
func someFunc() | ||
|
||
/// This one has docs! | ||
func otherFunc() | ||
|
||
func bonusFunc() | ||
} | ||
|
||
public extension P { | ||
/// Extra default docs! | ||
func extraFunc() {} | ||
} |
71 changes: 71 additions & 0 deletions
71
test/SymbolGraph/Relationships/Synthesized/RemoteInheritedDocs.swift
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// RUN: %empty-directory(%t) | ||
// RUN: %target-swift-frontend %S/Inputs/RemoteP.swift -module-name RemoteP -emit-module -emit-module-path %t/RemoteP.swiftmodule -emit-module-source-info-path %t/RemoteP.swiftsourceinfo -emit-module-doc-path %t/RemoteP.swiftdoc | ||
// RUN: %target-swift-frontend %s -module-name RemoteInheritedDocs -emit-module -emit-module-path %t/RemoteInheritedDocs.swiftmodule -emit-module-source-info-path %t/RemoteInheritedDocs.swiftsourceinfo -emit-module-doc-path %t/RemoteInheritedDocs.swiftdoc -I %t | ||
|
||
// RUN: %target-swift-symbolgraph-extract -module-name RemoteInheritedDocs -I %t -pretty-print -output-dir %t | ||
// RUN: %FileCheck %s --input-file %t/RemoteInheritedDocs.symbols.json --check-prefix SOME | ||
// RUN: %FileCheck %s --input-file %t/RemoteInheritedDocs.symbols.json --check-prefix OTHER | ||
// RUN: %FileCheck %s --input-file %t/RemoteInheritedDocs.symbols.json --check-prefix BONUS | ||
// RUN: %FileCheck %s --input-file %t/RemoteInheritedDocs.symbols.json --check-prefix INHERIT | ||
// RUN: %FileCheck %s --input-file %t/RemoteInheritedDocs.symbols.json --check-prefix LOCAL | ||
// RUN: %FileCheck %s --input-file %t/RemoteInheritedDocs.symbols.json --check-prefix OVERRIDE | ||
|
||
// RUN: %target-swift-symbolgraph-extract -module-name RemoteInheritedDocs -I %t -pretty-print -output-dir %t -skip-inherited-docs | ||
// RUN: %FileCheck %s --input-file %t/RemoteInheritedDocs.symbols.json --check-prefix SOME | ||
// RUN: %FileCheck %s --input-file %t/RemoteInheritedDocs.symbols.json --check-prefix OTHER | ||
// RUN: %FileCheck %s --input-file %t/RemoteInheritedDocs.symbols.json --check-prefix BONUS | ||
// RUN: %FileCheck %s --input-file %t/RemoteInheritedDocs.symbols.json --check-prefix SKIP | ||
// RUN: %FileCheck %s --input-file %t/RemoteInheritedDocs.symbols.json --check-prefix LOCAL | ||
// RUN: %FileCheck %s --input-file %t/RemoteInheritedDocs.symbols.json --check-prefix OVERRIDE | ||
|
||
// SOME: "source": "s:19RemoteInheritedDocs1SV8someFuncyyF" | ||
// SOME-NEXT: "target": "s:19RemoteInheritedDocs1SV" | ||
// SOME-NEXT: "sourceOrigin" | ||
// SOME-NEXT: "identifier": "s:7RemoteP1PP8someFuncyyF" | ||
// SOME-NEXT: "displayName": "P.someFunc()" | ||
|
||
// OTHER: "source": "s:19RemoteInheritedDocs1SV9otherFuncyyF" | ||
// OTHER-NEXT: "target": "s:19RemoteInheritedDocs1SV" | ||
// OTHER-NEXT: "sourceOrigin" | ||
// OTHER-NEXT: "identifier": "s:7RemoteP1PP9otherFuncyyF" | ||
// OTHER-NEXT: "displayName": "P.otherFunc()" | ||
|
||
// BONUS: "source": "s:19RemoteInheritedDocs1SV9bonusFuncyyF" | ||
// BONUS-NEXT: "target": "s:19RemoteInheritedDocs1SV" | ||
// BONUS-NEXT: "sourceOrigin" | ||
// BONUS-NEXT: "identifier": "s:7RemoteP1PP9bonusFuncyyF" | ||
// BONUS-NEXT: "displayName": "P.bonusFunc()" | ||
|
||
// INHERIT: This one has docs! | ||
// SKIP-NOT: This one has docs! | ||
|
||
// LOCAL: Local docs override! | ||
|
||
// OVERRIDE-NOT: Extra default docs! | ||
// OVERRIDE-NOT: Extension override! | ||
|
||
import RemoteP | ||
|
||
// The `RemoteP.P` protocol has three methods: `someFunc` and `bonusFunc` don't have docs upstream, | ||
// but `otherFunc` does. Regardless, each one needs a `sourceOrigin` field connecting it to | ||
// upstream. | ||
|
||
// `RemoteP.P` also has an extension with a default implementation for `extraFunc` that does have | ||
// docs, but overriding it here should prevent those from appearing | ||
|
||
public struct S: P { | ||
public func someFunc() {} | ||
|
||
public func otherFunc() {} | ||
|
||
/// Local docs override! | ||
public func bonusFunc() {} | ||
|
||
public func extraFunc() {} | ||
} | ||
|
||
public extension P { | ||
/// Extension override! | ||
func someFunc() {} | ||
} | ||
|
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.
Should we also test public default implementations of the protocol or is that not relevant?
e.g.,
and assert that "This one also has docs!" doesn't get inherited. I'm not sure about this one because I think the extension
someFunc()
gets a separate USR thanS
'ssomeFunc()
.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.
Default implementations coming from an extension are tested as part of the existing inherited docs test, though not for protocols in a different module... 🤔
But i'm not sure i understand the situation you're asking about. Can you write an extension like that without an implementation? What happens with
someFunc
in that situation?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.
Sorry, I meant
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.
Ah, that makes more sense. I've added a couple more situations to the test.