-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Align isolated conformances with the current proposal #79983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
0e873e7
71a516b
4f24761
3837661
0cfa048
c58e22f
6eb7905
836fcbe
c7fd48a
01b2789
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,6 +240,14 @@ class alignas(1 << DeclAlignInBits) ProtocolConformance | |
/// Otherwise a new conformance will be created. | ||
ProtocolConformance *getCanonicalConformance(); | ||
|
||
/// Determine the actor isolation of this conformance. | ||
ActorIsolation getIsolation() const; | ||
|
||
/// Determine whether this conformance is isolated to an actor. | ||
bool isIsolated() const { | ||
return getIsolation().isActorIsolated(); | ||
} | ||
|
||
/// Return true if the conformance has a witness for the given associated | ||
/// type. | ||
bool hasTypeWitness(AssociatedTypeDecl *assocType) const; | ||
|
@@ -529,6 +537,7 @@ class NormalProtocolConformance : public RootProtocolConformance, | |
{ | ||
friend class ValueWitnessRequest; | ||
friend class TypeWitnessRequest; | ||
friend class ConformanceIsolationRequest; | ||
|
||
/// The protocol being conformed to. | ||
ProtocolDecl *Protocol; | ||
|
@@ -546,6 +555,9 @@ class NormalProtocolConformance : public RootProtocolConformance, | |
/// NominalTypeDecl that declared the conformance. | ||
DeclContext *Context; | ||
|
||
/// The global actor isolation for this conformance, if there is one. | ||
TypeExpr *globalActorIsolation = nullptr; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this null most of the time? You can use a single bit to record the presence of this attribute, while storing the actual value in the request evaluator cache only when present. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's NULL most of the time. We could have a put and put it an ASTContext-managed side table, since it needs to be there at the point when the NormalProtocolConformance is created. |
||
|
||
NormalProtocolConformance *ImplyingConformance = nullptr; | ||
|
||
/// The mapping of individual requirements in the protocol over to | ||
|
@@ -570,6 +582,9 @@ class NormalProtocolConformance : public RootProtocolConformance, | |
|
||
void resolveLazyInfo() const; | ||
|
||
/// Set up global actor isolation for this conformance. | ||
void setGlobalActorIsolation(Type globalActorType); | ||
|
||
public: | ||
NormalProtocolConformance(Type conformingType, ProtocolDecl *protocol, | ||
SourceLoc loc, DeclContext *dc, | ||
|
@@ -593,6 +608,7 @@ class NormalProtocolConformance : public RootProtocolConformance, | |
Bits.NormalProtocolConformance.HasComputedAssociatedConformances = false; | ||
Bits.NormalProtocolConformance.SourceKind = | ||
unsigned(ConformanceEntryKind::Explicit); | ||
globalActorIsolation = options.getGlobalActorIsolationType(); | ||
} | ||
|
||
/// Get the protocol being conformed to. | ||
|
@@ -634,7 +650,8 @@ class NormalProtocolConformance : public RootProtocolConformance, | |
void setInvalid() { Bits.NormalProtocolConformance.IsInvalid = true; } | ||
|
||
ProtocolConformanceOptions getOptions() const { | ||
return ProtocolConformanceOptions(Bits.NormalProtocolConformance.Options); | ||
return ProtocolConformanceOptions(Bits.NormalProtocolConformance.Options, | ||
globalActorIsolation); | ||
} | ||
|
||
/// Whether this is an "unchecked" conformance. | ||
|
@@ -669,11 +686,6 @@ class NormalProtocolConformance : public RootProtocolConformance, | |
return getOptions().contains(ProtocolConformanceFlags::Preconcurrency); | ||
} | ||
|
||
/// Whether this is an isolated conformance. | ||
bool isIsolated() const { | ||
return getOptions().contains(ProtocolConformanceFlags::Isolated); | ||
} | ||
|
||
/// Retrieve the location of `@preconcurrency`, if there is one and it is | ||
/// known. | ||
SourceLoc getPreconcurrencyLoc() const { return PreconcurrencyLoc; } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this ought to be a TypeLoc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could. We get a TypeExpr out of the CustomAttr itself, so we can either stick that into a TypeLoc or keep it as-is. This way it's only a single pointer in ConformanceAttributes vs. the two-pointer TypeLoc, so I didn't do it.