Define the default constructor for ReplaceFileCorruptionHandler which can be used in common code
Bug: b/358138957
Test: ./gradlew :datastore:datastore-core:test
(cherry picked from https://android-review.googlesource.com/q/commit:0f39d9164b42a309a9a9fdb89d8ec0f9ef4c9eb8)
(cherry picked from https://android-review.googlesource.com/q/commit:e7ce0350011074a822fb1e5171f98934f849ff73)
Merged-In: I795b055022878928f05970fe63ae6c907ef3af14
Change-Id: I795b055022878928f05970fe63ae6c907ef3af14
diff --git a/datastore/datastore-core/src/commonJvmMain/kotlin/androidx/datastore/core/handlers/ReplaceFileCorruptionHandler.jvm.kt b/datastore/datastore-core/src/commonJvmMain/kotlin/androidx/datastore/core/handlers/ReplaceFileCorruptionHandler.jvm.kt
index d4cd54a..096914f 100644
--- a/datastore/datastore-core/src/commonJvmMain/kotlin/androidx/datastore/core/handlers/ReplaceFileCorruptionHandler.jvm.kt
+++ b/datastore/datastore-core/src/commonJvmMain/kotlin/androidx/datastore/core/handlers/ReplaceFileCorruptionHandler.jvm.kt
@@ -32,7 +32,7 @@
* callback fails, nothing will be written to disk. Since the exception will be swallowed after
* writing the data, this is a good place to log the exception.
*/
-public actual class ReplaceFileCorruptionHandler<T> constructor(
+public actual class ReplaceFileCorruptionHandler<T> actual constructor(
private val produceNewData: (CorruptionException) -> T
) : CorruptionHandler<T> {
diff --git a/datastore/datastore-core/src/commonMain/kotlin/androidx/datastore/core/handlers/ReplaceFileCorruptionHandler.kt b/datastore/datastore-core/src/commonMain/kotlin/androidx/datastore/core/handlers/ReplaceFileCorruptionHandler.kt
index 3a3d4e7..6f3782d 100644
--- a/datastore/datastore-core/src/commonMain/kotlin/androidx/datastore/core/handlers/ReplaceFileCorruptionHandler.kt
+++ b/datastore/datastore-core/src/commonMain/kotlin/androidx/datastore/core/handlers/ReplaceFileCorruptionHandler.kt
@@ -26,6 +26,7 @@
* If the handler encounters an exception when attempting to replace data, the new exception is
* added as a suppressed exception to the original exception and the original exception is thrown.
*/
-public expect class ReplaceFileCorruptionHandler<T> : CorruptionHandler<T> {
+public expect class ReplaceFileCorruptionHandler<T>(produceNewData: (CorruptionException) -> T) :
+ CorruptionHandler<T> {
override suspend fun handleCorruption(ex: CorruptionException): T
}
diff --git a/datastore/datastore-core/src/nativeMain/kotlin/androidx/datastore/core/handlers/ReplaceFileCorruptionHandler.native.kt b/datastore/datastore-core/src/nativeMain/kotlin/androidx/datastore/core/handlers/ReplaceFileCorruptionHandler.native.kt
index 58291e9..449b286 100644
--- a/datastore/datastore-core/src/nativeMain/kotlin/androidx/datastore/core/handlers/ReplaceFileCorruptionHandler.native.kt
+++ b/datastore/datastore-core/src/nativeMain/kotlin/androidx/datastore/core/handlers/ReplaceFileCorruptionHandler.native.kt
@@ -30,7 +30,7 @@
* callback fails, nothing will be written to disk. Since the exception will be swallowed after
* writing the data, this is a good place to log the exception.
*/
-public actual class ReplaceFileCorruptionHandler<T> constructor(
+public actual class ReplaceFileCorruptionHandler<T> actual constructor(
private val produceNewData: (CorruptionException) -> T
) : CorruptionHandler<T> {