Skip to content

Commit 48e1d9f

Browse files
committed
Adapt the code to the new Kotlin version
1 parent ca34c0a commit 48e1d9f

File tree

8 files changed

+4
-23
lines changed

8 files changed

+4
-23
lines changed

core/common/src/format/DateTimeComponents.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@ internal class DateTimeComponentsContents internal constructor(
484484
date.hashCode() xor time.hashCode() xor offset.hashCode() xor (timeZoneId?.hashCode() ?: 0)
485485
}
486486

487-
@SharedImmutable
488487
internal val timeZoneField = GenericFieldSpec(PropertyAccessor(DateTimeComponentsContents::timeZoneId))
489488

490489
internal class TimeZoneIdDirective(private val knownZones: Set<String>) :
@@ -538,5 +537,4 @@ private class TwoDigitNumber(private val reference: KMutableProperty0<Int?>) {
538537
}
539538
}
540539

541-
@SharedImmutable
542540
private val emptyDateTimeComponentsContents = DateTimeComponentsContents()

core/common/src/format/DateTimeFormat.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,10 @@ internal sealed class AbstractDateTimeFormat<T, U : Copyable<U>> : DateTimeForma
109109
actualFormat.formatter.format(intermediateFromValue(value), this)
110110
}
111111

112-
private val parser: Parser<U> by lazy { Parser(actualFormat.parser) }
113-
114112
override fun parse(input: CharSequence): T {
115113
val matched = try {
116-
parser.match(input, emptyIntermediate)
114+
// without the fully qualified name, the compilation fails for some reason
115+
kotlinx.datetime.internal.format.parser.Parser(actualFormat.parser).match(input, emptyIntermediate)
117116
} catch (e: ParseException) {
118117
throw DateTimeFormatException("Failed to parse value from '$input'", e)
119118
}
@@ -125,11 +124,11 @@ internal sealed class AbstractDateTimeFormat<T, U : Copyable<U>> : DateTimeForma
125124
}
126125

127126
override fun parseOrNull(input: CharSequence): T? =
128-
parser.matchOrNull(input, emptyIntermediate)?.let { valueFromIntermediateOrNull(it) }
127+
// without the fully qualified name, the compilation fails for some reason
128+
kotlinx.datetime.internal.format.parser.Parser(actualFormat.parser).matchOrNull(input, emptyIntermediate)?.let { valueFromIntermediateOrNull(it) }
129129

130130
}
131131

132-
@SharedImmutable
133132
private val allFormatConstants: List<Pair<String, StringFormat<*>>> by lazy {
134133
fun unwrap(format: DateTimeFormat<*>): StringFormat<*> = (format as AbstractDateTimeFormat<*, *>).actualFormat
135134
// the formats are ordered vaguely by decreasing length, as the topmost among suitable ones is chosen.

core/common/src/format/LocalDateFormat.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,11 @@ internal interface AbstractWithDateBuilder: DateTimeFormatBuilder.WithDate {
314314
}
315315

316316
// these are constants so that the formats are not recreated every time they are used
317-
@SharedImmutable
318317
internal val ISO_DATE by lazy {
319318
LocalDateFormat.build { year(); char('-'); monthNumber(); char('-'); dayOfMonth() }
320319
}
321-
@SharedImmutable
322320
internal val ISO_DATE_BASIC by lazy {
323321
LocalDateFormat.build { year(); monthNumber(); dayOfMonth() }
324322
}
325323

326-
@SharedImmutable
327324
private val emptyIncompleteLocalDate = IncompleteLocalDate()

core/common/src/format/LocalDateTimeFormat.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ internal interface AbstractWithDateTimeBuilder:
7575
}
7676

