mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #27571 from slavapestov/circular-validation-cleanups-5
Circular validation cleanups, part 5
This commit is contained in:
@@ -1352,14 +1352,15 @@ ParamDecl *PatternBindingInitializer::getImplicitSelfDecl() {
|
||||
auto DC = singleVar->getDeclContext();
|
||||
if (DC->isTypeContext()) {
|
||||
auto specifier = (DC->getDeclaredInterfaceType()->hasReferenceSemantics()
|
||||
? ParamDecl::Specifier::Default
|
||||
: ParamDecl::Specifier::InOut);
|
||||
? ParamSpecifier::Default
|
||||
: ParamSpecifier::InOut);
|
||||
|
||||
ASTContext &C = DC->getASTContext();
|
||||
SelfParam = new (C) ParamDecl(specifier, SourceLoc(), SourceLoc(),
|
||||
SelfParam = new (C) ParamDecl(SourceLoc(), SourceLoc(),
|
||||
Identifier(), singleVar->getLoc(),
|
||||
C.Id_self, this);
|
||||
SelfParam->setImplicit();
|
||||
SelfParam->setSpecifier(specifier);
|
||||
SelfParam->setInterfaceType(DC->getSelfInterfaceType());
|
||||
}
|
||||
}
|
||||
@@ -5455,15 +5456,11 @@ bool VarDecl::isMemberwiseInitialized(bool preferDeclaredProperties) const {
|
||||
void ParamDecl::setSpecifier(Specifier specifier) {
|
||||
// FIXME: Revisit this; in particular shouldn't __owned parameters be
|
||||
// ::Let also?
|
||||
setIntroducer(specifier == ParamDecl::Specifier::Default
|
||||
setIntroducer(specifier == ParamSpecifier::Default
|
||||
? VarDecl::Introducer::Let
|
||||
: VarDecl::Introducer::Var);
|
||||
Bits.ParamDecl.Specifier = static_cast<unsigned>(specifier);
|
||||
setImplInfo(
|
||||
StorageImplInfo::getSimpleStored(
|
||||
isImmutableSpecifier(specifier)
|
||||
? StorageIsNotMutable
|
||||
: StorageIsMutable));
|
||||
Bits.ParamDecl.SpecifierComputed = true;
|
||||
}
|
||||
|
||||
bool ParamDecl::isAnonClosureParam() const {
|
||||
@@ -5478,6 +5475,15 @@ bool ParamDecl::isAnonClosureParam() const {
|
||||
return nameStr[0] == '$';
|
||||
}
|
||||
|
||||
ParamDecl::Specifier ParamDecl::getSpecifier() const {
|
||||
auto &ctx = getASTContext();
|
||||
|
||||
auto mutableThis = const_cast<ParamDecl *>(this);
|
||||
return evaluateOrDefault(ctx.evaluator,
|
||||
ParamSpecifierRequest{mutableThis},
|
||||
ParamDecl::Specifier::Default);
|
||||
}
|
||||
|
||||
StaticSpellingKind AbstractStorageDecl::getCorrectStaticSpelling() const {
|
||||
if (!isStatic())
|
||||
return StaticSpellingKind::None;
|
||||
@@ -5708,21 +5714,18 @@ void VarDecl::emitLetToVarNoteIfSimple(DeclContext *UseDC) const {
|
||||
}
|
||||
}
|
||||
|
||||
ParamDecl::ParamDecl(Specifier specifier, SourceLoc specifierLoc,
|
||||
ParamDecl::ParamDecl(SourceLoc specifierLoc,
|
||||
SourceLoc argumentNameLoc, Identifier argumentName,
|
||||
SourceLoc parameterNameLoc, Identifier parameterName,
|
||||
DeclContext *dc)
|
||||
: VarDecl(DeclKind::Param,
|
||||
/*IsStatic*/ false,
|
||||
specifier == ParamDecl::Specifier::Default
|
||||
? VarDecl::Introducer::Let
|
||||
: VarDecl::Introducer::Var,
|
||||
VarDecl::Introducer::Let,
|
||||
/*IsCaptureList*/ false, parameterNameLoc, parameterName, dc,
|
||||
StorageIsMutable_t(!isImmutableSpecifier(specifier))),
|
||||
StorageIsNotMutable),
|
||||
ArgumentName(argumentName), ParameterNameLoc(parameterNameLoc),
|
||||
ArgumentNameLoc(argumentNameLoc), SpecifierLoc(specifierLoc) {
|
||||
|
||||
Bits.ParamDecl.Specifier = static_cast<unsigned>(specifier);
|
||||
Bits.ParamDecl.SpecifierComputed = false;
|
||||
Bits.ParamDecl.IsTypeLocImplicit = false;
|
||||
Bits.ParamDecl.defaultArgumentKind =
|
||||
static_cast<unsigned>(DefaultArgumentKind::None);
|
||||
@@ -5739,7 +5742,6 @@ ParamDecl::ParamDecl(ParamDecl *PD, bool withTypes)
|
||||
ArgumentNameLoc(PD->getArgumentNameLoc()),
|
||||
SpecifierLoc(PD->getSpecifierLoc()),
|
||||
DefaultValueAndFlags(nullptr, PD->DefaultValueAndFlags.getInt()) {
|
||||
Bits.ParamDecl.Specifier = static_cast<unsigned>(PD->getSpecifier());
|
||||
Bits.ParamDecl.IsTypeLocImplicit = PD->Bits.ParamDecl.IsTypeLocImplicit;
|
||||
Bits.ParamDecl.defaultArgumentKind = PD->Bits.ParamDecl.defaultArgumentKind;
|
||||
typeLoc = PD->getTypeLoc().clone(PD->getASTContext());
|
||||
@@ -5749,6 +5751,7 @@ ParamDecl::ParamDecl(ParamDecl *PD, bool withTypes)
|
||||
if (withTypes && PD->hasInterfaceType())
|
||||
setInterfaceType(PD->getInterfaceType());
|
||||
|
||||
setSpecifier(PD->getSpecifier());
|
||||
setImplicitlyUnwrappedOptional(PD->isImplicitlyUnwrappedOptional());
|
||||
}
|
||||
|
||||
@@ -6547,41 +6550,13 @@ ParamDecl *AbstractFunctionDecl::getImplicitSelfDecl(bool createIfNeeded) {
|
||||
|
||||
// Create and save our 'self' parameter.
|
||||
auto &ctx = getASTContext();
|
||||
*selfDecl = new (ctx) ParamDecl(ParamDecl::Specifier::Default,
|
||||
SourceLoc(), SourceLoc(), Identifier(),
|
||||
*selfDecl = new (ctx) ParamDecl(SourceLoc(), SourceLoc(), Identifier(),
|
||||
getLoc(), ctx.Id_self, this);
|
||||
(*selfDecl)->setImplicit();
|
||||
|
||||
// If we already have an interface type, compute the 'self' parameter type.
|
||||
// Otherwise, we'll do it later.
|
||||
if (hasInterfaceType())
|
||||
computeSelfDeclType();
|
||||
|
||||
return *selfDecl;
|
||||
}
|
||||
|
||||
void AbstractFunctionDecl::computeSelfDeclType() {
|
||||
assert(hasImplicitSelfDecl());
|
||||
assert(hasInterfaceType());
|
||||
|
||||
auto *selfDecl = getImplicitSelfDecl(/*createIfNeeded=*/false);
|
||||
|
||||
// If we haven't created a 'self' parameter yet, do nothing, we'll compute
|
||||
// the type later.
|
||||
if (selfDecl == nullptr)
|
||||
return;
|
||||
|
||||
auto selfParam = computeSelfParam(this,
|
||||
/*isInitializingCtor*/true,
|
||||
/*wantDynamicSelf*/true);
|
||||
selfDecl->setInterfaceType(selfParam.getPlainType());
|
||||
|
||||
auto specifier = selfParam.getParameterFlags().isInOut()
|
||||
? ParamDecl::Specifier::InOut
|
||||
: ParamDecl::Specifier::Default;
|
||||
selfDecl->setSpecifier(specifier);
|
||||
}
|
||||
|
||||
void AbstractFunctionDecl::setParameters(ParameterList *BodyParams) {
|
||||
#ifndef NDEBUG
|
||||
auto Name = getFullName();
|
||||
@@ -6703,14 +6678,6 @@ void AbstractFunctionDecl::computeType(AnyFunctionType::ExtInfo info) {
|
||||
|
||||
// Record the interface type.
|
||||
setInterfaceType(funcTy);
|
||||
|
||||
// Compute the type of the 'self' parameter if we're created one already.
|
||||
if (hasSelf)
|
||||
computeSelfDeclType();
|
||||
|
||||
// Make sure that there are no unresolved dependent types in the
|
||||
// generic signature.
|
||||
assert(!funcTy->findUnresolvedDependentMemberType());
|
||||
}
|
||||
|
||||
bool AbstractFunctionDecl::hasInlinableBodyText() const {
|
||||
|
||||
Reference in New Issue
Block a user