How does erasure work in Kotlin?

Actually Kotlin knows the difference between the two methods in your example, but jvm will not. That’s why it’s a “platform” clash.

You can make your second example compile by using the @JvmName annotation:

class Foo {
  @JvmName("barString") fun bar(foo: List<String>): String {
    return ""
  }

  @JvmName("barInt") fun bar(foo: List<Int>): String {
    return "2";
  }
}

This annotation exists for this very reason. You can read more in the interop documentation.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)