Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
typesanitizer opened this issue Feb 21, 2020 · 7 comments
Labels
compiler The Swift compiler in itself good first issue Good for newcomers improvement

Comments

@typesanitizer
Copy link

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.

@typesanitizer
Copy link
Author

@swift-ci create

@swift-ci
Copy link
Collaborator

Comment by Daniel Sweeney (JIRA)

I can take a look at this. I have put an hour or so into it so far and it is coming along well.

@typesanitizer
Copy link
Author

Great! Let me know if you need help with something. 🙂

@swift-ci
Copy link
Collaborator

Comment by Daniel Sweeney (JIRA)

I put a basic pull request in at #31360 I would prefer the struct to have const fields and to never allow a nullPtr but there's some remaining analysis to do on that. I don't think I can ask you to review directly and I know I can't fire off CI myself. It passed the regular tests. I'm looking at the validation tests now.

@swift-ci
Copy link
Collaborator

swift-ci commented May 1, 2020

Comment by Daniel Sweeney (JIRA)

Hi theindigamer (JIRA User) what happens to the Jira now that the changes are merged? Should I mark it as resolved? Thanks!

@typesanitizer
Copy link
Author

Good point, I forgot about that heh. Yes, you can it mark it as resolved. 🙂

@swift-ci
Copy link
Collaborator

swift-ci commented May 1, 2020

Comment by Daniel Sweeney (JIRA)

PR merged with help from theindigamer (JIRA User).

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself good first issue Good for newcomers improvement
Projects
None yet
Development

No branches or pull requests

2 participants