Skip to content

Commit ecc7eac

Browse files
authored
Support compiling the SDK with Kotlin 2 (#1721)
1 parent 988015a commit ecc7eac

File tree

44 files changed

+3187
-3188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3187
-3188
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ This release will bump the Realm file format from version 23 to 24. Opening a fi
119119
* Deprecated Jenkins and switching to Github Action ([JIRA]https://jira.mongodb.org/browse/RKOTLIN-825).
120120
- Remove CMake required version.
121121
* Updated URL to documentation.
122+
* Refactored to allow compilation with Kotlin 2.0
123+
122124

123125

124126
## 1.14.1 (2024-03-19)

packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/ErrorCategory.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ expect enum class ErrorCategory : CodeDescription {
3535
RLM_ERR_CAT_WEBSOCKET_ERROR,
3636
RLM_ERR_CAT_SYNC_ERROR;
3737

38+
override val nativeValue: Int
39+
override val description: String?
40+
3841
companion object {
3942
internal fun of(nativeValue: Int): ErrorCategory?
4043
}

packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/ErrorCode.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ expect enum class ErrorCode : CodeDescription {
185185
RLM_ERR_CALLBACK,
186186
RLM_ERR_UNKNOWN;
187187

188+
override val nativeValue: Int
189+
override val description: String?
190+
188191
companion object {
189192
fun of(nativeValue: Int): ErrorCode?
190193
}

packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ expect enum class SyncConnectionErrorCode : CodeDescription {
3939
RLM_SYNC_ERR_CONNECTION_SWITCH_TO_FLX_SYNC,
4040
RLM_SYNC_ERR_CONNECTION_SWITCH_TO_PBS;
4141

42+
override val nativeValue: Int
43+
override val description: String?
44+
4245
companion object {
4346
internal fun of(nativeValue: Int): SyncConnectionErrorCode?
4447
}
@@ -86,6 +89,9 @@ expect enum class SyncSessionErrorCode : CodeDescription {
8689
RLM_SYNC_ERR_SESSION_BAD_SCHEMA_VERSION,
8790
RLM_SYNC_ERR_SESSION_SCHEMA_VERSION_CHANGED;
8891

92+
override val nativeValue: Int
93+
override val description: String?
94+
8995
companion object {
9096
internal fun of(nativeValue: Int): SyncSessionErrorCode?
9197
}
@@ -122,6 +128,9 @@ expect enum class WebsocketErrorCode : CodeDescription {
122128
RLM_ERR_WEBSOCKET_RETRY_ERROR,
123129
RLM_ERR_WEBSOCKET_FATAL_ERROR;
124130

131+
override val nativeValue: Int
132+
override val description: String?
133+
125134
companion object {
126135
fun of(nativeValue: Int): WebsocketErrorCode?
127136
}
@@ -141,6 +150,9 @@ expect enum class WebsocketCallbackResult : CodeDescription {
141150
RLM_ERR_SYNC_SOCKET_NOT_SUPPORTED,
142151
RLM_ERR_SYNC_SOCKET_INVALID_ARGUMENT;
143152

153+
override val nativeValue: Int
154+
override val description: String?
155+
144156
companion object {
145157
fun of(nativeValue: Int): WebsocketCallbackResult?
146158
}

packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/ErrorCategory.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
package io.realm.kotlin.internal.interop
1818

1919
actual enum class ErrorCategory(
20-
override val description: String,
21-
override val nativeValue: Int
20+
actual override val description: String?,
21+
actual override val nativeValue: Int
2222
) : CodeDescription {
2323
RLM_ERR_CAT_LOGIC("Logic", realm_error_category_e.RLM_ERR_CAT_LOGIC),
2424
RLM_ERR_CAT_RUNTIME("Runtime", realm_error_category_e.RLM_ERR_CAT_RUNTIME),

packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/ErrorCode.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.realm.kotlin.internal.interop
1818

19-
actual enum class ErrorCode(override val description: String, override val nativeValue: Int) :
19+
actual enum class ErrorCode(actual override val description: String?, actual override val nativeValue: Int) :
2020
CodeDescription {
2121
RLM_ERR_NONE("None", realm_errno_e.RLM_ERR_NONE),
2222
RLM_ERR_RUNTIME("Runtime", realm_errno_e.RLM_ERR_RUNTIME),

packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import io.realm.kotlin.internal.interop.realm_sync_socket_callback_result_e
2323
import io.realm.kotlin.internal.interop.realm_web_socket_errno_e
2424

2525
actual enum class SyncConnectionErrorCode(
26-
override val description: String,
27-
override val nativeValue: Int
26+
actual override val description: String?,
27+
actual override val nativeValue: Int
2828
) : CodeDescription {
2929
RLM_SYNC_ERR_CONNECTION_CONNECTION_CLOSED("ConnectionClosed", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_CONNECTION_CLOSED),
3030
RLM_SYNC_ERR_CONNECTION_OTHER_ERROR("OtherError", realm_sync_errno_connection_e.RLM_SYNC_ERR_CONNECTION_OTHER_ERROR),
@@ -51,8 +51,8 @@ actual enum class SyncConnectionErrorCode(
5151
}
5252

5353
actual enum class SyncSessionErrorCode(
54-
override val description: String,
55-
override val nativeValue: Int
54+
actual override val description: String?,
55+
actual override val nativeValue: Int
5656
) : CodeDescription {
5757
RLM_SYNC_ERR_SESSION_SESSION_CLOSED("SessionClosed", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_SESSION_CLOSED),
5858
RLM_SYNC_ERR_SESSION_OTHER_SESSION_ERROR("OtherSessioError", realm_sync_errno_session_e.RLM_SYNC_ERR_SESSION_OTHER_SESSION_ERROR),
@@ -100,8 +100,8 @@ actual enum class SyncSessionErrorCode(
100100
}
101101

102102
actual enum class WebsocketErrorCode(
103-
override val description: String,
104-
override val nativeValue: Int
103+
actual override val description: String?,
104+
actual override val nativeValue: Int
105105
) : CodeDescription {
106106
RLM_ERR_WEBSOCKET_OK("Ok", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_OK),
107107
RLM_ERR_WEBSOCKET_GOINGAWAY("GoingAway", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_GOINGAWAY),
@@ -139,7 +139,7 @@ actual enum class WebsocketErrorCode(
139139
}
140140
}
141141

142-
actual enum class WebsocketCallbackResult(override val description: String, override val nativeValue: Int) : CodeDescription {
142+
actual enum class WebsocketCallbackResult(actual override val description: String?, actual override val nativeValue: Int) : CodeDescription {
143143

144144
RLM_ERR_SYNC_SOCKET_SUCCESS(
145145
"Websocket callback success",

packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/ErrorCategory.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import realm_wrapper.realm_error_category
2121
* Error categories are composed of multiple categories in once, it is a flag property.
2222
*/
2323
actual enum class ErrorCategory(
24-
override val description: String,
25-
override val nativeValue: Int
24+
actual override val description: String?,
25+
actual override val nativeValue: Int
2626
) : CodeDescription {
2727
RLM_ERR_CAT_LOGIC("Logic", realm_error_category.RLM_ERR_CAT_LOGIC.value.toInt()),
2828
RLM_ERR_CAT_RUNTIME("Runtime", realm_error_category.RLM_ERR_CAT_RUNTIME.value.toInt()),

packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/ErrorCode.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package io.realm.kotlin.internal.interop
1919
import realm_wrapper.realm_errno
2020

2121
actual enum class ErrorCode(
22-
override val description: String,
22+
actual override val description: String?,
2323
nativeError: realm_errno
2424
) : CodeDescription {
2525
RLM_ERR_NONE("None", realm_errno.RLM_ERR_NONE),
@@ -186,7 +186,7 @@ actual enum class ErrorCode(
186186
RLM_ERR_CALLBACK("Callback", realm_errno.RLM_ERR_CALLBACK),
187187
RLM_ERR_UNKNOWN("Unknown", realm_errno.RLM_ERR_UNKNOWN);
188188

189-
override val nativeValue: Int = nativeError.value.toInt()
189+
actual override val nativeValue: Int = nativeError.value.toInt()
190190

191191
val asNativeEnum: realm_errno = nativeError
192192

packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import realm_wrapper.realm_sync_socket_callback_result
2222
import realm_wrapper.realm_web_socket_errno
2323

2424
actual enum class SyncConnectionErrorCode(
25-
override val description: String,
25+
actual override val description: String?,
2626
errorCode: realm_sync_errno_connection
2727
) : CodeDescription {
2828
RLM_SYNC_ERR_CONNECTION_CONNECTION_CLOSED("ConnectionClosed", realm_sync_errno_connection.RLM_SYNC_ERR_CONNECTION_CONNECTION_CLOSED),
@@ -41,7 +41,7 @@ actual enum class SyncConnectionErrorCode(
4141
RLM_SYNC_ERR_CONNECTION_SWITCH_TO_FLX_SYNC("SwitchToFlxSync", realm_sync_errno_connection.RLM_SYNC_ERR_CONNECTION_SWITCH_TO_FLX_SYNC),
4242
RLM_SYNC_ERR_CONNECTION_SWITCH_TO_PBS("SwitchToPbs", realm_sync_errno_connection.RLM_SYNC_ERR_CONNECTION_SWITCH_TO_PBS);
4343

44-
override val nativeValue: Int = errorCode.value.toInt()
44+
actual override val nativeValue: Int = errorCode.value.toInt()
4545

4646
actual companion object {
4747
internal actual fun of(nativeValue: Int): SyncConnectionErrorCode? =
@@ -52,7 +52,7 @@ actual enum class SyncConnectionErrorCode(
5252
}
5353

5454
actual enum class SyncSessionErrorCode(
55-
override val description: String,
55+
actual override val description: String?,
5656
errorCode: realm_sync_errno_session
5757
) : CodeDescription {
5858
RLM_SYNC_ERR_SESSION_SESSION_CLOSED("SessionClosed", realm_sync_errno_session.RLM_SYNC_ERR_SESSION_SESSION_CLOSED),
@@ -92,7 +92,7 @@ actual enum class SyncSessionErrorCode(
9292
RLM_SYNC_ERR_SESSION_BAD_SCHEMA_VERSION("BadSchemaVersion", realm_sync_errno_session.RLM_SYNC_ERR_SESSION_BAD_SCHEMA_VERSION),
9393
RLM_SYNC_ERR_SESSION_SCHEMA_VERSION_CHANGED("SchemaVersionChanged", realm_sync_errno_session.RLM_SYNC_ERR_SESSION_SCHEMA_VERSION_CHANGED);
9494

95-
override val nativeValue: Int = errorCode.value.toInt()
95+
actual override val nativeValue: Int = errorCode.value.toInt()
9696

9797
actual companion object {
9898
internal actual fun of(nativeValue: Int): SyncSessionErrorCode? =
@@ -103,7 +103,7 @@ actual enum class SyncSessionErrorCode(
103103
}
104104

105105
actual enum class WebsocketErrorCode(
106-
override val description: String,
106+
actual override val description: String?,
107107
errorCode: realm_web_socket_errno,
108108
) : CodeDescription {
109109
RLM_ERR_WEBSOCKET_OK("Ok", realm_web_socket_errno.RLM_ERR_WEBSOCKET_OK),
@@ -132,7 +132,7 @@ actual enum class WebsocketErrorCode(
132132
RLM_ERR_WEBSOCKET_RETRY_ERROR("RetryError", realm_web_socket_errno.RLM_ERR_WEBSOCKET_RETRY_ERROR),
133133
RLM_ERR_WEBSOCKET_FATAL_ERROR("FatalError", realm_web_socket_errno.RLM_ERR_WEBSOCKET_FATAL_ERROR);
134134

135-
override val nativeValue: Int = errorCode.value.toInt()
135+
actual override val nativeValue: Int = errorCode.value.toInt()
136136

137137
val asNativeEnum: realm_web_socket_errno = errorCode
138138

@@ -145,7 +145,7 @@ actual enum class WebsocketErrorCode(
145145
}
146146

147147
actual enum class WebsocketCallbackResult(
148-
override val description: String,
148+
actual override val description: String?,
149149
nativeError: realm_sync_socket_callback_result
150150
) : CodeDescription {
151151

@@ -182,7 +182,7 @@ actual enum class WebsocketCallbackResult(
182182
realm_sync_socket_callback_result.RLM_ERR_SYNC_SOCKET_INVALID_ARGUMENT
183183
);
184184

185-
override val nativeValue: Int = nativeError.value.toInt()
185+
actual override val nativeValue: Int = nativeError.value.toInt()
186186
val asNativeEnum: realm_sync_socket_callback_result = nativeError
187187

188188
actual companion object {

0 commit comments

Comments
 (0)