[BUG] [multiplatform] ExperimentalAPI annotation from Kotlin 1.6.0 and above

1
closed
shadowsheep1
shadowsheep1
Posted 2 months ago

[BUG] [multiplatform] ExperimentalAPI annotation from Kotlin 1.6.0 and above #10467

With this setup:

AS Artic Fox 2020.3.1 Patch 2

object Versions {
    const val iosTestTask = false
    const val foo = "8.6.8"
    const val kotlin = "1.5.31"

    // Gradle
    const val androidGradlePlugin = "7.0.2"
    const val gradle = "gradle-7.2-bin"

    // Android
    const val compileSdk = 30
    const val minSdk = 23
    const val targetSdk = compileSdk

    // You can also use this to specify versions for dependencies. Having consistent
    // versions between modules can avoid behavior conflicts.
    const val sqldelight = "1.5.1"
    const val settings = "0.8"
    const val serialization = "1.2.2"
    // https://kotlinlang.org/docs/mobile/concurrency-and-coroutines.html#multithreaded-coroutines
    const val coroutines = "1.5.1-native-mt"
    const val ktor = "1.6.3"
    const val openapigen = "5.2.1"
}

Experimental annotation

I had (using @InternalAPI annotation) this error.

e: Opt-in requirement marker annotation on override requires the same marker on base declaration

I'd to use @OptIn(InternalAPI::class) instead

File: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/auth/HttpBasicAuth.kt.mustache

package {{packageName}}.auth

import io.ktor.util.InternalAPI
import io.ktor.util.encodeBase64

class HttpBasicAuth : Authentication {
    var username: String? = null
    var password: String? = null

   @OptIn(InternalAPI::class)
    override fun apply(query: MutableMap<String, List<String>>, headers: MutableMap<String, String>) {
        if (username == null && password == null) return
        val str = (username ?: "") + ":" + (password ?: "")
        val auth = str.encodeBase64()
        headers["Authorization"] = "Basic $auth"
    }
}
shadowsheep1
shadowsheep1
Created 2 months ago

I've found that I use Kotlin version 1.5.31 but the latest multiplatform plugin 1.6.0-M1 where the above annotation is now and error (previous was a warning)