36
36
#include " swift/AST/PlatformKind.h"
37
37
#include " swift/AST/Requirement.h"
38
38
#include " swift/AST/TrailingCallArguments.h"
39
- #include " swift/AST/TypeLoc.h"
40
39
#include " llvm/ADT/SmallVector.h"
41
40
#include " llvm/ADT/StringRef.h"
42
41
#include " llvm/Support/ErrorHandling.h"
@@ -1111,47 +1110,41 @@ class DynamicReplacementAttr final
1111
1110
1112
1111
// / The \c @_typeEraser(TypeEraserType) attribute.
1113
1112
class TypeEraserAttr final : public DeclAttribute {
1114
- TypeLoc TypeEraserLoc ;
1113
+ TypeExpr *TypeEraserExpr ;
1115
1114
LazyMemberLoader *Resolver;
1116
1115
uint64_t ResolverContextData;
1117
1116
1118
1117
friend class ResolveTypeEraserTypeRequest ;
1119
1118
1120
- TypeEraserAttr (SourceLoc atLoc, SourceRange range, TypeLoc typeEraserLoc ,
1119
+ TypeEraserAttr (SourceLoc atLoc, SourceRange range, TypeExpr *typeEraserExpr ,
1121
1120
LazyMemberLoader *Resolver, uint64_t Data)
1122
1121
: DeclAttribute(DAK_TypeEraser, atLoc, range, /* Implicit=*/ false ),
1123
- TypeEraserLoc (typeEraserLoc ),
1122
+ TypeEraserExpr (typeEraserExpr ),
1124
1123
Resolver(Resolver), ResolverContextData(Data) {}
1125
1124
1126
1125
public:
1127
1126
static TypeEraserAttr *create (ASTContext &ctx,
1128
1127
SourceLoc atLoc, SourceRange range,
1129
- TypeRepr *typeEraserRepr);
1128
+ TypeExpr *typeEraserRepr);
1130
1129
1131
1130
static TypeEraserAttr *create (ASTContext &ctx,
1132
1131
LazyMemberLoader *Resolver,
1133
1132
uint64_t Data);
1134
1133
1135
1134
// / Retrieve the parsed type repr for this attribute, if it
1136
1135
// / was parsed. Else returns \c nullptr.
1137
- TypeRepr *getParsedTypeEraserTypeRepr () const {
1138
- return TypeEraserLoc.getTypeRepr ();
1139
- }
1136
+ TypeRepr *getParsedTypeEraserTypeRepr () const ;
1140
1137
1141
1138
// / Retrieve the parsed location for this attribute, if it was parsed.
1142
- SourceLoc getLoc () const {
1143
- return TypeEraserLoc.getLoc ();
1144
- }
1139
+ SourceLoc getLoc () const ;
1145
1140
1146
1141
// / Retrieve the resolved type of this attribute if it has been resolved by a
1147
1142
// / successful call to \c getResolvedType(). Otherwise,
1148
1143
// / returns \c Type()
1149
1144
// /
1150
1145
// / This entrypoint is only suitable for syntactic clients like the
1151
1146
// / AST printer. Semantic clients should use \c getResolvedType() instead.
1152
- Type getTypeWithoutResolving () const {
1153
- return TypeEraserLoc.getType ();
1154
- }
1147
+ Type getTypeWithoutResolving () const ;
1155
1148
1156
1149
// / Returns \c true if the type eraser type has a valid implementation of the
1157
1150
// / erasing initializer for the given protocol.
@@ -1597,27 +1590,27 @@ class ClangImporterSynthesizedTypeAttr : public DeclAttribute {
1597
1590
// / Defines a custom attribute.
1598
1591
class CustomAttr final : public DeclAttribute,
1599
1592
public TrailingCallArguments<CustomAttr> {
1600
- TypeLoc type ;
1593
+ TypeExpr *typeExpr ;
1601
1594
Expr *arg;
1602
1595
PatternBindingInitializer *initContext;
1603
1596
Expr *semanticInit = nullptr ;
1604
1597
1605
1598
unsigned hasArgLabelLocs : 1 ;
1606
1599
unsigned numArgLabels : 16 ;
1607
1600
1608
- CustomAttr (SourceLoc atLoc, SourceRange range, TypeLoc type,
1601
+ CustomAttr (SourceLoc atLoc, SourceRange range, TypeExpr * type,
1609
1602
PatternBindingInitializer *initContext, Expr *arg,
1610
1603
ArrayRef<Identifier> argLabels, ArrayRef<SourceLoc> argLabelLocs,
1611
1604
bool implicit);
1612
1605
1613
1606
public:
1614
- static CustomAttr *create (ASTContext &ctx, SourceLoc atLoc, TypeLoc type,
1607
+ static CustomAttr *create (ASTContext &ctx, SourceLoc atLoc, TypeExpr * type,
1615
1608
bool implicit = false ) {
1616
1609
return create (ctx, atLoc, type, false , nullptr , SourceLoc (), { }, { }, { },
1617
1610
SourceLoc (), implicit);
1618
1611
}
1619
1612
1620
- static CustomAttr *create (ASTContext &ctx, SourceLoc atLoc, TypeLoc type,
1613
+ static CustomAttr *create (ASTContext &ctx, SourceLoc atLoc, TypeExpr * type,
1621
1614
bool hasInitializer,
1622
1615
PatternBindingInitializer *initContext,
1623
1616
SourceLoc lParenLoc,
@@ -1630,8 +1623,8 @@ class CustomAttr final : public DeclAttribute,
1630
1623
unsigned getNumArguments () const { return numArgLabels; }
1631
1624
bool hasArgumentLabelLocs () const { return hasArgLabelLocs; }
1632
1625
1633
- TypeRepr *getTypeRepr () const { return type. getTypeRepr (); }
1634
- Type getType () const { return type. getType (); }
1626
+ TypeRepr *getTypeRepr () const ;
1627
+ Type getType () const ;
1635
1628
1636
1629
Expr *getArg () const { return arg; }
1637
1630
void setArg (Expr *newArg) { arg = newArg; }
@@ -1647,11 +1640,11 @@ class CustomAttr final : public DeclAttribute,
1647
1640
1648
1641
private:
1649
1642
friend class CustomAttrNominalRequest ;
1650
- void resetTypeInformation (TypeRepr *repr) { type = TypeLoc (repr); }
1643
+ void resetTypeInformation (TypeExpr *repr);
1651
1644
1652
1645
private:
1653
1646
friend class CustomAttrTypeRequest ;
1654
- void setType (Type ty) { type = TypeLoc ( getTypeRepr (), ty); }
1647
+ void setType (Type ty);
1655
1648
};
1656
1649
1657
1650
// / Relates a property to its projection value property, as described by a property wrapper. For
0 commit comments