[SR-12315] Extension of nested type does not have access to types it is nested in #54745
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
type checker
Area → compiler: Semantic analysis
Environment
Apple Swift version 5.2 (swiftlang-1103.0.22 clang-1103.0.22)
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
Additional Detail from JIRA
md5: 9705f88c3c600bbce103a2deadb3c46c
duplicates:
Issue Description:
Wording in title perhaps a bit confusing, so here's an example which I'd expect to work:
This works fine, I'm in Top.Middle.Hi and can use Middle however I want:
Since the triple nesting gets pretty annoying, I refactor my code into an extension, like so:
which does not work, as suddenly I can't use Middle.
My current workaround is to define typealiases in the extension so the refactored code can use the short names... I would love to not have to do this. Visibility rules should not really change depending on if I declare the functions in the actual struct or in an extension IMO.
For context: we use nesting a lot for the sake of namespacing, so Top is more like "Namespace" so basically all code of larger modules already starts at one indentation level, then various types need to be in Middle and then have actual implementation specific types inside... This means this nesting pattern is quite common (or we end up polluting library user namespace with "popular names" which we'd like to avoid)
The text was updated successfully, but these errors were encountered: