@@ -301,26 +301,31 @@ class AccessorModifierIrGeneration(private val pluginContext: IrPluginContext) {
301301 val typeAdapterMethodReferences = if (declaration.hasAnnotation(TYPE_ADAPTER_ANNOTATION )) {
302302 logDebug(" Object property named ${declaration.name} is an adapted type." )
303303
304- // TODO throw on unsupported types
305-
306304 val adapterClassReference =
307305 declaration.getAnnotation(TYPE_ADAPTER_ANNOTATION .asSingleFqName())
308306 .getValueArgument(0 )!! as IrClassReference
309307 val adapterClass: IrClass = adapterClassReference.classType.getClass()!!
310308
311- // TODO find correct super type adapter type, might be multiple ones
309+ // TODO find correct super type adapter type, might be multiple ones because inheritance
312310 val (realmType: IrTypeArgument , userType) =
313311 (adapterClassReference.symbol.superTypes().first() as IrSimpleType )
314312 .arguments
315313 .let { arguments ->
316314 arguments[0 ] to arguments[1 ]
317315 }
318316
319- // TODO throw proper error on null
320- // replace the property type with the one from the type adapter
321- realmType.typeOrNull!! .let {
322- propertyType = it.makeNotNull()
323- nullable = it.isNullable()
317+ // Replace the property type with the one from the type adapter
318+ realmType.typeOrNull.let {
319+ if (it != null ) {
320+ propertyType = it.makeNotNull()
321+ if (propertyType.isChar() || propertyType.isByte() || propertyType.isShort() || propertyType.isInt() || propertyType.isMutableRealmInteger()) {
322+ // TODO improve messaging
323+ logError(" Unsupported Realm storage type. Use `Long` instead" , declaration.locationOf())
324+ }
325+ nullable = it.isNullable()
326+ } else {
327+ logError(" Could not retrieve the storage type." )
328+ }
324329 }
325330
326331 when (adapterClass.kind) {
0 commit comments