@@ -5598,28 +5598,52 @@ enum class ObjCSubscriptKind {
5598
5598
// / signatures (indices and element type) are distinct.
5599
5599
// /
5600
5600
class SubscriptDecl : public GenericContext , public AbstractStorageDecl {
5601
+ friend class ResultTypeRequest ;
5602
+
5601
5603
SourceLoc StaticLoc;
5602
5604
SourceLoc ArrowLoc;
5603
5605
SourceLoc EndLoc;
5604
5606
ParameterList *Indices;
5605
5607
TypeLoc ElementTy;
5606
5608
5607
- public:
5609
+ void setElementInterfaceType (Type type);
5610
+
5608
5611
SubscriptDecl (DeclName Name,
5609
5612
SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
5610
5613
SourceLoc SubscriptLoc, ParameterList *Indices,
5611
- SourceLoc ArrowLoc, TypeLoc ElementTy , DeclContext *Parent,
5614
+ SourceLoc ArrowLoc, TypeRepr *ElementTyR , DeclContext *Parent,
5612
5615
GenericParamList *GenericParams)
5613
5616
: GenericContext(DeclContextKind::SubscriptDecl, Parent, GenericParams),
5614
5617
AbstractStorageDecl (DeclKind::Subscript,
5615
5618
StaticSpelling != StaticSpellingKind::None,
5616
5619
Parent, Name, SubscriptLoc,
5617
5620
/* will be overwritten*/ StorageIsNotMutable),
5618
5621
StaticLoc(StaticLoc), ArrowLoc(ArrowLoc),
5619
- Indices(nullptr ), ElementTy(ElementTy ) {
5622
+ Indices(nullptr ), ElementTy(ElementTyR ) {
5620
5623
Bits.SubscriptDecl .StaticSpelling = static_cast <unsigned >(StaticSpelling);
5621
5624
setIndices (Indices);
5622
5625
}
5626
+
5627
+ public:
5628
+ // / Factory function only for use by deserialization.
5629
+ static SubscriptDecl *createDeserialized (ASTContext &Context, DeclName Name,
5630
+ StaticSpellingKind StaticSpelling,
5631
+ Type ElementTy, DeclContext *Parent,
5632
+ GenericParamList *GenericParams);
5633
+
5634
+ static SubscriptDecl *create (ASTContext &Context, DeclName Name,
5635
+ SourceLoc StaticLoc,
5636
+ StaticSpellingKind StaticSpelling,
5637
+ SourceLoc SubscriptLoc, ParameterList *Indices,
5638
+ SourceLoc ArrowLoc, TypeRepr *ElementTyR,
5639
+ DeclContext *Parent,
5640
+ GenericParamList *GenericParams);
5641
+
5642
+ static SubscriptDecl *createImported (ASTContext &Context, DeclName Name,
5643
+ SourceLoc SubscriptLoc,
5644
+ ParameterList *Indices,
5645
+ SourceLoc ArrowLoc, Type ElementTy,
5646
+ DeclContext *Parent, ClangNode ClangN);
5623
5647
5624
5648
// / \returns the way 'static'/'class' was spelled in the source.
5625
5649
StaticSpellingKind getStaticSpelling () const {
@@ -5646,8 +5670,11 @@ class SubscriptDecl : public GenericContext, public AbstractStorageDecl {
5646
5670
// / Retrieve the type of the element referenced by a subscript
5647
5671
// / operation.
5648
5672
Type getElementInterfaceType () const ;
5649
- TypeLoc &getElementTypeLoc () { return ElementTy; }
5650
- const TypeLoc &getElementTypeLoc () const { return ElementTy; }
5673
+
5674
+ TypeRepr *getElementTypeRepr () const { return ElementTy.getTypeRepr (); }
5675
+ SourceRange getElementTypeSourceRange () const {
5676
+ return ElementTy.getSourceRange ();
5677
+ }
5651
5678
5652
5679
// / Determine the kind of Objective-C subscripting this declaration
5653
5680
// / implies.
@@ -6146,6 +6173,7 @@ class FuncDecl : public AbstractFunctionDecl {
6146
6173
friend class AbstractFunctionDecl ;
6147
6174
friend class SelfAccessKindRequest ;
6148
6175
friend class IsStaticRequest ;
6176
+ friend class ResultTypeRequest ;
6149
6177
6150
6178
SourceLoc StaticLoc; // Location of the 'static' token or invalid.
6151
6179
SourceLoc FuncLoc; // Location of the 'func' token.
@@ -6180,6 +6208,8 @@ class FuncDecl : public AbstractFunctionDecl {
6180
6208
Bits.FuncDecl .HasTopLevelLocalContextCaptures = false ;
6181
6209
}
6182
6210
6211
+ void setResultInterfaceType (Type type);
6212
+
6183
6213
private:
6184
6214
static FuncDecl *createImpl (ASTContext &Context, SourceLoc StaticLoc,
6185
6215
StaticSpellingKind StaticSpelling,
@@ -6207,25 +6237,31 @@ class FuncDecl : public AbstractFunctionDecl {
6207
6237
6208
6238
public:
6209
6239
// / Factory function only for use by deserialization.
6210
- static FuncDecl *createDeserialized (ASTContext &Context, SourceLoc StaticLoc,
6240
+ static FuncDecl *createDeserialized (ASTContext &Context,
6211
6241
StaticSpellingKind StaticSpelling,
6212
- SourceLoc FuncLoc,
6213
- DeclName Name, SourceLoc NameLoc,
6214
- bool Async, SourceLoc AsyncLoc,
6215
- bool Throws, SourceLoc ThrowsLoc,
6242
+ DeclName Name, bool Async, bool Throws,
6216
6243
GenericParamList *GenericParams,
6217
- DeclContext *Parent);
6244
+ Type FnRetType, DeclContext *Parent);
6218
6245
6219
6246
static FuncDecl *create (ASTContext &Context, SourceLoc StaticLoc,
6220
- StaticSpellingKind StaticSpelling,
6221
- SourceLoc FuncLoc,
6222
- DeclName Name, SourceLoc NameLoc,
6223
- bool Async, SourceLoc AsyncLoc,
6224
- bool Throws, SourceLoc ThrowsLoc,
6247
+ StaticSpellingKind StaticSpelling, SourceLoc FuncLoc,
6248
+ DeclName Name, SourceLoc NameLoc, bool Async,
6249
+ SourceLoc AsyncLoc, bool Throws, SourceLoc ThrowsLoc,
6225
6250
GenericParamList *GenericParams,
6226
- ParameterList *ParameterList,
6227
- TypeLoc FnRetType, DeclContext *Parent,
6228
- ClangNode ClangN = ClangNode());
6251
+ ParameterList *BodyParams, TypeRepr *ResultTyR,
6252
+ DeclContext *Parent);
6253
+
6254
+ static FuncDecl *createImplicit (ASTContext &Context,
6255
+ StaticSpellingKind StaticSpelling,
6256
+ DeclName Name, SourceLoc NameLoc, bool Async,
6257
+ bool Throws, GenericParamList *GenericParams,
6258
+ ParameterList *BodyParams, Type FnRetType,
6259
+ DeclContext *Parent);
6260
+
6261
+ static FuncDecl *createImported (ASTContext &Context, SourceLoc FuncLoc,
6262
+ DeclName Name, SourceLoc NameLoc, bool Throws,
6263
+ ParameterList *BodyParams, Type FnRetType,
6264
+ DeclContext *Parent, ClangNode ClangN);
6229
6265
6230
6266
bool isStatic () const ;
6231
6267
@@ -6269,8 +6305,10 @@ class FuncDecl : public AbstractFunctionDecl {
6269
6305
}
6270
6306
SourceRange getSourceRange () const ;
6271
6307
6272
- TypeLoc &getBodyResultTypeLoc () { return FnRetType; }
6273
- const TypeLoc &getBodyResultTypeLoc () const { return FnRetType; }
6308
+ TypeRepr *getResultTypeRepr () const { return FnRetType.getTypeRepr (); }
6309
+ SourceRange getResultTypeSourceRange () const {
6310
+ return FnRetType.getSourceRange ();
6311
+ }
6274
6312
6275
6313
// / Retrieve the result interface type of this function.
6276
6314
Type getResultInterfaceType () const ;
@@ -6391,15 +6429,12 @@ class AccessorDecl final : public FuncDecl {
6391
6429
6392
6430
public:
6393
6431
static AccessorDecl *createDeserialized (ASTContext &ctx,
6394
- SourceLoc declLoc,
6395
- SourceLoc accessorKeywordLoc,
6396
- AccessorKind accessorKind,
6397
- AbstractStorageDecl *storage,
6398
- SourceLoc staticLoc,
6399
- StaticSpellingKind staticSpelling,
6400
- bool throws, SourceLoc throwsLoc,
6401
- GenericParamList *genericParams,
6402
- DeclContext *parent);
6432
+ AccessorKind accessorKind,
6433
+ AbstractStorageDecl *storage,
6434
+ StaticSpellingKind staticSpelling,
6435
+ bool throws,
6436
+ GenericParamList *genericParams,
6437
+ Type fnRetType, DeclContext *parent);
6403
6438
6404
6439
static AccessorDecl *create (ASTContext &ctx, SourceLoc declLoc,
6405
6440
SourceLoc accessorKeywordLoc,
@@ -6410,7 +6445,7 @@ class AccessorDecl final : public FuncDecl {
6410
6445
bool throws, SourceLoc throwsLoc,
6411
6446
GenericParamList *genericParams,
6412
6447
ParameterList *parameterList,
6413
- TypeLoc fnRetType, DeclContext *parent,
6448
+ Type fnRetType, DeclContext *parent,
6414
6449
ClangNode clangNode = ClangNode());
6415
6450
6416
6451
SourceLoc getAccessorKeywordLoc () const { return AccessorKeywordLoc; }
0 commit comments