7777
// these are constants so that the formats are not recreated every time they are used
78-
@SharedImmutable
7978
internal val ISO_DATETIME by lazy {
8079
LocalDateTimeFormat.build {
8180
date(ISO_DATE)
@@ -84,7 +83,6 @@ internal val ISO_DATETIME by lazy {
8483
}
8584
}
8685

87-
@SharedImmutable
8886
internal val ISO_DATETIME_OPTIONAL_SECONDS by lazy {
8987
LocalDateTimeFormat.build {
9088
date(ISO_DATE)
@@ -93,5 +91,4 @@ internal val ISO_DATETIME_OPTIONAL_SECONDS by lazy {
9391
}
9492
}
9593

96-
@SharedImmutable
9794
private val emptyIncompleteLocalDateTime = IncompleteLocalDateTime()

core/common/src/format/LocalTimeFormat.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ internal class LocalTimeFormat(override val actualFormat: StringFormat<TimeField
254254
}
255255

256256
// these are constants so that the formats are not recreated every time they are used
257-
@SharedImmutable
258257
internal val ISO_TIME by lazy {
259258
LocalTimeFormat.build {
260259
hour()
@@ -273,7 +272,6 @@ internal val ISO_TIME by lazy {
273272
}
274273
}
275274

276-
@SharedImmutable
277275
internal val ISO_TIME_OPTIONAL_SECONDS by lazy {
278276
LocalTimeFormat.build {
279277
hour()
@@ -290,5 +288,4 @@ internal val ISO_TIME_OPTIONAL_SECONDS by lazy {
290288
}
291289
}
292290

293-
@SharedImmutable
294291
private val emptyIncompleteLocalTime = IncompleteLocalTime()

core/common/src/format/UtcOffsetFormat.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ private class UtcOffsetSecondOfMinuteDirective(private val padding: Padding) :
229229
}
230230

231231
// these are constants so that the formats are not recreated every time they are used
232-
@SharedImmutable
233232
internal val ISO_OFFSET by lazy {
234233
UtcOffsetFormat.build {
235234
alternativeParsing({ chars("z") }) {
@@ -245,7 +244,6 @@ internal val ISO_OFFSET by lazy {
245244
}
246245
}
247246
}
248-
@SharedImmutable
249247
internal val ISO_OFFSET_BASIC by lazy {
250248
UtcOffsetFormat.build {
251249
alternativeParsing({ chars("z") }) {
@@ -262,13 +260,11 @@ internal val ISO_OFFSET_BASIC by lazy {
262260
}
263261
}
264262

265-
@SharedImmutable
266263
internal val FOUR_DIGIT_OFFSET by lazy {
267264
UtcOffsetFormat.build {
268265
offsetHours()
269266
offsetMinutesOfHour()
270267
}
271268
}
272269

273-
@SharedImmutable
274270
private val emptyIncompleteUtcOffset = IncompleteUtcOffset()

core/common/src/format/migration/Unicode.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,6 @@ private fun unicodeDirective(char: Char, formatLength: Int): UnicodeFormat = whe
599599
else -> UnknownUnicodeDirective(char, formatLength)
600600
}
601601

602-
@SharedImmutable
603602
private val nonPlainCharacters = ('a'..'z') + ('A'..'Z') + listOf('[', ']', '\'')
604603

605604
private fun unsupportedDirective(fieldName: String, recommendation: String? = null): Nothing =

core/native/src/UtcOffset.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import kotlinx.datetime.format.*
1010
import kotlinx.datetime.serializers.UtcOffsetSerializer
1111
import kotlinx.serialization.Serializable
1212
import kotlin.math.abs
13-
import kotlin.native.concurrent.SharedImmutable
1413
import kotlin.native.concurrent.ThreadLocal
1514

1615
@Serializable(with = UtcOffsetSerializer::class)
@@ -116,7 +115,6 @@ public actual fun UtcOffset(hours: Int? = null, minutes: Int? = null, seconds: I
116115
}
117116
}
118117

119-
@SharedImmutable
120118
private val lenientFormat = UtcOffsetFormat.build {
121119
alternativeParsing(
122120
{

0 commit comments

Comments
 (0)