Extension nested struct compile error

===== Module.swift =====
struct Module {
}

===== Numbers.swift =====
extension Module {
    class Numbers {
        static var aConstantDouble: Double { return 0.54 }
    }
}
extension Module.Numbers { // No issue
    static var anotherDouble: Double { return 0.646 } 
}

===== SomeViewController.swift =====
extension Module.Numbers { // Compilation error: 'Numbers' is not a member type of 'Module'
    static var someViewControllerDouble: Double { return 0.989 }
}

I'm using namespace extension method to create some constants. However I'm facing some issue when I'm trying to extend the class in nested struct. I'm not sure what I'd missed out, any idea?

This is the bug SR-631, fixed for Swift 5.

1 Like

Thanks bro.

Terms of Service

Privacy Policy

Cookie Policy