hudsonb
hudsonb

Reputation: 2294

Why does == and equals produce different results?

Executing the following code:

inline fun <reified R> foobar() {
    println(R::class == Double::class)
    println(R::class.equals(Double::class))
}

fun main(args: Array<String>) {
    foobar<Double>()
}

Produces the following output:

false
true

Why is there a difference between == and equals in this case? IntelliJ itself is suggesting that I replace the equals call with ==. Also, I could have sworn this code using == was working in the past.

Using kotlin version 1.1.0-rc91

Upvotes: 3

Views: 120

Answers (1)

hotkey
hotkey

Reputation: 147911

This behavior is a known issue in code generation for class tokens of reified type parameters, it's tracked here: KT-17748.

Upvotes: 3

Related Questions