Anyone please help..how to resolve this? Overload ...
# announcements
d
Anyone please help..how to resolve this? Overload resolution ambiguity: public open fun <T : Any!> fromJson(p0: JsonElement!, p1: Type!): TypeVariable(T)! defined in com.google.gson.Gson public open fun <T : Any!> fromJson(p0: JsonReader!, p1: Type!): TypeVariable(T)! defined in com.google.gson.Gson public open fun <T : Any!> fromJson(p0: Reader!, p1: Type!): TypeVariable(T)! defined in com.google.gson.Gson public open fun <T : Any!> fromJson(p0: String!, p1: Type!): TypeVariable(T)! defined in com.google.gson.Gson
r
what are you calling the function with? It seems that first argument is ambiguous, therefore it can't select which function of these 4 to call
d
Copy code
return Gson().fromJson(databaseValue, object : TypeToken<UserProfile?>() {}.type)
error pointing on this line
r
what type is
databaseValue
?
d
it is a string
r
if it was a string, this error would not show up, are you sure of that?
d
Yes
Copy code
class UserProfileConvertor : PropertyConverter<UserProfile, String> {
    override fun convertToEntityProperty(databaseValue: String?): UserProfile? {
        if (databaseValue == null) {
            return null
        }
        return Gson().fromJson(databaseValue, object : TypeToken<UserProfile?>() {}.type)
    }

    override fun convertToDatabaseValue(entityProperty: UserProfile?): String? {
        return if (entityProperty == null) null else Gson().toJson(entityProperty)
    }

    fun convertToDatabaseValue(user_profiles: MutableList<Any?>): String? {
        return if (user_profiles == null) null else Gson().toJson(user_profiles)

    }
}
This is the class
c
maybe because its nullable?
what if you change it to databaseValue!! ?
r
should be smartcasted tho, no? But yes, nullable might be the cause
d
plz check the above class i made some change
i dont think it is about the nullable
c
submit an issue here: http://kotl.in/issue that the error message should be improved.
its really the job of the kotlin compiler to output a useful error message here
d
Okay
So i should wait for the response from kotlin right?
c
what happens when you change it to
return Gson().fromJson("", object : TypeToken<UserProfile?>() {}.type)
just try to minimize it and find a simple version that fails, then fix it
d
let me check