@@ -4774,27 +4774,6 @@ class ParamDecl : public VarDecl {
4774
4774
4775
4775
SourceRange getSourceRange () const ;
4776
4776
4777
- // / Create an implicit 'self' decl for a method in the specified decl context.
4778
- // / If 'static' is true, then this is self for a static method in the type.
4779
- // /
4780
- // / Note that this decl is created, but it is returned with an incorrect
4781
- // / DeclContext that needs to be set correctly. This is automatically handled
4782
- // / when a function is created with this as part of its argument list.
4783
- // / For a generic context, this also gives the parameter an unbound generic
4784
- // / type with the expectation that type-checking will fill in the context
4785
- // / generic parameters.
4786
- static ParamDecl *createUnboundSelf (SourceLoc loc, DeclContext *DC);
4787
-
4788
- // / Create an implicit 'self' decl for a method in the specified decl context.
4789
- // / If 'static' is true, then this is self for a static method in the type.
4790
- // /
4791
- // / Note that this decl is created, but it is returned with an incorrect
4792
- // / DeclContext that needs to be set correctly. This is automatically handled
4793
- // / when a function is created with this as part of its argument list.
4794
- static ParamDecl *createSelf (SourceLoc loc, DeclContext *DC,
4795
- bool isStatic = false ,
4796
- bool isInOut = false );
4797
-
4798
4777
// Implement isa/cast/dyncast/etc.
4799
4778
static bool classof (const Decl *D) {
4800
4779
return D->getKind () == DeclKind::Param;
@@ -5169,6 +5148,8 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5169
5148
private:
5170
5149
void computeNeedsNewVTableEntry ();
5171
5150
5151
+ void computeSelfDeclType ();
5152
+
5172
5153
public:
5173
5154
// / Compute the interface type of this function declaration from the
5174
5155
// / parameter types.
@@ -5202,24 +5183,21 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
5202
5183
return Params;
5203
5184
}
5204
5185
5205
- void setParameters (ParamDecl *SelfDecl,
5206
- ParameterList *Params);
5186
+ void setParameters (ParameterList *Params);
5207
5187
5208
5188
bool hasImplicitSelfDecl () const {
5209
5189
return Bits.AbstractFunctionDecl .HasImplicitSelfDecl ;
5210
5190
}
5211
5191
5212
5192
ParamDecl **getImplicitSelfDeclStorage ();
5213
5193
5214
- // / Retrieve the implicit 'self' parameter for methods, or nullptr for free
5215
- // / functions.
5216
- const ParamDecl *getImplicitSelfDecl () const {
5217
- return const_cast <AbstractFunctionDecl*>(this )->getImplicitSelfDecl ();
5218
- }
5219
- ParamDecl *getImplicitSelfDecl () {
5220
- auto **selfDecl = getImplicitSelfDeclStorage ();
5221
- return (selfDecl == nullptr ? nullptr : *selfDecl);
5194
+ // / Retrieve the implicit 'self' parameter for methods. Returns nullptr for
5195
+ // / free functions.
5196
+ const ParamDecl *getImplicitSelfDecl (bool createIfNeeded=true ) const {
5197
+ return const_cast <AbstractFunctionDecl*>(this )
5198
+ ->getImplicitSelfDecl (createIfNeeded);
5222
5199
}
5200
+ ParamDecl *getImplicitSelfDecl (bool createIfNeeded=true );
5223
5201
5224
5202
// / Retrieve the declaration that this method overrides, if any.
5225
5203
AbstractFunctionDecl *getOverriddenDecl () const {
@@ -5346,7 +5324,6 @@ class FuncDecl : public AbstractFunctionDecl {
5346
5324
DeclName Name, SourceLoc NameLoc,
5347
5325
bool Throws, SourceLoc ThrowsLoc,
5348
5326
GenericParamList *GenericParams,
5349
- bool HasImplicitSelfDecl,
5350
5327
DeclContext *Parent,
5351
5328
ClangNode ClangN);
5352
5329
@@ -5358,7 +5335,6 @@ class FuncDecl : public AbstractFunctionDecl {
5358
5335
DeclName Name, SourceLoc NameLoc,
5359
5336
bool Throws, SourceLoc ThrowsLoc,
5360
5337
GenericParamList *GenericParams,
5361
- bool HasImplicitSelfDecl,
5362
5338
DeclContext *Parent);
5363
5339
5364
5340
static FuncDecl *create (ASTContext &Context, SourceLoc StaticLoc,
@@ -5367,7 +5343,6 @@ class FuncDecl : public AbstractFunctionDecl {
5367
5343
DeclName Name, SourceLoc NameLoc,
5368
5344
bool Throws, SourceLoc ThrowsLoc,
5369
5345
GenericParamList *GenericParams,
5370
- ParamDecl *SelfDecl,
5371
5346
ParameterList *ParameterList,
5372
5347
TypeLoc FnRetType, DeclContext *Parent,
5373
5348
ClangNode ClangN = ClangNode());
@@ -5550,7 +5525,6 @@ class AccessorDecl final : public FuncDecl {
5550
5525
SourceLoc staticLoc,
5551
5526
StaticSpellingKind staticSpelling,
5552
5527
bool throws, SourceLoc throwsLoc,
5553
- bool hasImplicitSelfDecl,
5554
5528
GenericParamList *genericParams,
5555
5529
DeclContext *parent,
5556
5530
ClangNode clangNode);
@@ -5566,7 +5540,6 @@ class AccessorDecl final : public FuncDecl {
5566
5540
StaticSpellingKind staticSpelling,
5567
5541
bool throws, SourceLoc throwsLoc,
5568
5542
GenericParamList *genericParams,
5569
- bool hasImplicitSelfDecl,
5570
5543
DeclContext *parent);
5571
5544
5572
5545
static AccessorDecl *create (ASTContext &ctx, SourceLoc declLoc,
@@ -5578,7 +5551,6 @@ class AccessorDecl final : public FuncDecl {
5578
5551
StaticSpellingKind staticSpelling,
5579
5552
bool throws, SourceLoc throwsLoc,
5580
5553
GenericParamList *genericParams,
5581
- ParamDecl *selfDecl,
5582
5554
ParameterList *parameterList,
5583
5555
TypeLoc fnRetType, DeclContext *parent,
5584
5556
ClangNode clangNode = ClangNode());
@@ -5886,7 +5858,7 @@ class ConstructorDecl : public AbstractFunctionDecl {
5886
5858
ConstructorDecl (DeclName Name, SourceLoc ConstructorLoc,
5887
5859
OptionalTypeKind Failability, SourceLoc FailabilityLoc,
5888
5860
bool Throws, SourceLoc ThrowsLoc,
5889
- ParamDecl *SelfParam, ParameterList *BodyParams,
5861
+ ParameterList *BodyParams,
5890
5862
GenericParamList *GenericParams,
5891
5863
DeclContext *Parent);
5892
5864
@@ -6057,8 +6029,7 @@ class DestructorDecl : public AbstractFunctionDecl {
6057
6029
ParamDecl *SelfDecl;
6058
6030
6059
6031
public:
6060
- DestructorDecl (SourceLoc DestructorLoc, ParamDecl *selfDecl,
6061
- DeclContext *Parent);
6032
+ DestructorDecl (SourceLoc DestructorLoc, DeclContext *Parent);
6062
6033
6063
6034
ParamDecl **getImplicitSelfDeclStorage () { return &SelfDecl; }
6064
6035
0 commit comments