Why is the following not compilable?
fun bar(foo: List<*>) = "" fun bar(foo: List<*>) = 2
while the following is?
fun bar(foo: List<String>) = "" fun bar(foo: List<Int>) = 2
For me it even gets more curious, when adding a generic type that isn’t even used, i.e. the following compiles too:
fun bar(foo: List<*>) = "" fun <T> bar(foo: List<*>) = 2 // T isn't even used
As the last one doesn’t even use
T and as we know, generics are erased at runtime, why does this one work, while the variant without generic type does not?
Within the byte code methods only differing in return type are allowed (already described in the above linked answer).
Any hints, sources and/or references are welcome.
Not so sure whether this is a deliberate language design choice or a bug… feel free to move the topic.
This question has also been asked here: https://stackoverflow.com/q/52092214/6202869