Skip to content

Commit 281d80c

Browse files
committed
Delete InitRetType from ConstructorDecl
This was used only by dependsOn on initializer results.
1 parent fc2547c commit 281d80c

File tree

11 files changed

+40
-79
lines changed

11 files changed

+40
-79
lines changed

include/swift/AST/Decl.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8689,18 +8689,12 @@ class ConstructorDecl : public AbstractFunctionDecl {
86898689
/// inserted at the end of the initializer by SILGen.
86908690
Expr *CallToSuperInit = nullptr;
86918691

8692-
/// Valid when lifetime dependence specifiers are present.
8693-
TypeLoc InitRetType;
8694-
86958692
public:
8696-
ConstructorDecl(DeclName Name, SourceLoc ConstructorLoc,
8697-
bool Failable, SourceLoc FailabilityLoc,
8698-
bool Async, SourceLoc AsyncLoc,
8699-
bool Throws, SourceLoc ThrowsLoc,
8700-
TypeLoc thrownTy,
8701-
ParameterList *BodyParams,
8702-
GenericParamList *GenericParams,
8703-
DeclContext *Parent, TypeRepr *InitRetTy);
8693+
ConstructorDecl(DeclName Name, SourceLoc ConstructorLoc, bool Failable,
8694+
SourceLoc FailabilityLoc, bool Async, SourceLoc AsyncLoc,
8695+
bool Throws, SourceLoc ThrowsLoc, TypeLoc thrownTy,
8696+
ParameterList *BodyParams, GenericParamList *GenericParams,
8697+
DeclContext *Parent);
87048698

87058699
static ConstructorDecl *
87068700
createImported(ASTContext &ctx, ClangNode clangNode, DeclName name,
@@ -8722,8 +8716,6 @@ class ConstructorDecl : public AbstractFunctionDecl {
87228716
/// Get the interface type of the initializing constructor.
87238717
Type getInitializerInterfaceType();
87248718

8725-
TypeRepr *getResultTypeRepr() const { return InitRetType.getTypeRepr(); }
8726-
87278719
void setDeserializedResultTypeLoc(TypeLoc ResultTyR);
87288720

87298721
/// Get the typechecked call to super.init expression, which needs to be

lib/AST/Bridging/DeclBridging.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,11 @@ BridgedConstructorDecl BridgedConstructorDecl_createParsed(
280280
auto throwsLoc = cThrowsLoc.unbridged();
281281
auto failabilityMarkLoc = cFailabilityMarkLoc.unbridged();
282282
// FIXME: rethrows
283-
// TODO: Handle LifetimeDependentReturnTypeRepr here.
284283
auto *decl = new (context) ConstructorDecl(
285284
declName, cInitKeywordLoc.unbridged(), failabilityMarkLoc.isValid(),
286285
failabilityMarkLoc, asyncLoc.isValid(), asyncLoc, throwsLoc.isValid(),
287286
throwsLoc, thrownType.unbridged(), parameterList,
288-
genericParams.unbridged(), cDeclContext.unbridged(),
289-
/*InitRetTy*/ nullptr);
287+
genericParams.unbridged(), cDeclContext.unbridged());
290288
decl->setTrailingWhereClause(genericWhereClause.unbridged());
291289
decl->setImplicitlyUnwrappedOptional(isIUO);
292290

lib/AST/Decl.cpp

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3792,8 +3792,6 @@ TypeRepr *ValueDecl::getResultTypeRepr() const {
37923792
returnRepr = SD->getElementTypeRepr();
37933793
} else if (auto *MD = dyn_cast<MacroDecl>(this)) {
37943794
returnRepr = MD->resultType.getTypeRepr();
3795-
} else if (auto *CD = dyn_cast<ConstructorDecl>(this)) {
3796-
returnRepr = CD->getResultTypeRepr();
37973795
}
37983796

37993797
return returnRepr;
@@ -10551,23 +10549,18 @@ bool FuncDecl::isMainTypeMainMethod() const {
1055110549

1055210550
ConstructorDecl::ConstructorDecl(DeclName Name, SourceLoc ConstructorLoc,
1055310551
bool Failable, SourceLoc FailabilityLoc,
10554-
bool Async, SourceLoc AsyncLoc,
10555-
bool Throws, SourceLoc ThrowsLoc,
10556-
TypeLoc ThrownType,
10552+
bool Async, SourceLoc AsyncLoc, bool Throws,
10553+
SourceLoc ThrowsLoc, TypeLoc ThrownType,
1055710554
ParameterList *BodyParams,
1055810555
GenericParamList *GenericParams,
10559-
DeclContext *Parent, TypeRepr *ResultTyR)
10560-
: AbstractFunctionDecl(DeclKind::Constructor, Parent, Name, ConstructorLoc,
10561-
Async, AsyncLoc, Throws, ThrowsLoc, ThrownType,
10562-
/*HasImplicitSelfDecl=*/true,
10563-
GenericParams),
10564-
FailabilityLoc(FailabilityLoc),
10565-
SelfDecl(nullptr)
10566-
{
10556+
DeclContext *Parent)
10557+
: AbstractFunctionDecl(DeclKind::Constructor, Parent, Name, ConstructorLoc,
10558+
Async, AsyncLoc, Throws, ThrowsLoc, ThrownType,
10559+
/*HasImplicitSelfDecl=*/true, GenericParams),
10560+
FailabilityLoc(FailabilityLoc), SelfDecl(nullptr) {
1056710561
if (BodyParams)
1056810562
setParameters(BodyParams);
1056910563

10570-
InitRetType = TypeLoc(ResultTyR);
1057110564
Bits.ConstructorDecl.HasStubImplementation = 0;
1057210565
Bits.ConstructorDecl.Failable = Failable;
1057310566

@@ -10583,21 +10576,14 @@ ConstructorDecl *ConstructorDecl::createImported(
1058310576
GenericParamList *genericParams, DeclContext *parent) {
1058410577
void *declPtr = allocateMemoryForDecl<ConstructorDecl>(
1058510578
ctx, sizeof(ConstructorDecl), true);
10586-
auto ctor = ::new (declPtr)
10587-
ConstructorDecl(name, constructorLoc,
10588-
failable, failabilityLoc,
10589-
async, asyncLoc,
10590-
throws, throwsLoc, TypeLoc::withoutLoc(thrownType),
10591-
bodyParams, genericParams, parent,
10592-
/*LifetimeDependenceTypeRepr*/ nullptr);
10579+
auto ctor = ::new (declPtr) ConstructorDecl(
10580+
name, constructorLoc, failable, failabilityLoc, async, asyncLoc, throws,
10581+
throwsLoc, TypeLoc::withoutLoc(thrownType), bodyParams, genericParams,
10582+
parent);
1059310583
ctor->setClangNode(clangNode);
1059410584
return ctor;
1059510585
}
1059610586

10597-
void ConstructorDecl::setDeserializedResultTypeLoc(TypeLoc ResultTyR) {
10598-
InitRetType = ResultTyR;
10599-
}
10600-
1060110587
bool ConstructorDecl::isObjCZeroParameterWithLongSelector() const {
1060210588
// The initializer must have a single, non-empty argument name.
1060310589
if (getName().getArgumentNames().size() != 1 ||

lib/ClangImporter/ImportDecl.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3792,8 +3792,7 @@ namespace {
37923792
/*failable=*/false, /*FailabilityLoc=*/SourceLoc(),
37933793
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
37943794
/*Throws=*/false, /*ThrowsLoc=*/SourceLoc(),
3795-
/*ThrownType=*/TypeLoc(), bodyParams, genericParams, dc,
3796-
/*LifetimeDependentTypeRepr*/ nullptr);
3795+
/*ThrownType=*/TypeLoc(), bodyParams, genericParams, dc);
37973796
} else {
37983797
auto resultTy = importedType.getType();
37993798

@@ -6456,8 +6455,7 @@ Decl *SwiftDeclConverter::importGlobalAsInitializer(
64566455
/*FailabilityLoc=*/SourceLoc(),
64576456
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
64586457
/*Throws=*/false, /*ThrowsLoc=*/SourceLoc(), /*ThrownType=*/TypeLoc(),
6459-
parameterList, /*GenericParams=*/nullptr, dc,
6460-
/*LifetimeDependentTypeRepr*/ nullptr);
6458+
parameterList, /*GenericParams=*/nullptr, dc);
64616459
result->setImplicitlyUnwrappedOptional(isIUO);
64626460
result->getASTContext().evaluator.cacheOutput(InitKindRequest{result},
64636461
std::move(initKind));
@@ -6971,8 +6969,7 @@ ConstructorDecl *SwiftDeclConverter::importConstructor(
69716969
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
69726970
/*Throws=*/importedName.getErrorInfo().has_value(),
69736971
/*ThrowsLoc=*/SourceLoc(), /*ThrownType=*/TypeLoc(), bodyParams,
6974-
/*GenericParams=*/nullptr, const_cast<DeclContext *>(dc),
6975-
/*LifetimeDependentTypeRepr*/ nullptr);
6972+
/*GenericParams=*/nullptr, const_cast<DeclContext *>(dc));
69766973

69776974
addObjCAttribute(result, selector);
69786975
recordMemberInContext(dc, result);

lib/ClangImporter/SwiftDeclSynthesizer.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,7 @@ SwiftDeclSynthesizer::createDefaultConstructor(NominalTypeDecl *structDecl) {
494494
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
495495
/*Throws=*/false, /*ThrowsLoc=*/SourceLoc(),
496496
/*ThrownType=*/TypeLoc(), emptyPL,
497-
/*GenericParams=*/nullptr, structDecl,
498-
/*LifetimeDependentTypeRepr*/ nullptr);
497+
/*GenericParams=*/nullptr, structDecl);
499498

500499
constructor->setAccess(AccessLevel::Public);
501500

@@ -625,8 +624,7 @@ ConstructorDecl *SwiftDeclSynthesizer::createValueConstructor(
625624
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
626625
/*Throws=*/false, /*ThrowsLoc=*/SourceLoc(),
627626
/*ThrownType=*/TypeLoc(), paramList,
628-
/*GenericParams=*/nullptr, structDecl,
629-
/*LifetimeDependentTypeRepr*/ nullptr);
627+
/*GenericParams=*/nullptr, structDecl);
630628

631629
constructor->setAccess(AccessLevel::Public);
632630

@@ -1273,8 +1271,7 @@ SwiftDeclSynthesizer::makeEnumRawValueConstructor(EnumDecl *enumDecl) {
12731271
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
12741272
/*Throws=*/false, /*ThrowsLoc=*/SourceLoc(),
12751273
/*ThrownType=*/TypeLoc(), paramPL,
1276-
/*GenericParams=*/nullptr, enumDecl,
1277-
/*LifetimeDependentTypeRepr*/ nullptr);
1274+
/*GenericParams=*/nullptr, enumDecl);
12781275
ctorDecl->setImplicit();
12791276
ctorDecl->setAccess(AccessLevel::Public);
12801277
ctorDecl->setBodySynthesizer(synthesizeEnumRawValueConstructorBody, enumDecl);

lib/Parse/ParseDecl.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10025,12 +10025,10 @@ Parser::parseDeclInit(ParseDeclOptions Flags, DeclAttributes &Attributes) {
1002510025

1002610026
diagnoseWhereClauseInGenericParamList(GenericParams);
1002710027

10028-
auto *CD = new (Context) ConstructorDecl(FullName, ConstructorLoc,
10029-
Failable, FailabilityLoc,
10030-
isAsync, asyncLoc,
10031-
throwsLoc.isValid(), throwsLoc,
10032-
thrownTy, BodyParams, GenericParams,
10033-
CurDeclContext, FuncRetTy);
10028+
auto *CD = new (Context)
10029+
ConstructorDecl(FullName, ConstructorLoc, Failable, FailabilityLoc,
10030+
isAsync, asyncLoc, throwsLoc.isValid(), throwsLoc,
10031+
thrownTy, BodyParams, GenericParams, CurDeclContext);
1003410032
CD->setImplicitlyUnwrappedOptional(IUO);
1003510033
CD->getAttrs() = Attributes;
1003610034

lib/Sema/CodeSynthesis.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,7 @@ static ConstructorDecl *createImplicitConstructor(NominalTypeDecl *decl,
331331
/*Failable=*/false, /*FailabilityLoc=*/SourceLoc(),
332332
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
333333
/*Throws=*/false, /*ThrowsLoc=*/SourceLoc(),
334-
/*ThrownType=*/TypeLoc(), paramList, /*GenericParams=*/nullptr, decl,
335-
/*LifetimeDependentTypeRepr*/ nullptr);
334+
/*ThrownType=*/TypeLoc(), paramList, /*GenericParams=*/nullptr, decl);
336335

337336
// Mark implicit.
338337
ctor->setImplicit();
@@ -827,8 +826,7 @@ createDesignatedInitOverride(ClassDecl *classDecl,
827826
/*AsyncLoc=*/SourceLoc(),
828827
/*Throws=*/superclassCtor->hasThrows(),
829828
/*ThrowsLoc=*/SourceLoc(), TypeLoc::withoutLoc(thrownType), bodyParams,
830-
genericParams, implCtx,
831-
/*LifetimeDependentTypeRepr*/ nullptr);
829+
genericParams, implCtx);
832830

