I'm working on adding a property extension. For example:
package foo;
val Date.ima : String
get() = "This is a date"
import java.util.Date
import foo.ima
fun main(args: Array<String>) {
var d = Date()
println(d.ima)
}
However, I’m doing something a little more interesting, so I add this to the first file:
val String.ima : String
get() = "This is a string"
Now, if I attempt to use both, I get an error:
import java.util.Date import foo.ima
fun main(args: Array<String>) {
var d = Date()
var s = “Something…”
println(d.ima)
println(s.ima)
}
Error(10,13) Kotlin: Type mismatch: inferred type is java.util.Date but jet.String was expected
When you have to function extensions of the same name, things seem to work fine, but with 2 value extensions, there are problems.