mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
AST: Give destructors a second parameter list
Constructors and methods had two parameter lists, one for self and one for the formal parameters. Destructors only had one parameter list, which introduced an annoying corner case.
This commit is contained in:
@@ -5379,16 +5379,17 @@ DestructorDecl::DestructorDecl(SourceLoc DestructorLoc, ParamDecl *selfDecl,
|
||||
: AbstractFunctionDecl(DeclKind::Destructor, Parent,
|
||||
DeclBaseName::createDestructor(), DestructorLoc,
|
||||
/*Throws=*/false, /*ThrowsLoc=*/SourceLoc(),
|
||||
/*NumParameterLists=*/1, nullptr) {
|
||||
/*NumParameterLists=*/2, nullptr) {
|
||||
setSelfDecl(selfDecl);
|
||||
ParameterLists[1] = ParameterList::createEmpty(Parent->getASTContext());
|
||||
}
|
||||
|
||||
void DestructorDecl::setSelfDecl(ParamDecl *selfDecl) {
|
||||
if (selfDecl) {
|
||||
SelfParameter = ParameterList::createWithoutLoc(selfDecl);
|
||||
SelfParameter->setDeclContextOfParamDecls(this);
|
||||
ParameterLists[0] = ParameterList::createWithoutLoc(selfDecl);
|
||||
ParameterLists[0]->setDeclContextOfParamDecls(this);
|
||||
} else {
|
||||
SelfParameter = nullptr;
|
||||
ParameterLists[0] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user