833831
ctor->setImplicit();
834832

lib/Sema/DerivedConformanceCodable.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,8 +1889,7 @@ static ValueDecl *deriveDecodable_init(DerivedConformance &derived) {
18891889
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
18901890
/*Throws=*/true, SourceLoc(),
18911891
/*ThrownType=*/TypeLoc(), paramList,
1892-
/*GenericParams=*/nullptr, conformanceDC,
1893-
/*LifetimeDependentTypeRepr*/ nullptr);
1892+
/*GenericParams=*/nullptr, conformanceDC);
18941893
initDecl->setImplicit();
18951894
initDecl->setSynthesized();
18961895

lib/Sema/DerivedConformanceCodingKey.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ static ValueDecl *deriveInitDecl(DerivedConformance &derived, Type paramType,
132132
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
133133
/*Throws=*/false, /*ThrowsLoc=*/SourceLoc(),
134134
/*ThrownType=*/TypeLoc(), paramList,
135-
/*GenericParams=*/nullptr, parentDC,
136-
/*LifetimeDependentTypeRepr*/ nullptr);
135+
/*GenericParams=*/nullptr, parentDC);
137136

138137
initDecl->setImplicit();
139138

lib/Sema/DerivedConformanceRawRepresentable.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,7 @@ deriveRawRepresentable_init(DerivedConformance &derived) {
432432
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
433433
/*Throws=*/false, /*ThrowsLoc=*/SourceLoc(),
434434
/*ThrownType=*/TypeLoc(), paramList,
435-
/*GenericParams=*/nullptr, parentDC,
436-
/*LifetimeDependentTypeRepr*/ nullptr);
435+
/*GenericParams=*/nullptr, parentDC);
437436

438437
initDecl->setImplicit();
439438
initDecl->setBodySynthesizer(&deriveBodyRawRepresentable_init);

lib/Serialization/Deserialization.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3719,16 +3719,14 @@ class DeclDeserializer {
37193719
return thrownTypeOrError.takeError();
37203720
const auto thrownType = thrownTypeOrError.get();
37213721

3722-
auto ctor = MF.createDecl<ConstructorDecl>(name, SourceLoc(), isFailable,
3723-
/*FailabilityLoc=*/SourceLoc(),
3724-
/*Async=*/async,
3725-
/*AsyncLoc=*/SourceLoc(),
3726-
/*Throws=*/throws,
3727-
/*ThrowsLoc=*/SourceLoc(),
3728-
TypeLoc::withoutLoc(thrownType),
3729-
/*BodyParams=*/nullptr,
3730-
genericParams, parent,
3731-
nullptr);
3722+
auto ctor = MF.createDecl<ConstructorDecl>(
3723+
name, SourceLoc(), isFailable,
3724+
/*FailabilityLoc=*/SourceLoc(),
3725+
/*Async=*/async,
3726+
/*AsyncLoc=*/SourceLoc(),
3727+
/*Throws=*/throws,
3728+
/*ThrowsLoc=*/SourceLoc(), TypeLoc::withoutLoc(thrownType),
3729+
/*BodyParams=*/nullptr, genericParams, parent);
37323730
declOrOffset = ctor;
37333731

37343732
ctor->setGenericSignature(MF.getGenericSignature(genericSigID));

0 commit comments

Comments
 (0)