Uploaded image for project: 'Swift'
  1. Swift
  2. SR-12247

Replace the type alias `ModuleDecl::ImportedModule` with a dedicated struct

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler
    • Labels:

      Description

      The code using it right now is unnecessarily challenging to read because there are `first` and `second` all over the place and one has no clue what is going on.

      Instead, it would be good to replace it with a dedicated nested struct like so:

      struct ModuleDecl {
      // .. blah
      struct ImportedModule {
        ModuleDecl::AccessPathTy AccessPath;
        ModuleDecl* Module;
      }
      // 
      }
      

      and update the code based on type errors (for example, you might need to update LLDB if it is using this type, or you might need to add 1-2 constructors which make this easy).

      As part of the investigation, one should check if the `Module` is ever null. (The easy way to do this would be to have a constructor which asserts if it receives a nullptr). If so, try replacing the `ModuleDecl *` type with `NullablePtr<ModuleDecl>` and keep that if the resulting code is not too convoluted (it might help to add 1-2 convenience constructors). Otherwise, keep the assertion in and document the invariant in a comment.

      Please @ me on GitHub (varungandhi-apple) or leave a comment here in case you need someone to guide you/review the PR.

        Attachments

          Activity

            People

            Assignee:
            dfsweeney Daniel Sweeney
            Reporter:
            theindigamer Varun Gandhi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: