https://kotlinlang.org logo
Title
s

Sam

03/28/2018, 1:45 PM
I have some Kotlin code that is not generating a valid Objective C header file. It seems to be a problem with the way the functions are translated to blocks.
//Kotlin class taking an array of functions
class Store (private val repositories: Map<String, Repository<*>>,
             private val middleware: List<Middleware> = emptyList()){

//The function definitions
typealias DispatchFunction = (cmd: Command) -> Unit
typealias Middleware = (dispatch: DispatchFunction, repositories: Map<String, Repository<*>>) -> (DispatchFunction) -> DispatchFunction

//The ObjC header file that is generated
-(instancetype)initWithRepositories:(NSDictionary<NSString*, id<PistachioRepository>>*)repositories middleware:(NSArray<PistachioStdlibUnit*(^)(id<PistachioCommand>)(^)(PistachioStdlibUnit*(^)(id<PistachioCommand>))(^)(PistachioStdlibUnit*(^)(id<PistachioCommand>), NSDictionary<NSString*, id<PistachioRepository>>*)>*)middleware NS_SWIFT_NAME(init(repositories:middleware:)) NS_DESIGNATED_INITIALIZER;
The error message is
Pistachio.h:86:168: Block pointer to non-function type is invalid
. Admittedly this is not a pretty function header and I'll probably refactor it since it seems to be a little too functional for ObjC. The code with the issue can be found at https://github.com/samus/pistachio/commit/4537d11648563596db6be22a53bb72a38a6be9ee
s

svyatoslav.scherbina

03/28/2018, 4:30 PM
Thank you for the report. We have found the root cause of the issue, it will be fixed in a few days.
👍 1
The issue is fixed in 0.7-dev-1447.