-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Wean AbstractFunctionDecl constructors off multiple parameter lists #18128
Conversation
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.
@swift-ci Please test |
@swift-ci Please test source compatibility |
@@ -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); |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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()
?
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 forConstructorDecl
andDestructorDecl
; forFuncDecl
, it is required iff the function is nested inside of a nominal type.