@@ -3364,6 +3364,10 @@ enum class CustomAttrTypeKind {
33643364 // / unbound generic types.
33653365 PropertyWrapper,
33663366
3367+ // / Just like property wrappers, type wrappers are represented
3368+ // / as custom type attributes and allow unbound generic types.
3369+ TypeWrapper,
3370+
33673371 // / Global actors are represented as custom type attributes. They don't
33683372 // / have any particularly interesting semantics.
33693373 GlobalActor,
@@ -3499,6 +3503,174 @@ class GetSourceFileAsyncNode
34993503 bool isCached () const { return true ; }
35003504};
35013505
3506+ // / Return a type wrapper (if any) associated with the given declaration.
3507+ class GetTypeWrapper
3508+ : public SimpleRequest<GetTypeWrapper, NominalTypeDecl *(NominalTypeDecl *),
3509+ RequestFlags::Cached> {
3510+ public:
3511+ using SimpleRequest::SimpleRequest;
3512+
3513+ private:
3514+ friend SimpleRequest;
3515+
3516+ NominalTypeDecl *evaluate (Evaluator &evaluator, NominalTypeDecl *) const ;
3517+
3518+ public:
3519+ bool isCached () const { return true ; }
3520+ };
3521+
3522+ // / Return a type of the type wrapper (if any) associated with the given
3523+ // / declaration.
3524+ class GetTypeWrapperType
3525+ : public SimpleRequest<GetTypeWrapperType, Type(NominalTypeDecl *),
3526+ RequestFlags::Cached> {
3527+ public:
3528+ using SimpleRequest::SimpleRequest;
3529+
3530+ private:
3531+ friend SimpleRequest;
3532+
3533+ Type evaluate (Evaluator &evaluator, NominalTypeDecl *) const ;
3534+
3535+ public:
3536+ bool isCached () const { return true ; }
3537+ };
3538+
3539+ // / Inject or get `$Storage` type which has all of the stored properties
3540+ // / of the given type with a type wrapper.
3541+ class GetTypeWrapperStorage
3542+ : public SimpleRequest<GetTypeWrapperStorage,
3543+ NominalTypeDecl *(NominalTypeDecl *),
3544+ RequestFlags::Cached> {
3545+ public:
3546+ using SimpleRequest::SimpleRequest;
3547+
3548+ private:
3549+ friend SimpleRequest;
3550+
3551+ NominalTypeDecl *evaluate (Evaluator &evaluator, NominalTypeDecl *) const ;
3552+
3553+ public:
3554+ bool isCached () const { return true ; }
3555+ };
3556+
3557+ // / Inject or get `$_storage` property which is used to route accesses through
3558+ // / to all stored properties of a type that has a type wrapper.
3559+ class GetTypeWrapperProperty
3560+ : public SimpleRequest<GetTypeWrapperProperty, VarDecl *(NominalTypeDecl *),
3561+ RequestFlags::Cached> {
3562+ public:
3563+ using SimpleRequest::SimpleRequest;
3564+
3565+ private:
3566+ friend SimpleRequest;
3567+
3568+ VarDecl *evaluate (Evaluator &evaluator, NominalTypeDecl *) const ;
3569+
3570+ public:
3571+ bool isCached () const { return true ; }
3572+ };
3573+
3574+ // / Given a stored property associated with a type wrapped type,
3575+ // / produce a property that mirrors it in the type wrapper context.
3576+ class GetTypeWrapperStorageForProperty
3577+ : public SimpleRequest<GetTypeWrapperStorageForProperty,
3578+ VarDecl *(VarDecl *), RequestFlags::Cached> {
3579+ public:
3580+ using SimpleRequest::SimpleRequest;
3581+
3582+ private:
3583+ friend SimpleRequest;
3584+
3585+ VarDecl *evaluate (Evaluator &evaluator, VarDecl *) const ;
3586+
3587+ public:
3588+ bool isCached () const { return true ; }
3589+ };
3590+
3591+ // / Synthesize the body of a getter for a stored property that belongs to
3592+ // / a type wrapped type.
3593+ class SynthesizeTypeWrappedPropertyGetterBody
3594+ : public SimpleRequest<SynthesizeTypeWrappedPropertyGetterBody,
3595+ BraceStmt *(AccessorDecl *), RequestFlags::Cached> {
3596+ public:
3597+ using SimpleRequest::SimpleRequest;
3598+
3599+ private:
3600+ friend SimpleRequest;
3601+
3602+ BraceStmt *evaluate (Evaluator &evaluator, AccessorDecl *) const ;
3603+
3604+ public:
3605+ bool isCached () const { return true ; }
3606+ };
3607+
3608+ // / Synthesize the body of a setter for a stored property that belongs to
3609+ // / a type wrapped type.
3610+ class SynthesizeTypeWrappedPropertySetterBody
3611+ : public SimpleRequest<SynthesizeTypeWrappedPropertySetterBody,
3612+ BraceStmt *(AccessorDecl *), RequestFlags::Cached> {
3613+ public:
3614+ using SimpleRequest::SimpleRequest;
3615+
3616+ private:
3617+ friend SimpleRequest;
3618+
3619+ BraceStmt *evaluate (Evaluator &evaluator, AccessorDecl *) const ;
3620+
3621+ public:
3622+ bool isCached () const { return true ; }
3623+ };
3624+
3625+ // / Inject or get `$Storage` type which has all of the stored properties
3626+ // / of the given type with a type wrapper.
3627+ class IsPropertyAccessedViaTypeWrapper
3628+ : public SimpleRequest<IsPropertyAccessedViaTypeWrapper, bool (VarDecl *),
3629+ RequestFlags::Cached> {
3630+ public:
3631+ using SimpleRequest::SimpleRequest;
3632+
3633+ private:
3634+ friend SimpleRequest;
3635+
3636+ bool evaluate (Evaluator &evaluator, VarDecl *) const ;
3637+
3638+ public:
3639+ bool isCached () const { return true ; }
3640+ };
3641+
3642+ class SynthesizeTypeWrapperInitializer
3643+ : public SimpleRequest<SynthesizeTypeWrapperInitializer,
3644+ ConstructorDecl *(NominalTypeDecl *),
3645+ RequestFlags::Cached> {
3646+ public:
3647+ using SimpleRequest::SimpleRequest;
3648+
3649+ private:
3650+ friend SimpleRequest;
3651+
3652+ ConstructorDecl *evaluate (Evaluator &evaluator, NominalTypeDecl *) const ;
3653+
3654+ public:
3655+ bool isCached () const { return true ; }
3656+ };
3657+
3658+ class SynthesizeTypeWrapperInitializerBody
3659+ : public SimpleRequest<SynthesizeTypeWrapperInitializerBody,
3660+ BraceStmt *(ConstructorDecl *),
3661+ RequestFlags::Cached> {
3662+ public:
3663+ using SimpleRequest::SimpleRequest;
3664+
3665+ private:
3666+ friend SimpleRequest;
3667+
3668+ BraceStmt *evaluate (Evaluator &evaluator, ConstructorDecl *) const ;
3669+
3670+ public:
3671+ bool isCached () const { return true ; }
3672+ };
3673+
35023674void simple_display (llvm::raw_ostream &out, ASTNode node);
35033675void simple_display (llvm::raw_ostream &out, Type value);
35043676void simple_display (llvm::raw_ostream &out, const TypeRepr *TyR);
0 commit comments