Swift version
swiftlang-6.4.0.19.4
Platform
all platforms
Editor
VSCode
Description
When background indexing runs with the default mode, modules that contain types decorated with macros that use @attached(extension, conformances: ...) appear to produce swiftmodules whose conformance information is incomplete or missing. Cross-module consumers then see spurious "type does not conform to protocol" diagnostics, broken completion, and broken jump-to-definition for APIs that depend on those conformances.
Switching to backgroundPreparationMode: "noLazy" seems to resolve the issues.
Previously thought to just expose this setting swiftlang/vscode-swift#2291 but instead we should fix the indexing.
Steps to Reproduce
swiftlang/swift-java editing experience is broken due to this and reproduces easily.
Additional context
swift-java's @JavaClass / @JavaInterface macros are declared as:
@attached(member, names: …)
@attached(extension, conformances: AnyJavaObject)
public macro JavaClass(_ fullClassName: String, …)
Their ExtensionMacro expansion emits:
extension <Type>: AnyJavaObject { }
These macros are applied to many types across many modules in the project, and downstream modules use those types where an AnyJavaObject conformance is required.
With backgroundPreparationMode: "enabled" (default), opening the project in VS Code with background indexing enabled produces sporadic but consistent failures (false errors, missing completion, broken jump-to-def) on code that should bevalid. With backgroundPreparationMode: "noLazy", everything works correctly.
The workaround currently committed to swift-java is .sourcekit-lsp/config.json: {"backgroundPreparationMode": "noLazy"}
Steps to reproduce
git clone https://github.com/swiftlang/swift-java && cd swift-java
rm .sourcekit-lsp/config.json to remove the workaround setting the noLazy mode
- Open in VS Code with the Swift extension and background indexing enabled
- Open files that import modules containing
@JavaClass / @JavaInterface types, any file containing them diagnostics / broken IDE features on uses of those types
Logging
No response
Swift version
swiftlang-6.4.0.19.4
Platform
all platforms
Editor
VSCode
Description
When background indexing runs with the default mode, modules that contain types decorated with macros that use
@attached(extension, conformances: ...)appear to produce swiftmodules whose conformance information is incomplete or missing. Cross-module consumers then see spurious "type does not conform to protocol" diagnostics, broken completion, and broken jump-to-definition for APIs that depend on those conformances.Switching to
backgroundPreparationMode: "noLazy"seems to resolve the issues.Previously thought to just expose this setting swiftlang/vscode-swift#2291 but instead we should fix the indexing.
Steps to Reproduce
swiftlang/swift-javaediting experience is broken due to this and reproduces easily.Additional context
swift-java's
@JavaClass/@JavaInterfacemacros are declared as:Their ExtensionMacro expansion emits:
These macros are applied to many types across many modules in the project, and downstream modules use those types where an AnyJavaObject conformance is required.
With
backgroundPreparationMode: "enabled"(default), opening the project in VS Code with background indexing enabled produces sporadic but consistent failures (false errors, missing completion, broken jump-to-def) on code that should bevalid. WithbackgroundPreparationMode: "noLazy", everything works correctly.The workaround currently committed to swift-java is .sourcekit-lsp/config.json:
{"backgroundPreparationMode": "noLazy"}Steps to reproduce
git clone https://github.com/swiftlang/swift-java && cd swift-javarm .sourcekit-lsp/config.jsonto remove the workaround setting the noLazy mode@JavaClass/@JavaInterfacetypes, any file containing them diagnostics / broken IDE features on uses of those typesLogging
No response