@@ -369,14 +369,21 @@ class alignas(1 << DeclAlignInBits) Decl {
369
369
IsPropertyWrapperBackingProperty : 1
370
370
);
371
371
372
- SWIFT_INLINE_BITFIELD (ParamDecl, VarDecl, 1 +2 +NumDefaultArgumentKindBits,
372
+ SWIFT_INLINE_BITFIELD (ParamDecl, VarDecl, 1 +2 +1 + NumDefaultArgumentKindBits,
373
373
// / Whether we've computed the specifier yet.
374
374
SpecifierComputed : 1 ,
375
375
376
376
// / The specifier associated with this parameter. This determines
377
377
// / the storage semantics of the value e.g. mutability.
378
378
Specifier : 2 ,
379
379
380
+ // / True if the type is implicitly specified in the source, but this has an
381
+ // / apparently valid typeRepr. This is used in accessors, which look like:
382
+ // / set (value) {
383
+ // / but need to get the typeRepr from the property as a whole so Sema can
384
+ // / resolve the type.
385
+ IsTypeLocImplicit : 1 ,
386
+
380
387
// / Information about a symbolic default argument, like #file.
381
388
defaultArgumentKind : NumDefaultArgumentKindBits
382
389
);
@@ -2978,6 +2985,9 @@ class TypeAliasDecl : public GenericTypeDecl {
2978
2985
// / Retrieve a sugared interface type containing the structure of the interface
2979
2986
// / type before any semantic validation has occured.
2980
2987
Type getStructuralType () const ;
2988
+
2989
+ // / Set the interface type of this typealias declaration from the underlying type.
2990
+ void computeType ();
2981
2991
2982
2992
bool isCompatibilityAlias () const {
2983
2993
return Bits.TypeAliasDecl .IsCompatibilityAlias ;
@@ -3166,6 +3176,10 @@ class AssociatedTypeDecl : public AbstractTypeParamDecl {
3166
3176
TrailingWhere = trailingWhereClause;
3167
3177
}
3168
3178
3179
+ // / Set the interface type of this associated type declaration to a dependent
3180
+ // / member type of 'Self'.
3181
+ void computeType ();
3182
+
3169
3183
// / Retrieve the associated type "anchor", which is the associated type
3170
3184
// / declaration that will be used to describe this associated type in the
3171
3185
// / ABI.
@@ -3355,6 +3369,10 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
3355
3369
Bits.NominalTypeDecl .AddedImplicitInitializers = true ;
3356
3370
}
3357
3371
3372
+ // / Set the interface type of this nominal type to the metatype of the
3373
+ // / declared interface type.
3374
+ void computeType ();
3375
+
3358
3376
// / getDeclaredType - Retrieve the type declared by this entity, without
3359
3377
// / any generic parameters bound if this is a generic type.
3360
3378
Type getDeclaredType () const ;
@@ -4786,7 +4804,8 @@ class VarDecl : public AbstractStorageDecl {
4786
4804
bool issCaptureList, SourceLoc nameLoc, Identifier name,
4787
4805
DeclContext *dc, StorageIsMutable_t supportsMutation);
4788
4806
4789
- TypeRepr *ParentRepr = nullptr ;
4807
+ // / This is the type specified, including location information.
4808
+ TypeLoc typeLoc;
4790
4809
4791
4810
Type typeInContext;
4792
4811
@@ -4806,10 +4825,8 @@ class VarDecl : public AbstractStorageDecl {
4806
4825
return hasName () ? getBaseName ().getIdentifier ().str () : " _" ;
4807
4826
}
4808
4827
4809
- // / Retrieve the TypeRepr corresponding to the parsed type of the parent
4810
- // / pattern, if it exists.
4811
- TypeRepr *getTypeRepr () const { return ParentRepr; }
4812
- void setTypeRepr (TypeRepr *repr) { ParentRepr = repr; }
4828
+ TypeLoc &getTypeLoc () { return typeLoc; }
4829
+ TypeLoc getTypeLoc () const { return typeLoc; }
4813
4830
4814
4831
bool hasType () const {
4815
4832
// We have a type if either the type has been computed already or if
@@ -5184,8 +5201,10 @@ class ParamDecl : public VarDecl {
5184
5201
Identifier argumentName, SourceLoc parameterNameLoc,
5185
5202
Identifier parameterName, DeclContext *dc);
5186
5203
5187
- // / Create a new ParamDecl identical to the first except without the interface type.
5188
- static ParamDecl *cloneWithoutType (const ASTContext &Ctx, ParamDecl *PD);
5204
+ // / Clone constructor, allocates a new ParamDecl identical to the first.
5205
+ // / Intentionally not defined as a typical copy constructor to avoid
5206
+ // / accidental copies.
5207
+ ParamDecl (ParamDecl *PD, bool withTypes);
5189
5208
5190
5209
// / Retrieve the argument (API) name for this function parameter.
5191
5210
Identifier getArgumentName () const { return ArgumentName; }
@@ -5202,7 +5221,10 @@ class ParamDecl : public VarDecl {
5202
5221
SourceLoc getParameterNameLoc () const { return ParameterNameLoc; }
5203
5222
5204
5223
SourceLoc getSpecifierLoc () const { return SpecifierLoc; }
5205
-
5224
+
5225
+ bool isTypeLocImplicit () const { return Bits.ParamDecl .IsTypeLocImplicit ; }
5226
+ void setIsTypeLocImplicit (bool val) { Bits.ParamDecl .IsTypeLocImplicit = val; }
5227
+
5206
5228
DefaultArgumentKind getDefaultArgumentKind () const {
5207
5229
return static_cast <DefaultArgumentKind>(Bits.ParamDecl .defaultArgumentKind );
5208
5230
}
@@ -5473,6 +5495,10 @@ class SubscriptDecl : public GenericContext, public AbstractStorageDecl {
5473
5495
TypeLoc &getElementTypeLoc () { return ElementTy; }
5474
5496
const TypeLoc &getElementTypeLoc () const { return ElementTy; }
5475
5497
5498
+ // / Compute the interface type of this subscript from the parameter and
5499
+ // / element types.
5500
+ void computeType ();
5501
+
5476
5502
// / Determine the kind of Objective-C subscripting this declaration
5477
5503
// / implies.
5478
5504
ObjCSubscriptKind getObjCSubscriptKind () const ;
@@ -6343,6 +6369,10 @@ class EnumElementDecl : public DeclContext, public ValueDecl {
6343
6369
return hasName () ? getBaseName ().getIdentifier ().str () : " _" ;
6344
6370
}
6345
6371
6372
+ // / Set the interface type of this enum element to the constructor function
6373
+ // / type; (Self.Type) -> Self or (Self.Type) -> (Args...) -> Self.
6374
+ void computeType ();
6375
+
6346
6376
Type getArgumentInterfaceType () const ;
6347
6377
6348
6378
void setParameterList (ParameterList *params);
0 commit comments