[Observation] Use absolute path in synthesized #sourceLocation#89202
Open
airspeedswift wants to merge 3 commits into
Open
[Observation] Use absolute path in synthesized #sourceLocation#89202airspeedswift wants to merge 3 commits into
airspeedswift wants to merge 3 commits into
Conversation
Member
Author
|
@swift-ci please smoke test |
jamieQ
reviewed
May 18, 2026
hamishknight
approved these changes
May 18, 2026
hamishknight
left a comment
Contributor
There was a problem hiding this comment.
LGTM! As mentioned above I think it would be nice to add a test to verify that #fileID does the correct thing in the expansion
The `@Observable` macro's `locationAnnotated` helper wraps relocated `didSet`/`willSet` bodies in a `#sourceLocation` directive so diagnostics point back to the user's spelled location. It was using the default `location(of:)` overload, which produces `#fileID`-style paths (`Module/file.swift`) — not a filesystem path. When SourceKit or Xcode tries to resolve a diagnostic or index entry whose location was remapped through that directive, the relative identifier doesn't open as a file. The user-visible symptom is "the file couldn't be opened because there is no such file" in the editor, with diagnostics and error navigation breaking for the file. Pass `filePathMode: .filePath` to use the absolute path.
…rceLocation The @observable macro wraps didSet/willSet bodies in #sourceLocation(file: "/abs/path.swift", ...). Confirm that #fileID inside such a body still evaluates to the Module/file.swift form rather than the absolute path.
c66bda3 to
6123163
Compare
Member
Author
|
@swift-ci please smoke test |
Member
Author
|
with swiftlang/sourcekit-lsp#2666 @swift-ci Please smoke test Windows platform |
Member
Author
|
@swift-ci please smoke test windows platform |
1 similar comment
Member
Author
|
@swift-ci please smoke test windows platform |
When the synthesized `#sourceLocation` path contains backslashes, swift-syntax emits a raw string literal (`#"..."#`) instead of a plain `"..."`. Make the FileCheck pattern accept either form.
Member
Author
|
@swift-ci please smoke test and merge |
1 similar comment
Member
Author
|
@swift-ci please smoke test and merge |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The
@Observablemacro'slocationAnnotatedhelper wraps relocateddidSet/willSetbodies in a#sourceLocationdirective so diagnostics point back to the user's spelled location. It was using the defaultlocation(of:)overload, which produces#fileID-style paths (Module/file.swift) — not a filesystem path.When SourceKit or Xcode tries to resolve a diagnostic or index entry whose location was remapped through that directive, the relative identifier doesn't open as a file. The user-visible symptom is "the file couldn't be opened because there is no such file" in the editor, with diagnostics and error navigation breaking for the file.
Pass
filePathMode: .filePathto use the absolute path.fixes rdar://174093766