I was wondering how is it possible that the
KotlinMultiplatformExtensions can be cast to
ExtensionAware when none of its supertypes extends
ExtensionAware. There must be some Gradle black magic here, but my muggle programming skills are not enough to figure it out.
I wondered into this question by looking at the generated Kotlin code for the K/Native
/** * Retrieves the [cocoapods][org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension] extension. */ val org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension.`cocoapods`: org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension get() = (this as org.gradle.api.plugins.ExtensionAware).extensions.getByName("cocoapods") as org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension /** * Configures the [cocoapods][org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension] extension. */ fun org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension.`cocoapods`(configure: org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension.() -> Unit): Unit = (this as org.gradle.api.plugins.ExtensionAware).extensions.configure("cocoapods", configure) // 🠑 some real avada kedavra high level s here!