pp.amorim
03/12/2024, 4:42 PMmapToDomain
is resolved and the project compiles. Could you please help with that?pp.amorim
03/12/2024, 4:43 PM@Parcelize
and @Serializable
, but I don’t think it has influence on thatJoffrey
03/12/2024, 4:44 PMapiFoo
as the extension receiver, but you also need an instance of DomainMapper<ApiFoo, *>
as a dispatch receiver. See:
https://kotlinlang.org/docs/extensions.html#declaring-extensions-as-membersJoffrey
03/12/2024, 4:44 PMApiFooMapper
in the context by wrapping the call in `with(ApiFooMapper) { ... }`:
val foo = with(ApiFooMapper) { apiFoo.mapToDomain() }
https://pl.kotl.in/-hYk5CWPcJoffrey
03/12/2024, 4:47 PMI have the very same solution in our Android project from another developer and it’s workingProbably they call this function in a context where a
DomainMapper
is available as this
(for instance within an extension function on DomainMapper
or within an implementation of DomainMapper
)pp.amorim
03/12/2024, 4:48 PMmapToDomain
is being imported directly as import …mappers.ApiFooMapper.mapToDomain
, so is it applying the with(ApiFooMapper)
automatically?pp.amorim
03/12/2024, 4:49 PMJoffrey
03/12/2024, 4:49 PMDomainMapper
must be available as this
in the place where it's called. If it's possible for you to post your code here, we can probably help and show you where it is.ApiFooMapper
is an object
in your code, then the import …mappers.ApiFooMapper.mapToDomain
might actually be the reason why it works. It imports the method and its containing object implicitly