Make addImplicitConstructors a static method

This commit is contained in:
Hamish Knight
2019-10-21 17:36:46 -07:00
parent 783787627a
commit 8adf3400d4
3 changed files with 9 additions and 7 deletions

View File

@@ -833,7 +833,7 @@ static bool areAllStoredPropertiesDefaultInitializable(NominalTypeDecl *decl) {
return true;
}
static void addImplicitConstructorsToStruct(StructDecl *decl, ASTContext &ctx) {
static void addImplicitConstructorsToStruct(StructDecl *decl) {
assert(!decl->hasClangNode() &&
"ClangImporter is responsible for adding implicit constructors");
assert(!decl->hasUnreferenceableStorage() &&
@@ -884,6 +884,7 @@ static void addImplicitConstructorsToStruct(StructDecl *decl, ASTContext &ctx) {
if (FoundMemberwiseInitializedProperty) {
// Create the implicit memberwise constructor.
auto &ctx = decl->getASTContext();
auto ctor = createImplicitConstructor(
decl, ImplicitConstructorKind::Memberwise, ctx);
decl->addMember(ctor);
@@ -893,7 +894,7 @@ static void addImplicitConstructorsToStruct(StructDecl *decl, ASTContext &ctx) {
TypeChecker::defineDefaultConstructor(decl);
}
static void addImplicitConstructorsToClass(ClassDecl *decl, ASTContext &ctx) {
static void addImplicitConstructorsToClass(ClassDecl *decl) {
// Bail out if we're validating one of our constructors already;
// we'll revisit the issue later.
if (!decl->hasClangNode()) {
@@ -911,6 +912,7 @@ static void addImplicitConstructorsToClass(ClassDecl *decl, ASTContext &ctx) {
// variable.
bool FoundDesignatedInit = false;
auto &ctx = decl->getASTContext();
SmallVector<std::pair<ValueDecl *, Type>, 4> declaredInitializers;
llvm::SmallPtrSet<ConstructorDecl *, 4> overriddenInits;
if (decl->hasClangNode()) {
@@ -1104,9 +1106,9 @@ void TypeChecker::addImplicitConstructors(NominalTypeDecl *decl) {
}
if (auto *structDecl = dyn_cast<StructDecl>(decl))
addImplicitConstructorsToStruct(structDecl, Context);
addImplicitConstructorsToStruct(structDecl);
if (auto *classDecl = dyn_cast<ClassDecl>(decl))
addImplicitConstructorsToClass(classDecl, Context);
addImplicitConstructorsToClass(classDecl);
}
void TypeChecker::synthesizeMemberForLookup(NominalTypeDecl *target,