toadzky
04/03/2024, 9:03 PMvalue class not working as expected. it seems like i'm doing stuff the way the docs say should work, but it's not actually working. (details in thread)toadzky
04/03/2024, 9:04 PMtoadzky
04/03/2024, 9:04 PMtoadzky
04/03/2024, 9:05 PMUnresolved reference. None of the following candidates is applicable because of receiver type mismatchtoadzky
04/03/2024, 9:05 PMChris Fillmore
04/03/2024, 9:11 PMtoadzky
04/03/2024, 9:14 PMtoadzky
04/03/2024, 9:16 PMChris Fillmore
04/03/2024, 9:29 PMtoadzky
04/03/2024, 9:33 PMsindrenm
04/03/2024, 9:33 PMtoadzky
04/03/2024, 9:35 PMinline aspect kind of makes it feel like it should just auto-become whatever it's wrapping under the hood, but i get why it doesn't - both from technical and philosophical perspectivesagrosner
04/04/2024, 12:13 AMsindrenm
04/04/2024, 7:26 AMtypealias will essentially be that, but that would remove the type safety aspect from it:
typealias UserId = String
typealias ItemId = String
fun getUser(id: UserId) {}
fun getItem(id: ItemId) {}
fun main() {
val itemId: ItemId = "foo"
getUser(itemId) // this would still compile
}
@JvmInline value class UserId(val value: String)
@JvmInline value class ItemId(val value: String)
fun getUser(id: UserId) {}
fun getItem(id: ItemId) {}
fun main() {
val itemId: ItemId = "foo"
getUser(itemId) // this would not compile
}toadzky
04/04/2024, 1:56 PMtoadzky
04/04/2024, 3:33 PMtoadzky
04/04/2024, 3:34 PMtoadzky
04/04/2024, 3:43 PMtoadzky
04/04/2024, 3:44 PMtoadzky
04/04/2024, 3:54 PMtoadzky
04/04/2024, 3:55 PM