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

Create FileSystem.SYSTEM property in shared source set #1455

Merged
merged 3 commits into from
Mar 12, 2024

Conversation

zsmb13
Copy link
Contributor

@zsmb13 zsmb13 commented Mar 11, 2024

This PR creates a new source set called systemFileSystem that jvm and native depend on, and makes FileSystem.SYSTEM available there.

We can't remove the existing SYSTEM declarations in the companion objects of FileSystem, and we can't introduce a companion object in the shared source set as it could not be further refined in more specific source sets.

Therefore, this new declaration is added as an expect extension on the companion. This lets code targeting JVM and native platforms resolve to the extension in common code, while they will actually use the properties of the companions directly when compiled.

To make this change easier to test, we add additional platforms to the samples project, and a sample function that exercises the new property.

Co-authored-by: Sebastian Sellmair <sebastian.sellmair@jetbrains.com>
Copy link
Member

@JakeWharton JakeWharton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever! LGTM once the sample build issues are fixed.

import okio.Path.Companion.toPath
import okio.SYSTEM

class MultiplatformFileSystem {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe skip this new sample, and instead delete SYSTEM_FILE_SYSTEM from TestingJvm.kt and TestingNative.kt ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, added this change.

Copy link
Member

@swankjesse swankjesse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long overdue. Nice fix.

@zsmb13 zsmb13 marked this pull request as ready for review March 12, 2024 08:58
@swankjesse swankjesse merged commit eac869b into square:master Mar 12, 2024
11 checks passed
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.

None yet

3 participants