@@ -548,6 +548,11 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
548548 IsOpaqueType : 1
549549 );
550550
551+ SWIFT_INLINE_BITFIELD_FULL (AssociatedTypeDecl, TypeDecl, 1 ,
552+ // / Whether we have computed the default type.
553+ IsDefaultDefinitionTypeComputed : 1
554+ );
555+
551556 SWIFT_INLINE_BITFIELD_EMPTY (GenericTypeDecl, TypeDecl);
552557
553558 SWIFT_INLINE_BITFIELD (TypeAliasDecl, GenericTypeDecl, 1 +1 ,
@@ -3692,24 +3697,28 @@ class AssociatedTypeDecl : public TypeDecl {
36923697 SourceLoc KeywordLoc;
36933698
36943699 // / The default definition.
3695- TypeRepr * DefaultDefinition;
3700+ TypeLoc DefaultDefinition;
36963701
36973702 // / The where clause attached to the associated type.
36983703 TrailingWhereClause *TrailingWhere;
36993704
3700- LazyMemberLoader *Resolver = nullptr ;
3701- uint64_t ResolverContextData;
3702-
37033705 friend class DefaultDefinitionTypeRequest ;
37043706
3705- public:
37063707 AssociatedTypeDecl (DeclContext *dc, SourceLoc keywordLoc, Identifier name,
37073708 SourceLoc nameLoc, TypeRepr *defaultDefinition,
37083709 TrailingWhereClause *trailingWhere);
3709- AssociatedTypeDecl (DeclContext *dc, SourceLoc keywordLoc, Identifier name,
3710- SourceLoc nameLoc, TrailingWhereClause *trailingWhere,
3711- LazyMemberLoader *definitionResolver,
3712- uint64_t resolverData);
3710+
3711+ public:
3712+ static AssociatedTypeDecl *createParsed (ASTContext &ctx, DeclContext *dc,
3713+ SourceLoc keywordLoc, Identifier name,
3714+ SourceLoc nameLoc,
3715+ TypeRepr *defaultDefinition,
3716+ TrailingWhereClause *trailingWhere);
3717+
3718+ static AssociatedTypeDecl *createDeserialized (
3719+ ASTContext &ctx, DeclContext *dc, SourceLoc keywordLoc, Identifier name,
3720+ SourceLoc nameLoc, TrailingWhereClause *trailingWhere,
3721+ LazyMemberLoader *lazyLoader, uint64_t defaultDefinitionTypeData);
37133722
37143723 // / Get the protocol in which this associated type is declared.
37153724 ProtocolDecl *getProtocol () const {
@@ -3720,15 +3729,25 @@ class AssociatedTypeDecl : public TypeDecl {
37203729 bool hasDefaultDefinitionType () const {
37213730 // If we have a TypeRepr, return true immediately without kicking off
37223731 // a request.
3723- return DefaultDefinition || getDefaultDefinitionType ();
3732+ return DefaultDefinition. getTypeRepr () || getDefaultDefinitionType ();
37243733 }
37253734
37263735 // / Retrieve the default definition type.
37273736 Type getDefaultDefinitionType () const ;
37283737
3738+ // / Retrieve the default definition type if computed, `None` otherwise.
3739+ // /
3740+ // / \Note Should only be used for dumping.
3741+ llvm::Optional<Type> getCachedDefaultDefinitionType () const ;
3742+
3743+ private:
3744+ // / Set the computed default definition type.
3745+ void setDefaultDefinitionType (Type ty);
3746+
3747+ public:
37293748 // / Retrieve the default definition as written in the source.
37303749 TypeRepr *getDefaultDefinitionTypeRepr () const {
3731- return DefaultDefinition;
3750+ return DefaultDefinition. getTypeRepr () ;
37323751 }
37333752
37343753 // / Retrieve the trailing where clause for this associated type, if any.
0 commit comments