我尝试了类似firestore-found-conflicting-getters-for-name-istext之类的问题,但没有帮助,我的实际错误是
Found conflicting getters for name getRatingDetail on class UserRatingSong
我的班级结构是这样的
interface UserRating<T : Rating> {
val ratingDetail: T
val userDetail: User
}
data class UserRatingSong(override val ratingDetail: SongRating,override val userDetail: User) : UserRating<SongRating> {
constructor() : this(SongRating(), User())
}
interface Rating {
var averageOfCategories: Float
}
data class SongRating(override var averageOfCategories: Float,var singerRating: Float,var musicRating: Float,var lyricsRating: Float) : Rating {
constructor() : this(0f, 0f, 0f, 0f)
}
data class User(val userName: String, val userId: String, val profilePic: String) {
constructor() : this("", "", "")
}
尝试添加新评分时出现此错误
fun addRating(userRating:UserRatingSong){
firestore.collection("myCollection")
.document("docId")
.collection("userRatings")
.document(userRating.userDetail.userId)
.set(userRating)//error occurs here
}
由于我检查过任何类成员都不具有相似的名称,所以我什至还尝试更改ratingDetail
字段名称,但更改后的字段名称也遇到相同的错误