From 175dd980f8db3f0671867df50ab08b9a0341481e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 27 Apr 2022 15:15:03 +0600 Subject: [PATCH] several warnings fixes --- .../kotlin/dev/inmo/micro_utils/common/Annotations.kt | 2 ++ .../kotlin/dev/inmo/micro_utils/common/DiffUtils.kt | 6 +++++- .../kotlin/dev/inmo/micro_utils/common/Either.kt | 2 +- .../dev/inmo/micro_utils/ktor/common/StandardSerializer.kt | 2 ++ .../dev/inmo/micro_utils/pagination/WalkPagination.kt | 1 + .../kotlin/dev/inmo/micro_utils/repos/MapperRepo.kt | 1 + .../dev/inmo/micro_utils/repos/mappers/KeyValueMappers.kt | 3 ++- .../micro_utils/repos/mappers/OneToManyKeyValueMappers.kt | 1 + .../dev/inmo/micro_utils/repos/FileStandardKeyValueRepo.kt | 4 +++- .../dev/inmo/micro_utils/repos/keyvalue/KeyValueStore.kt | 7 ++++++- 10 files changed, 24 insertions(+), 5 deletions(-) diff --git a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/Annotations.kt b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/Annotations.kt index 4501df28077..a317e27471a 100644 --- a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/Annotations.kt +++ b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/Annotations.kt @@ -1,3 +1,5 @@ +@file:Suppress("OPT_IN_IS_NOT_ENABLED") + package dev.inmo.micro_utils.common @RequiresOptIn( diff --git a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/DiffUtils.kt b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/DiffUtils.kt index ab8c6d2ebc6..c1da3f3aa72 100644 --- a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/DiffUtils.kt +++ b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/DiffUtils.kt @@ -43,6 +43,7 @@ private inline fun performChanges( if (oldOneEqualToNewObject || newOneEqualToOldObject) { changedList.addAll( potentialChanges.take(i).mapNotNull { + @Suppress("UNCHECKED_CAST") if (it.first != null && it.second != null) it as Pair, IndexedValue> else null } ) @@ -121,7 +122,10 @@ fun Iterable.calculateDiff( when { oldObject === newObject || (oldObject == newObject && !strictComparison) -> { - changedObjects.addAll(potentiallyChangedObjects.map { it as Pair, IndexedValue> }) + changedObjects.addAll(potentiallyChangedObjects.map { + @Suppress("UNCHECKED_CAST") + it as Pair, IndexedValue> + }) potentiallyChangedObjects.clear() } else -> { diff --git a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/Either.kt b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/Either.kt index 595967582d1..c07426febe1 100644 --- a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/Either.kt +++ b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/Either.kt @@ -33,7 +33,7 @@ class EitherSerializer( t1Serializer: KSerializer, t2Serializer: KSerializer, ) : KSerializer> { - @OptIn(ExperimentalSerializationApi::class, InternalSerializationApi::class) + @OptIn(InternalSerializationApi::class) override val descriptor: SerialDescriptor = buildSerialDescriptor( "TypedSerializer", SerialKind.CONTEXTUAL diff --git a/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/StandardSerializer.kt b/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/StandardSerializer.kt index 5d088c9721b..0e7163665e0 100644 --- a/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/StandardSerializer.kt +++ b/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/StandardSerializer.kt @@ -1,3 +1,5 @@ +@file:Suppress("NOTHING_TO_INLINE") + package dev.inmo.micro_utils.ktor.common import kotlinx.serialization.* diff --git a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/WalkPagination.kt b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/WalkPagination.kt index 05c1087fed8..e46baf20d68 100644 --- a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/WalkPagination.kt +++ b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/WalkPagination.kt @@ -27,4 +27,5 @@ inline fun PaginationResult.thisPageIfNotEmpty(): PaginationResult? = null } +@Suppress("NOTHING_TO_INLINE") inline fun PaginationResult.currentPageIfNotEmpty() = thisPageIfNotEmpty() diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapperRepo.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapperRepo.kt index 3d25d74ee2a..313c7970f60 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapperRepo.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapperRepo.kt @@ -1,5 +1,6 @@ package dev.inmo.micro_utils.repos +@Suppress("UNCHECKED_CAST") interface MapperRepo { suspend fun FromKey.toOutKey() = this as ToKey suspend fun FromValue.toOutValue() = this as ToValue diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/KeyValueMappers.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/KeyValueMappers.kt index ed67d4c9e4e..3644852d713 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/KeyValueMappers.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/KeyValueMappers.kt @@ -126,9 +126,10 @@ inline fun mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom) ) +@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") open class MapperStandardKeyValueRepo( private val to: StandardKeyValueRepo, - mapper: MapperRepo + private val mapper: MapperRepo ) : StandardKeyValueRepo, MapperRepo by mapper, ReadStandardKeyValueRepo by MapperReadStandardKeyValueRepo(to, mapper), diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/OneToManyKeyValueMappers.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/OneToManyKeyValueMappers.kt index 97b872a7b1c..74751f79518 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/OneToManyKeyValueMappers.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/OneToManyKeyValueMappers.kt @@ -132,6 +132,7 @@ inline fun mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom) ) +@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") open class MapperOneToManyKeyValueRepo( private val to: OneToManyKeyValueRepo, mapper: MapperRepo diff --git a/repos/common/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/FileStandardKeyValueRepo.kt b/repos/common/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/FileStandardKeyValueRepo.kt index 9afb05be768..5e93cfc10e6 100644 --- a/repos/common/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/FileStandardKeyValueRepo.kt +++ b/repos/common/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/FileStandardKeyValueRepo.kt @@ -175,9 +175,11 @@ class FileWriteStandardKeyValueRepo( } @Warning("Files watching will not correctly works on Android Platform with version of API lower than API 26") +@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") class FileStandardKeyValueRepo( folder: File, filesChangedProcessingScope: CoroutineScope? = null ) : StandardKeyValueRepo, WriteStandardKeyValueRepo by FileWriteStandardKeyValueRepo(folder, filesChangedProcessingScope), - ReadStandardKeyValueRepo by FileReadStandardKeyValueRepo(folder) \ No newline at end of file + ReadStandardKeyValueRepo by FileReadStandardKeyValueRepo(folder) { +} diff --git a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/keyvalue/KeyValueStore.kt b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/keyvalue/KeyValueStore.kt index 20ce4d8274e..bc863224c42 100644 --- a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/keyvalue/KeyValueStore.kt +++ b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/keyvalue/KeyValueStore.kt @@ -16,6 +16,7 @@ fun Context.keyValueStore( name: String = "default", cacheValues: Boolean = false ): StandardKeyValueRepo { + @Suppress("UNCHECKED_CAST") return cache.getOrPut(name) { KeyValueStore(this, name, cacheValues) } as KeyValueStore @@ -62,6 +63,7 @@ class KeyValueStore internal constructor ( } override suspend fun get(k: String): T? { + @Suppress("UNCHECKED_CAST") return (cachedData ?. get(k) ?: sharedPreferences.all[k]) as? T } @@ -73,7 +75,10 @@ class KeyValueStore internal constructor ( PaginationResult( it.page, it.pagesNumber, - it.results.map { it as T }.let { if (reversed) it.reversed() else it }, + it.results.map { + @Suppress("UNCHECKED_CAST") + it as T + }.let { if (reversed) it.reversed() else it }, it.size ) }