realm-kotlin icon indicating copy to clipboard operation
realm-kotlin copied to clipboard

Verify that inline classes work as types

Open cmelchior opened this issue 3 years ago • 1 comments

Inline classes are a great way to allow greater type-safety in API's, e.g. something like:

inline class WorkTypeId(val id: Long)
class WorkType() : RealmObject {
    var _id: WorkTypeId = WorkTypeId(0)
}

But this throws an exception during compile time right now:

e: [Realm Compiler Plugin] 2021-11-21T14:17:50.921229Z Primary key _id is of type WorkEntryId but must be of type [Byte, Char, Short, Int, Long, String]

IMO we should allow properties with inline class types that map to supported Realm types.

cmelchior avatar Nov 21 '21 14:11 cmelchior

Is it still valid? I have such case and it works.

tarasmorskyi-mediamonks avatar Jan 14 '22 15:01 tarasmorskyi-mediamonks