Skip to content

Wean AbstractFunctionDecl constructors off multiple parameter lists #18128

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

Conversation

slavapestov
Copy link
Contributor

This is a follow-up to #18082 and #18102. Now that most usages of getParameterLists(), getNumParameterLists(), etc are gone, the next step is to change how function declarations are constructed. Instead of taking an array of parameter lists, they now take a self declaration and single parameter list. The self declaration is required for ConstructorDecl and DestructorDecl; for FuncDecl, it is required iff the function is nested inside of a nominal type.

There was some dead code that's no longer needed.
…meter lists

There are two general constructor forms here:

- One took the number of parameter lists, to be filled in later.
  Now, this takes a boolean indicating if there is an implicit
  'self'.

- The other one took the actual parameter lists and filled them
  in right away. This now takes a separate 'self' ParamDecl and
  ParameterList.

Instead of storing the number of parameter lists, an
AbstractFunctionDecl now only needs to store if there is a 'self'
or not.

I've updated most places that construct AbstractFunctionDecls to
properly use these new forms. In the ClangImporter, there is
more code that remains to be untangled, so we continue to build
multiple ParameterLists and unpack them into a ParamDecl and
ParameterList at the last minute.
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov merged commit 19104c0 into swiftlang:master Jul 21, 2018
@@ -490,7 +490,7 @@ static void handleSILDeclRef(Serializer &S, const SILDeclRef &Ref,
SmallVectorImpl<ValueID> &ListOfValues) {
ListOfValues.push_back(S.addDeclRef(Ref.getDecl()));
ListOfValues.push_back((unsigned)Ref.kind);
ListOfValues.push_back(Ref.getParameterListCount() - 1);
ListOfValues.push_back(Ref.isCurried);
Copy link
Contributor

@jrose-apple jrose-apple Jul 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a format change; please bump the module version. Doing it in a separate commit confused me. You're good.

@@ -5341,19 +5340,18 @@ class FuncDecl : public AbstractFunctionDecl {
SourceLoc FuncLoc,
DeclName Name, SourceLoc NameLoc,
bool Throws, SourceLoc ThrowsLoc,
unsigned NumParameterLists,
bool HasImplicitSelfDecl,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this boolean ever distinct from Parent->isTypeContext()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants