MrNiamh
11/20/2025, 3:47 PMa compile fine, but b is a compilation error? I wouldn't expect a to compile but it does, but i'm also surprised it's not consistent between the two.
data class ContactId(val value: UUID)
fun main(){
val contactId = ContactId(UUID.randomUUID())
val uuid = UUID.randomUUID()
val a = contactId == uuid
val b = contactId.toString() == uuid
}Youssef Shoaib [MOD]
11/20/2025, 3:50 PMequals is a thing, and it can do crazy stuff. Kotlin thus only warns if it knows that the equality absolutely can't happenMrNiamh
11/20/2025, 3:52 PMKlitos Kyriacou
11/21/2025, 10:00 AM@JvmInline
value class ContactId(val value: UUID)
which makes a a compilation failure as you wanted it to be. However, there may be some issues with some JSON libraries that don't recognise inline classes.