3636#include " swift/AST/PlatformKind.h"
3737#include " swift/AST/Requirement.h"
3838#include " swift/AST/TrailingCallArguments.h"
39- #include " swift/AST/TypeLoc.h"
4039#include " llvm/ADT/SmallVector.h"
4140#include " llvm/ADT/StringRef.h"
4241#include " llvm/Support/ErrorHandling.h"
@@ -56,6 +55,7 @@ class LazyConformanceLoader;
5655class LazyMemberLoader ;
5756class PatternBindingInitializer ;
5857class TrailingWhereClause ;
58+ class TypeExpr ;
5959
6060// / TypeAttributes - These are attributes that may be applied to types.
6161class TypeAttributes {
@@ -1110,47 +1110,41 @@ class DynamicReplacementAttr final
11101110
11111111// / The \c @_typeEraser(TypeEraserType) attribute.
11121112class TypeEraserAttr final : public DeclAttribute {
1113- TypeLoc TypeEraserLoc ;
1113+ TypeExpr *TypeEraserExpr ;
11141114 LazyMemberLoader *Resolver;
11151115 uint64_t ResolverContextData;
11161116
11171117 friend class ResolveTypeEraserTypeRequest ;
11181118
1119- TypeEraserAttr (SourceLoc atLoc, SourceRange range, TypeLoc typeEraserLoc ,
1119+ TypeEraserAttr (SourceLoc atLoc, SourceRange range, TypeExpr *typeEraserExpr ,
11201120 LazyMemberLoader *Resolver, uint64_t Data)
11211121 : DeclAttribute(DAK_TypeEraser, atLoc, range, /* Implicit=*/ false ),
1122- TypeEraserLoc (typeEraserLoc ),
1122+ TypeEraserExpr (typeEraserExpr ),
11231123 Resolver(Resolver), ResolverContextData(Data) {}
11241124
11251125public:
11261126 static TypeEraserAttr *create (ASTContext &ctx,
11271127 SourceLoc atLoc, SourceRange range,
1128- TypeLoc typeEraserLoc );
1128+ TypeExpr *typeEraserRepr );
11291129
11301130 static TypeEraserAttr *create (ASTContext &ctx,
11311131 LazyMemberLoader *Resolver,
11321132 uint64_t Data);
11331133
11341134 // / Retrieve the parsed type repr for this attribute, if it
11351135 // / was parsed. Else returns \c nullptr.
1136- TypeRepr *getParsedTypeEraserTypeRepr () const {
1137- return TypeEraserLoc.getTypeRepr ();
1138- }
1136+ TypeRepr *getParsedTypeEraserTypeRepr () const ;
11391137
11401138 // / Retrieve the parsed location for this attribute, if it was parsed.
1141- SourceLoc getLoc () const {
1142- return TypeEraserLoc.getLoc ();
1143- }
1139+ SourceLoc getLoc () const ;
11441140
11451141 // / Retrieve the resolved type of this attribute if it has been resolved by a
11461142 // / successful call to \c getResolvedType(). Otherwise,
11471143 // / returns \c Type()
11481144 // /
11491145 // / This entrypoint is only suitable for syntactic clients like the
11501146 // / AST printer. Semantic clients should use \c getResolvedType() instead.
1151- Type getTypeWithoutResolving () const {
1152- return TypeEraserLoc.getType ();
1153- }
1147+ Type getTypeWithoutResolving () const ;
11541148
11551149 // / Returns \c true if the type eraser type has a valid implementation of the
11561150 // / erasing initializer for the given protocol.
@@ -1464,25 +1458,26 @@ class SpecializeAttr : public DeclAttribute {
14641458// / The @_implements attribute, which treats a decl as the implementation for
14651459// / some named protocol requirement (but otherwise not-visible by that name).
14661460class ImplementsAttr : public DeclAttribute {
1467-
1468- TypeLoc ProtocolType;
1461+ TypeExpr *ProtocolType;
14691462 DeclName MemberName;
14701463 DeclNameLoc MemberNameLoc;
14711464
14721465public:
14731466 ImplementsAttr (SourceLoc atLoc, SourceRange Range,
1474- TypeLoc ProtocolType,
1467+ TypeExpr * ProtocolType,
14751468 DeclName MemberName,
14761469 DeclNameLoc MemberNameLoc);
14771470
14781471 static ImplementsAttr *create (ASTContext &Ctx, SourceLoc atLoc,
14791472 SourceRange Range,
1480- TypeLoc ProtocolType,
1473+ TypeExpr * ProtocolType,
14811474 DeclName MemberName,
14821475 DeclNameLoc MemberNameLoc);
14831476
1484- TypeLoc getProtocolType () const ;
1485- TypeLoc &getProtocolType ();
1477+ void setProtocolType (Type ty);
1478+ Type getProtocolType () const ;
1479+ TypeRepr *getProtocolTypeRepr () const ;
1480+
14861481 DeclName getMemberName () const { return MemberName; }
14871482 DeclNameLoc getMemberNameLoc () const { return MemberNameLoc; }
14881483
@@ -1595,27 +1590,27 @@ class ClangImporterSynthesizedTypeAttr : public DeclAttribute {
15951590// / Defines a custom attribute.
15961591class CustomAttr final : public DeclAttribute,
15971592 public TrailingCallArguments<CustomAttr> {
1598- TypeLoc type ;
1593+ TypeExpr *typeExpr ;
15991594 Expr *arg;
16001595 PatternBindingInitializer *initContext;
16011596 Expr *semanticInit = nullptr ;
16021597
16031598 unsigned hasArgLabelLocs : 1 ;
16041599 unsigned numArgLabels : 16 ;
16051600
1606- CustomAttr (SourceLoc atLoc, SourceRange range, TypeLoc type,
1601+ CustomAttr (SourceLoc atLoc, SourceRange range, TypeExpr * type,
16071602 PatternBindingInitializer *initContext, Expr *arg,
16081603 ArrayRef<Identifier> argLabels, ArrayRef<SourceLoc> argLabelLocs,
16091604 bool implicit);
16101605
16111606public:
1612- static CustomAttr *create (ASTContext &ctx, SourceLoc atLoc, TypeLoc type,
1607+ static CustomAttr *create (ASTContext &ctx, SourceLoc atLoc, TypeExpr * type,
16131608 bool implicit = false ) {
16141609 return create (ctx, atLoc, type, false , nullptr , SourceLoc (), { }, { }, { },
16151610 SourceLoc (), implicit);
16161611 }
16171612
1618- static CustomAttr *create (ASTContext &ctx, SourceLoc atLoc, TypeLoc type,
1613+ static CustomAttr *create (ASTContext &ctx, SourceLoc atLoc, TypeExpr * type,
16191614 bool hasInitializer,
16201615 PatternBindingInitializer *initContext,
16211616 SourceLoc lParenLoc,
@@ -1628,8 +1623,8 @@ class CustomAttr final : public DeclAttribute,
16281623 unsigned getNumArguments () const { return numArgLabels; }
16291624 bool hasArgumentLabelLocs () const { return hasArgLabelLocs; }
16301625
1631- TypeLoc & getTypeLoc () { return type; }
1632- const TypeLoc & getTypeLoc () const { return type; }
1626+ TypeRepr * getTypeRepr () const ;
1627+ Type getType () const ;
16331628
16341629 Expr *getArg () const { return arg; }
16351630 void setArg (Expr *newArg) { arg = newArg; }
@@ -1642,6 +1637,14 @@ class CustomAttr final : public DeclAttribute,
16421637 static bool classof (const DeclAttribute *DA) {
16431638 return DA->getKind () == DAK_Custom;
16441639 }
1640+
1641+ private:
1642+ friend class CustomAttrNominalRequest ;
1643+ void resetTypeInformation (TypeExpr *repr);
1644+
1645+ private:
1646+ friend class CustomAttrTypeRequest ;
1647+ void setType (Type ty);
16451648};
16461649
16471650// / Relates a property to its projection value property, as described by a property wrapper. For
0 commit comments