-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
Co-authored-by: Sebastian Sellmair <sebastian.sellmair@jetbrains.com>
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.
Clever! LGTM once the sample build issues are fixed.
import okio.Path.Companion.toPath | ||
import okio.SYSTEM | ||
|
||
class MultiplatformFileSystem { |
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.
Maybe skip this new sample, and instead delete SYSTEM_FILE_SYSTEM
from TestingJvm.kt
and TestingNative.kt
?
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.
Makes sense, added this change.
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.
Long overdue. Nice fix.
This PR creates a new source set called
systemFileSystem
thatjvm
andnative
depend on, and makesFileSystem.SYSTEM
available there.We can't remove the existing
SYSTEM
declarations in the companion objects ofFileSystem
, 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.