Skip to content

[SR-12247] Replace the type alias ModuleDecl::ImportedModule with a dedicated struct #54674

@typesanitizer

Description

@typesanitizer
Previous ID SR-12247
Radar rdar://problem/59652913
Original Reporter @typesanitizer
Type Improvement
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, StarterBug
Assignee dfsweeney (JIRA)
Priority Medium

md5: e0ba93c630c00648118ca45d93bdb575

Issue 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions