krzyzanowskim / Natalie

Natalie - Storyboard Code Generator (for Swift)
http://blog.krzyzanowskim.com/2015/04/15/natalie-storyboard-code-generator/
MIT License
1.17k stars 74 forks source link

Issue with inheritance #78

Closed delannoyk closed 7 years ago

delannoyk commented 8 years ago

Hi,

I recently faced an issue with Natalie. Given the following architecture:

class A: UIViewController {}
class B: A {}

with both A and B identifiable view controllers in my Storyboard.

Natalie generates this code that doesn't compile:


//MARK: - AViewController
extension AViewController: IdentifiableProtocol { 
    var storyboardIdentifier: String? { return "AViewController" }
    static var storyboardIdentifier: String? { return "AViewController" }
}

//MARK: - BViewController
extension BViewController: IdentifiableProtocol { 
    var storyboardIdentifier: String? { return "BViewController" }
    static var storyboardIdentifier: String? { return "BViewController" }
}

and generates the following errors:

./Storyboards.swift:248:9: error: overriding declaration requires an 'override' keyword
    var storyboardIdentifier: String? { return "BViewController" }
        ^
./Storyboards.swift:241:9: note: overridden declaration is here
    var storyboardIdentifier: String? { return "AViewController" }
        ^
./Storyboards.swift:249:16: error: overriding declaration requires an 'override' keyword
    static var storyboardIdentifier: String? { return "BViewController" }
               ^
./Storyboards.swift:242:16: note: overridden declaration is here
    static var storyboardIdentifier: String? { return "AViewController" }
               ^
./Storyboards.swift:249:16: error: class var overrides a 'final' class var
    static var storyboardIdentifier: String? { return "BViewController" }
               ^
./Storyboards.swift:242:16: note: overridden declaration is here
    static var storyboardIdentifier: String? { return "AViewController" }
               ^
./Storyboards.swift:247:28: error: redundant conformance of 'BViewController' to protocol 'IdentifiableProtocol'
extension BViewController: IdentifiableProtocol { 
                           ^
./BViewController.swift:11:7: note: 'BViewController' inherits conformance to protocol 'IdentifiableProtocol' from superclass here
class BViewController: AViewController {
      ^

Here is a sample project reproducing the issue: https://github.com/delannoyk/NatalieInheritanceIssue

krzyzanowskim commented 8 years ago

related https://github.com/krzyzanowskim/Natalie/issues/10