How do you trick the type checker if you just know...
# getting-started
v
How do you trick the type checker if you just know better? For example in Gradle context if I do
Copy code
configurations.create("foo") {
    val runtimeAttributes = configurations.runtimeClasspath.get().attributes
    runtimeAttributes.keySet().forEach { key ->
        attributes.attribute(key, runtimeAttributes.getAttribute(key))
    }
}
I know that
key
and
runtimeAttributes.getAttribute(key)
are compatible, but the Kotlin compiler does not. The method is declared
attribute(Attribute<T> key, T value)
e
Copy code
.attribute(key as Attribute<Any>, runtimeAttributes.getAttribute(key))
unchecked cast would probably bypass it
v
Nope 😞
Oh, wait, Kotlin is happy now, just IntelliJ is still painting it red, thanks