Skip to content
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

TSCBasic: make LocalFileSystem a struct #410

Merged
merged 1 commit into from
Apr 20, 2023
Merged

Conversation

MaxDesiatov
Copy link
Contributor

LocalFileSystem doesn't contain any storage for state, it should be safely convertible to struct. For this we have to remove AnyObject requirement from the FileSystem protocol. As a nice benefit, @unchecked Sendable conformance on LocalFileSystem can be removed as it now inherits Sendable conformance from FileSystem.

`LocalFileSystem` doesn't contain any storage for state, it should be safely convertible to `struct`. For this we have to remove `AnyObject` requirement from the `FileSystem` protocol. As a nice benefit, `@unchecked Sendable` conformance on `LocalFileSystem` can be removed as it now inherits `Sendable` conformance from `FileSystem`.
@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov
Copy link
Contributor Author

Build failure due to SourceKit-LSP relying on this being a reference type and using === for an identity comparison:

SKCoreTests/ToolchainRegistryTests.swift:523:48: error: argument type 'any FileSystem' expected to be an instance of a class or class-constrained type
  precondition(!clang && !swiftc && !clangd || fs === localFileSystem || !shouldChmod,

@tomerd should we just remove that precondition there or is it better to keep it as a class and preserve that AnyObject constraint on the FileSystem protocol, effectively closing this PR?

@tomerd
Copy link
Contributor

tomerd commented Apr 19, 2023

I think testing like this for local file system is anti-pattern, this should be replaced with better logic

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov MaxDesiatov merged commit ae57c40 into main Apr 20, 2023
@MaxDesiatov MaxDesiatov deleted the maxd/local-fs-struct branch April 20, 2023 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants