@@ -301,26 +301,31 @@ class AccessorModifierIrGeneration(private val pluginContext: IrPluginContext) {
301
301
val typeAdapterMethodReferences = if (declaration.hasAnnotation(TYPE_ADAPTER_ANNOTATION )) {
302
302
logDebug(" Object property named ${declaration.name} is an adapted type." )
303
303
304
- // TODO throw on unsupported types
305
-
306
304
val adapterClassReference =
307
305
declaration.getAnnotation(TYPE_ADAPTER_ANNOTATION .asSingleFqName())
308
306
.getValueArgument(0 )!! as IrClassReference
309
307
val adapterClass: IrClass = adapterClassReference.classType.getClass()!!
310
308
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
312
310
val (realmType: IrTypeArgument , userType) =
313
311
(adapterClassReference.symbol.superTypes().first() as IrSimpleType )
314
312
.arguments
315
313
.let { arguments ->
316
314
arguments[0 ] to arguments[1 ]
317
315
}
318
316
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
+ }
324
329
}
325
330
326
331
when (adapterClass.kind) {
0 commit comments