@@ -117,6 +117,8 @@ import org.jetbrains.kotlin.types.StarProjectionImpl
117117import org.jetbrains.kotlin.types.isNullable
118118import org.jetbrains.kotlin.types.typeUtil.supertypes
119119import kotlin.collections.set
120+ // import org.jetbrains.kotlin.ir.util.isNullable
121+ // import org.jetbrains.kotlin.ir.util.isSubtypeOfClass
120122
121123/* *
122124 * Modifies the IR tree to transform getter/setter to call the C-Interop layer to retrieve read the managed values from the Realm
@@ -822,23 +824,23 @@ class AccessorModifierIrGeneration(private val pluginContext: IrPluginContext) {
822824 ).also {
823825 it.dispatchReceiver = irGetObject(realmObjectHelper.symbol)
824826 }.apply {
825- if (typeArgumentsCount > 0 ) {
826- putTypeArgument( 0 , type)
827+ if (typeArguments.isNotEmpty() ) {
828+ typeArguments[ 0 ] = type
827829 }
828- putValueArgument( 0 , irGet(objectReferenceType, tmp.symbol) )
829- putValueArgument( 1 , irString(property.persistedName) )
830+ arguments[ 0 ] = irGet(objectReferenceType, tmp.symbol)
831+ arguments[ 1 ] = irString(property.persistedName)
830832 }
831833 val storageValue = fromRealmValue?.let {
832834 irCall(callee = it).apply {
833- if (typeArgumentsCount > 0 ) {
834- putTypeArgument( 0 , type)
835+ if (typeArguments.isNotEmpty() ) {
836+ typeArguments[ 0 ] = type
835837 }
836- putValueArgument( 0 , managedObjectGetValueCall)
838+ arguments[ 0 ] = managedObjectGetValueCall
837839 }
838840 } ? : managedObjectGetValueCall
839841 val publicValue = toPublic?.let {
840842 irCall(callee = toPublic).apply {
841- putValueArgument( 0 , storageValue)
843+ arguments[ 0 ] = storageValue
842844 }
843845 } ? : storageValue
844846 + irIfNull(
@@ -892,28 +894,28 @@ class AccessorModifierIrGeneration(private val pluginContext: IrPluginContext) {
892894 )
893895 val storageValue: IrDeclarationReference = fromPublic?.let {
894896 irCall(callee = it).apply {
895- putValueArgument( 0 , irGet(setter.valueParameters. first() ))
897+ arguments[ 0 ] = irGet(parameters. first())
896898 }
897- } ? : irGet(setter.valueParameters .first())
899+ } ? : irGet(parameters .first())
898900 val realmValue: IrDeclarationReference = toRealmValue?.let {
899901 irCall(callee = it).apply {
900- if (typeArgumentsCount > 0 ) {
901- putTypeArgument( 0 , type)
902+ if (typeArguments.isNotEmpty() ) {
903+ typeArguments[ 0 ] = type
902904 }
903- putValueArgument( 0 , storageValue)
905+ arguments[ 0 ] = storageValue
904906 }
905907 } ? : storageValue
906908 val cinteropCall = irCall(
907909 callee = setFunction,
908910 ).also {
909911 it.dispatchReceiver = irGetObject(realmObjectHelper.symbol)
910912 }.apply {
911- if (typeArgumentsCount > 0 ) {
912- putTypeArgument( 0 , type)
913+ if (typeArguments.isNotEmpty() ) {
914+ typeArguments[ 0 ] = type
913915 }
914- putValueArgument( 0 , irGet(objectReferenceType, tmp.symbol) )
915- putValueArgument( 1 , irString(property.persistedName) )
916- putValueArgument( 2 , realmValue)
916+ arguments[ 0 ] = irGet(objectReferenceType, tmp.symbol)
917+ arguments[ 1 ] = irString(property.persistedName)
918+ arguments[ 2 ] = realmValue
917919 }
918920
919921 + irIfNull(
@@ -924,7 +926,7 @@ class AccessorModifierIrGeneration(private val pluginContext: IrPluginContext) {
924926 irSetField(
925927 irGet(receiver),
926928 backingField.symbol.owner,
927- irGet(setter.valueParameters .first()),
929+ irGet(parameters .first()),
928930 ),
929931 // Managed object, return realm value
930932 elsePart = cinteropCall
@@ -1071,24 +1073,28 @@ class AccessorModifierIrGeneration(private val pluginContext: IrPluginContext) {
10711073
10721074 // Otherwise just return the matching core type present in the declaration
10731075 val genericPropertyType: PropertyType ? = getPropertyTypeFromKotlinType(collectionGenericType)
1074- return if (genericPropertyType == null ) {
1075- logError(
1076- " Unsupported type for ${collectionType.description} : '${collectionGenericType.getKotlinTypeFqNameCompat(true )
1077- } '" ,
1078- declaration.locationOf()
1079- )
1080- null
1081- } else if (genericPropertyType == PropertyType .RLM_PROPERTY_TYPE_MIXED && ! collectionGenericType.isNullable()) {
1082- logError(
1083- " Unsupported type for ${collectionType.description} : Only '${collectionType.description} <RealmAny?>' is supported." ,
1084- declaration.locationOf()
1085- )
1086- return null
1087- } else {
1088- CoreType (
1089- propertyType = genericPropertyType,
1090- nullable = collectionGenericType.isNullable()
1091- )
1076+ return when (genericPropertyType) {
1077+ null -> {
1078+ logError(
1079+ " Unsupported type for ${collectionType.description} : '${collectionGenericType.getKotlinTypeFqNameCompat(true )
1080+ } '" ,
1081+ declaration.locationOf()
1082+ )
1083+ null
1084+ }
1085+ PropertyType .RLM_PROPERTY_TYPE_MIXED if ! collectionGenericType.isNullable() -> {
1086+ logError(
1087+ " Unsupported type for ${collectionType.description} : Only '${collectionType.description} <RealmAny?>' is supported." ,
1088+ declaration.locationOf()
1089+ )
1090+ return null
1091+ }
1092+ else -> {
1093+ CoreType (
1094+ propertyType = genericPropertyType,
1095+ nullable = collectionGenericType.isNullable()
1096+ )
1097+ }
10921098 }
10931099 }
10941100
0 commit comments