AST: Banish OptionalTypeKind to ClangImporter.h

The only place this was used in Decl.h was the failability kind of a
constructor.

I decided to replace this with a boolean isFailable() bit. Now that
we have isImplicitlyUnwrappedOptional(), it seems to make more sense
to not have ConstructorDecl represent redundant information which
might not be internally consistent.

Most callers of getFailability() actually only care if the result is
failable or not; the few callers that care about it being IUO can
check isImplicitlyUnwrappedOptional() as well.
This commit is contained in:
Slava Pestov
2019-08-15 17:07:42 -04:00
parent 19d283d9dc
commit 1c3ac86796
30 changed files with 125 additions and 189 deletions

View File

@@ -254,7 +254,7 @@ static ConstructorDecl *createImplicitConstructor(NominalTypeDecl *decl,
DeclName name(ctx, DeclBaseName::createConstructor(), paramList);
auto *ctor =
new (ctx) ConstructorDecl(name, Loc,
OTK_None, /*FailabilityLoc=*/SourceLoc(),
/*Failable=*/false, /*FailabilityLoc=*/SourceLoc(),
/*Throws=*/false, /*ThrowsLoc=*/SourceLoc(),
paramList, /*GenericParams=*/nullptr, decl);
@@ -676,7 +676,7 @@ createDesignatedInitOverride(ClassDecl *classDecl,
auto ctor =
new (ctx) ConstructorDecl(superclassCtor->getFullName(),
classDecl->getBraces().Start,
superclassCtor->getFailability(),
superclassCtor->isFailable(),
/*FailabilityLoc=*/SourceLoc(),
/*Throws=*/superclassCtor->hasThrows(),
/*ThrowsLoc=*/SourceLoc(),
@@ -689,7 +689,7 @@ createDesignatedInitOverride(ClassDecl *classDecl,
ctor->computeType();
ctor->setImplicitlyUnwrappedOptional(
ctor->getFailability() == OTK_ImplicitlyUnwrappedOptional);
superclassCtor->isImplicitlyUnwrappedOptional());
ctor->setValidationToChecked();