2626#include " swift/AST/DeclContext.h"
2727#include " swift/AST/DeclNameLoc.h"
2828#include " swift/AST/FreestandingMacroExpansion.h"
29- #include " swift/AST/FunctionRefKind .h"
29+ #include " swift/AST/FunctionRefInfo .h"
3030#include " swift/AST/ProtocolConformanceRef.h"
3131#include " swift/AST/ThrownErrorDestination.h"
3232#include " swift/AST/TypeAlignments.h"
@@ -193,16 +193,16 @@ class alignas(8) Expr : public ASTAllocated<Expr> {
193193 LiteralCapacity : 32
194194 );
195195
196- SWIFT_INLINE_BITFIELD (DeclRefExpr, Expr, 2 +2 +1 +1 ,
196+ SWIFT_INLINE_BITFIELD (DeclRefExpr, Expr, 2 +3 +1 +1 ,
197197 Semantics : 2 , // an AccessSemantics
198- FunctionRefKind : 2 ,
198+ FunctionRefInfo : 3 ,
199199 IsImplicitlyAsync : 1 ,
200200 IsImplicitlyThrows : 1
201201 );
202202
203- SWIFT_INLINE_BITFIELD (UnresolvedDeclRefExpr, Expr, 2 +2 ,
203+ SWIFT_INLINE_BITFIELD (UnresolvedDeclRefExpr, Expr, 2 +3 ,
204204 DeclRefKind : 2 ,
205- FunctionRefKind : 2
205+ FunctionRefInfo : 3
206206 );
207207
208208 SWIFT_INLINE_BITFIELD (MemberRefExpr, LookupExpr, 2 ,
@@ -225,8 +225,8 @@ class alignas(8) Expr : public ASTAllocated<Expr> {
225225 NumElements : 32
226226 );
227227
228- SWIFT_INLINE_BITFIELD (UnresolvedDotExpr, Expr, 2 ,
229- FunctionRefKind : 2
228+ SWIFT_INLINE_BITFIELD (UnresolvedDotExpr, Expr, 3 ,
229+ FunctionRefInfo : 3
230230 );
231231
232232 SWIFT_INLINE_BITFIELD_FULL (SubscriptExpr, LookupExpr, 2 ,
@@ -235,12 +235,12 @@ class alignas(8) Expr : public ASTAllocated<Expr> {
235235
236236 SWIFT_INLINE_BITFIELD_EMPTY (DynamicSubscriptExpr, DynamicLookupExpr);
237237
238- SWIFT_INLINE_BITFIELD_FULL (UnresolvedMemberExpr, Expr, 2 ,
239- FunctionRefKind : 2
238+ SWIFT_INLINE_BITFIELD_FULL (UnresolvedMemberExpr, Expr, 3 ,
239+ FunctionRefInfo : 3
240240 );
241241
242- SWIFT_INLINE_BITFIELD (OverloadSetRefExpr, Expr, 2 ,
243- FunctionRefKind : 2
242+ SWIFT_INLINE_BITFIELD (OverloadSetRefExpr, Expr, 3 ,
243+ FunctionRefInfo : 3
244244 );
245245
246246 SWIFT_INLINE_BITFIELD (BooleanLiteralExpr, LiteralExpr, 1 ,
@@ -1230,12 +1230,10 @@ class DeclRefExpr : public Expr {
12301230 Type Ty = Type())
12311231 : Expr(ExprKind::DeclRef, Implicit, Ty), D(D), Loc(Loc),
12321232 implicitActorHopTarget (ActorIsolation::forUnspecified()) {
1233- Bits.DeclRefExpr .Semantics = (unsigned ) semantics;
1234- Bits.DeclRefExpr .FunctionRefKind =
1235- static_cast <unsigned >(Loc.isCompound () ? FunctionRefKind::Compound
1236- : FunctionRefKind::Unapplied);
1233+ Bits.DeclRefExpr .Semantics = (unsigned )semantics;
12371234 Bits.DeclRefExpr .IsImplicitlyAsync = false ;
12381235 Bits.DeclRefExpr .IsImplicitlyThrows = false ;
1236+ setFunctionRefInfo (FunctionRefInfo::unapplied (Loc));
12391237 }
12401238
12411239 // / Retrieve the declaration to which this expression refers.
@@ -1300,13 +1298,14 @@ class DeclRefExpr : public Expr {
13001298 DeclNameLoc getNameLoc () const { return Loc; }
13011299
13021300 // / Retrieve the kind of function reference.
1303- FunctionRefKind getFunctionRefKind () const {
1304- return static_cast <FunctionRefKind> (Bits.DeclRefExpr .FunctionRefKind );
1301+ FunctionRefInfo getFunctionRefInfo () const {
1302+ return FunctionRefInfo::fromOpaque (Bits.DeclRefExpr .FunctionRefInfo );
13051303 }
13061304
13071305 // / Set the kind of function reference.
1308- void setFunctionRefKind (FunctionRefKind refKind) {
1309- Bits.DeclRefExpr .FunctionRefKind = static_cast <unsigned >(refKind);
1306+ void setFunctionRefInfo (FunctionRefInfo refKind) {
1307+ Bits.DeclRefExpr .FunctionRefInfo = refKind.getOpaqueValue ();
1308+ ASSERT (refKind == getFunctionRefInfo () && " FunctionRefInfo truncated" );
13101309 }
13111310
13121311 static bool classof (const Expr *E) {
@@ -1506,10 +1505,9 @@ class OverloadSetRefExpr : public Expr {
15061505
15071506protected:
15081507 OverloadSetRefExpr (ExprKind Kind, ArrayRef<ValueDecl*> decls,
1509- FunctionRefKind functionRefKind , bool Implicit, Type Ty)
1508+ FunctionRefInfo functionRefInfo , bool Implicit, Type Ty)
15101509 : Expr(Kind, Implicit, Ty), Decls(decls) {
1511- Bits.OverloadSetRefExpr .FunctionRefKind =
1512- static_cast <unsigned >(functionRefKind);
1510+ setFunctionRefInfo (functionRefInfo);
15131511 }
15141512
15151513public:
@@ -1529,14 +1527,14 @@ class OverloadSetRefExpr : public Expr {
15291527 bool hasBaseObject () const ;
15301528
15311529 // / Retrieve the kind of function reference.
1532- FunctionRefKind getFunctionRefKind () const {
1533- return static_cast <FunctionRefKind>(
1534- Bits.OverloadSetRefExpr .FunctionRefKind );
1530+ FunctionRefInfo getFunctionRefInfo () const {
1531+ return FunctionRefInfo::fromOpaque (Bits.OverloadSetRefExpr .FunctionRefInfo );
15351532 }
15361533
15371534 // / Set the kind of function reference.
1538- void setFunctionRefKind (FunctionRefKind refKind) {
1539- Bits.OverloadSetRefExpr .FunctionRefKind = static_cast <unsigned >(refKind);
1535+ void setFunctionRefInfo (FunctionRefInfo refKind) {
1536+ Bits.OverloadSetRefExpr .FunctionRefInfo = refKind.getOpaqueValue ();
1537+ ASSERT (refKind == getFunctionRefInfo () && " FunctionRefInfo truncated" );
15401538 }
15411539
15421540 static bool classof (const Expr *E) {
@@ -1552,9 +1550,9 @@ class OverloadedDeclRefExpr final : public OverloadSetRefExpr {
15521550
15531551public:
15541552 OverloadedDeclRefExpr (ArrayRef<ValueDecl*> Decls, DeclNameLoc Loc,
1555- FunctionRefKind functionRefKind ,
1553+ FunctionRefInfo functionRefInfo ,
15561554 bool Implicit, Type Ty = Type())
1557- : OverloadSetRefExpr(ExprKind::OverloadedDeclRef, Decls, functionRefKind ,
1555+ : OverloadSetRefExpr(ExprKind::OverloadedDeclRef, Decls, functionRefInfo ,
15581556 Implicit, Ty),
15591557 Loc (Loc) {
15601558 }
@@ -1584,9 +1582,7 @@ class UnresolvedDeclRefExpr : public Expr {
15841582 : Expr(ExprKind::UnresolvedDeclRef, /* Implicit=*/ loc.isInvalid()),
15851583 Name (name), Loc(loc) {
15861584 Bits.UnresolvedDeclRefExpr .DeclRefKind = static_cast <unsigned >(refKind);
1587- Bits.UnresolvedDeclRefExpr .FunctionRefKind =
1588- static_cast <unsigned >(Loc.isCompound () ? FunctionRefKind::Compound
1589- : FunctionRefKind::Unapplied);
1585+ setFunctionRefInfo (FunctionRefInfo::unapplied (loc));
15901586 }
15911587
15921588 static UnresolvedDeclRefExpr *createImplicit (
@@ -1616,14 +1612,15 @@ class UnresolvedDeclRefExpr : public Expr {
16161612 }
16171613
16181614 // / Retrieve the kind of function reference.
1619- FunctionRefKind getFunctionRefKind () const {
1620- return static_cast <FunctionRefKind> (
1621- Bits.UnresolvedDeclRefExpr .FunctionRefKind );
1615+ FunctionRefInfo getFunctionRefInfo () const {
1616+ return FunctionRefInfo::fromOpaque (
1617+ Bits.UnresolvedDeclRefExpr .FunctionRefInfo );
16221618 }
16231619
16241620 // / Set the kind of function reference.
1625- void setFunctionRefKind (FunctionRefKind refKind) {
1626- Bits.UnresolvedDeclRefExpr .FunctionRefKind = static_cast <unsigned >(refKind);
1621+ void setFunctionRefInfo (FunctionRefInfo refKind) {
1622+ Bits.UnresolvedDeclRefExpr .FunctionRefInfo = refKind.getOpaqueValue ();
1623+ ASSERT (refKind == getFunctionRefInfo () && " FunctionRefInfo truncated" );
16271624 }
16281625
16291626 DeclNameLoc getNameLoc () const { return Loc; }
@@ -1901,19 +1898,18 @@ class UnresolvedMemberExpr final
19011898 bool implicit)
19021899 : Expr(ExprKind::UnresolvedMember, implicit), DotLoc(dotLoc),
19031900 NameLoc (nameLoc), Name(name) {
1904- // FIXME: Really, we should be setting this to `FunctionRefKind::Compound`
1905- // if `NameLoc` is compound, but this would be a source break for cases like
1901+ // FIXME(FunctionRefInfo): Really, we should be passing `nameLoc` directly,
1902+ // allowing the FunctionRefInfo to be treated as compound. This would
1903+ // require us to enable IUOs for compound names, e.g:
19061904 // ```
19071905 // struct S {
19081906 // static func makeS(_: Int) -> S! { S() }
19091907 // }
19101908 //
19111909 // let s: S = .makeS(_:)(0)
19121910 // ```
1913- // Instead, we should store compound-ness as a separate bit from applied/
1914- // unapplied.
1915- Bits.UnresolvedMemberExpr .FunctionRefKind =
1916- static_cast <unsigned >(FunctionRefKind::Unapplied);
1911+ setFunctionRefInfo (
1912+ FunctionRefInfo::unapplied (DeclNameLoc (nameLoc.getBaseNameLoc ())));
19171913 }
19181914
19191915 DeclNameRef getName () const { return Name; }
@@ -1926,16 +1922,17 @@ class UnresolvedMemberExpr final
19261922 SourceLoc getEndLoc () const { return NameLoc.getSourceRange ().End ; }
19271923
19281924 // / Retrieve the kind of function reference.
1929- FunctionRefKind getFunctionRefKind () const {
1930- return static_cast <FunctionRefKind> (
1931- Bits.UnresolvedMemberExpr .FunctionRefKind );
1925+ FunctionRefInfo getFunctionRefInfo () const {
1926+ return FunctionRefInfo::fromOpaque (
1927+ Bits.UnresolvedMemberExpr .FunctionRefInfo );
19321928 }
19331929
19341930 // / Set the kind of function reference.
1935- void setFunctionRefKind (FunctionRefKind refKind) {
1936- Bits.UnresolvedMemberExpr .FunctionRefKind = static_cast <unsigned >(refKind);
1931+ void setFunctionRefInfo (FunctionRefInfo refKind) {
1932+ Bits.UnresolvedMemberExpr .FunctionRefInfo = refKind.getOpaqueValue ();
1933+ ASSERT (refKind == getFunctionRefInfo () && " FunctionRefInfo truncated" );
19371934 }
1938-
1935+
19391936 static bool classof (const Expr *E) {
19401937 return E->getKind () == ExprKind::UnresolvedMember;
19411938 }
@@ -2627,9 +2624,7 @@ class UnresolvedDotExpr : public Expr {
26272624 : Expr(ExprKind::UnresolvedDot, Implicit), SubExpr(subexpr),
26282625 DotLoc (dotloc), NameLoc(nameloc), Name(name),
26292626 OuterAlternatives(outerAlternatives) {
2630- Bits.UnresolvedDotExpr .FunctionRefKind =
2631- static_cast <unsigned >(NameLoc.isCompound () ? FunctionRefKind::Compound
2632- : FunctionRefKind::Unapplied);
2627+ setFunctionRefInfo (FunctionRefInfo::unapplied (nameloc));
26332628 }
26342629
26352630 static UnresolvedDotExpr *createImplicit (
@@ -2692,13 +2687,14 @@ class UnresolvedDotExpr : public Expr {
26922687 }
26932688
26942689 // / Retrieve the kind of function reference.
2695- FunctionRefKind getFunctionRefKind () const {
2696- return static_cast <FunctionRefKind> (Bits.UnresolvedDotExpr .FunctionRefKind );
2690+ FunctionRefInfo getFunctionRefInfo () const {
2691+ return FunctionRefInfo::fromOpaque (Bits.UnresolvedDotExpr .FunctionRefInfo );
26972692 }
26982693
26992694 // / Set the kind of function reference.
2700- void setFunctionRefKind (FunctionRefKind refKind) {
2701- Bits.UnresolvedDotExpr .FunctionRefKind = static_cast <unsigned >(refKind);
2695+ void setFunctionRefInfo (FunctionRefInfo refKind) {
2696+ Bits.UnresolvedDotExpr .FunctionRefInfo = refKind.getOpaqueValue ();
2697+ ASSERT (refKind == getFunctionRefInfo () && " FunctionRefInfo truncated" );
27022698 }
27032699
27042700 static bool classof (const Expr *E) {
0 commit comments