Not sure if this is a good place to ask, but I hav...
# general-advice
l
Not sure if this is a good place to ask, but I have this code which is working fine in 2.4 but fails in 2.5:
Copy code
inline fun <reified T : Enum<T>, V> ((T) -> V).find(value: V): T? {
    return enumValues<T>().firstOrNull { this(it) == value }
}

enum class Animal(val string: String) {
    Cat("cat"),
    Dog("dog");

    companion object {
        // error: Return type 'Nothing' needs to be specified explicitly.
        // error: Cannot use 'Nothing' as reified type parameter.
        fun fromString(string: String) = Animal::string.find(string)
                ?: throw IllegalArgumentException("Bad animal: '$string'")
    }
}
Any idea as to why, and why this behavior was changed? (Playground link)
h
I'd ask in #eap
y
Importantly, removing the elvis makes it compile
c