CoreValue icon indicating copy to clipboard operation
CoreValue copied to clipboard

Cannot invoke 'curry' with an argument list of type '((objectID: NSManagedObjectID?, name: String, employees: Array<StoredEmployee>) -> StoredCompany)

Open emarashliev opened this issue 8 years ago • 4 comments

We have next two separated files:

//  StoredCompany.swift

import CoreData
import CoreValue


struct StoredCompany: CVManagedPersistentStruct {
    static let EntityName = "Company"
    var objectID: NSManagedObjectID?

    var name: String
    var employees: Array<StoredEmployee>

    static func fromObject(o: NSManagedObject) throws -> StoredCompany {
        return try curry(self.init)
            <^> o <|? "objectID"
            <^> o <| "name"
            <^> o <|| "employees"
    }

    mutating func save(context: NSManagedObjectContext) throws {
        try employees.saveAll(context)

        try defaultSave(context)
    }
//  StoredEmployee.swift

import CoreData
import CoreValue


struct StoredEmployee : CVManagedPersistentStruct {
    static let EntityName = "Employee"
    var objectID: NSManagedObjectID?

    let name: String
    let age: Int16
    let position: String?
    let department: String
    let job: String

    static func fromObject(o: NSManagedObject) throws -> StoredEmployee {
        return try curry(self.init)
            <^> o <|? "objectID"
            <^> o <| "name"
            <^> o <| "age"
            <^> o <|? "position"
            <^> o <| "department"
            <^> o <| "job"
    }
}

The compiler throws next error .../StoredCompany.swift:21:20: Cannot invoke 'curry' with an argument list of type '((objectID: NSManagedObjectID?, name: String, employees: Array<StoredEmployee>) -> StoredCompany)'

It's happens only when struct StoredEmployee and struct StoredCompany are in separated files. Probably that's the reason that the tests doesn't catch it.

Cheers! 🍻

emarashliev avatar Jul 20 '16 14:07 emarashliev

Does your project have multiple targets? Is it possible that you did not add both files to all appropriate targets when you separated them?

brow avatar Aug 18 '16 02:08 brow

Does this still happen? If yes, can you try with the current Swift 3 release (CoreValue 0.2)?

terhechte avatar Oct 17 '16 10:10 terhechte

Though not sure why it was happening, adding:

typealias StructureType = StoredEmployee

usually solved the problem for me.

tkohout avatar Oct 24 '16 20:10 tkohout

I bumped into the same issue. this solved it too:

typealias StructureType = MyStructureType

btw, is this project alive?

leandromperez avatar Feb 02 '17 19:02 leandromperez