Ambiguous type name 'Segue' #90

Open
moray95 opened this Issue Nov 21, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@moray95

moray95 commented Nov 21, 2016

Hello,

I have just integrated Natalie with my project using the build script given in the README.
When trying to compile the generated Storyboards.swift, I am having the error Ambiguous type name 'Segue'.

The issue is caused on a custom view controller inheriting from another custom view controller, therefore, on the child view controller, the type Segue can refer to neither it's own type or it's parent's type.

The generated code looks like the following:

extension X { 

    enum Segue: String, CustomStringConvertible, SegueProtocol {
        case viewDetail = "viewDetail"

        var kind: SegueKind? {
            switch (self) {
            case .viewDetail:
                return SegueKind(rawValue: "show")
            }
        }

        var destination: UIViewController.Type? {
            switch (self) {
            default:
                assertionFailure("Unknown destination")
                return nil
            }
        }

        var identifier: String? { return self.description } 
        var description: String { return self.rawValue }
    }

}

extension UIStoryboardSegue {
    func selection() -> Y.Segue? {  // <-- Error on this line
        if let identifier = self.identifier {
            return DeliveryOrderHistoryViewController.Segue(rawValue: identifier)
        }
        return nil
    }
}

extension Y { 

    enum Segue: String, CustomStringConvertible, SegueProtocol {
        case viewDetail = "viewDetail"

        var kind: SegueKind? {
            switch (self) {
            case .viewDetail:
                return SegueKind(rawValue: "show")
            }
        }

        var destination: UIViewController.Type? {
            switch (self) {
            default:
                assertionFailure("Unknown destination")
                return nil
            }
        }

        var identifier: String? { return self.description } 
        var description: String { return self.rawValue }
    }

}

On the code above, Y inherits from X, which in turn inherits from UIViewController.

Do you have any recommendations on how to fix the issue?

@krzyzanowskim

This comment has been minimized.

Show comment
Hide comment
@krzyzanowskim

krzyzanowskim Nov 21, 2016

Owner

I don't have fix for that yet, you can work on it if you want. I'm happy to merge the fix.
For now, closing as duplicate of #78

Owner

krzyzanowskim commented Nov 21, 2016

I don't have fix for that yet, you can work on it if you want. I'm happy to merge the fix.
For now, closing as duplicate of #78

@krzyzanowskim

This comment has been minimized.

Show comment
Hide comment
@krzyzanowskim

krzyzanowskim Dec 18, 2016

Owner

I was wrong; that's not the same issue. The other issue is resolved while this one is in progress now, looks like Swift issue/limitation for now.

Owner

krzyzanowskim commented Dec 18, 2016

I was wrong; that's not the same issue. The other issue is resolved while this one is in progress now, looks like Swift issue/limitation for now.

@krzyzanowskim

This comment has been minimized.

Show comment
Hide comment
@krzyzanowskim

krzyzanowskim Dec 26, 2016

Owner

@moray95 do you have, sample storyboard file/project to reproduce the exact issue?

Owner

krzyzanowskim commented Dec 26, 2016

@moray95 do you have, sample storyboard file/project to reproduce the exact issue?

@moray95

This comment has been minimized.

Show comment
Hide comment
@moray95

moray95 Dec 26, 2016

Hey @krzyzanowskim, thanks for the heads up. You can find a simple project that reproduces the issue here: https://github.com/moray95/natalie-bug. I'd just like to you to note that I wasn't able to integrate properly natalie with Xcode (the run script generates an empty file) but run it from the command line.

moray95 commented Dec 26, 2016

Hey @krzyzanowskim, thanks for the heads up. You can find a simple project that reproduces the issue here: https://github.com/moray95/natalie-bug. I'd just like to you to note that I wasn't able to integrate properly natalie with Xcode (the run script generates an empty file) but run it from the command line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment