Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
emarashliev opened this issue Jul 20, 2016 · 4 comments

Comments

@emarashliev
Copy link

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! 🍻

@brow
Copy link

brow commented Aug 18, 2016

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

@terhechte
Copy link
Owner

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

@tkohout
Copy link
Contributor

tkohout commented Oct 24, 2016

Though not sure why it was happening, adding:

typealias StructureType = StoredEmployee

usually solved the problem for me.

@leandromperez
Copy link
Contributor

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

typealias StructureType = MyStructureType

btw, is this project alive?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants