-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ParseableInterface] Standardize printing for accessors #20250
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 all commits
a1c23be
a64a4e1
dd163f0
9048954
1345310
a20c31a
ea3e02b
ac249e6
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 |
---|---|---|
|
@@ -3019,21 +3019,29 @@ ModuleFile::getDeclCheckedImpl(DeclID DID) { | |
|
||
configureStorage(var, opaqueReadOwnership, | ||
readImpl, writeImpl, readWriteImpl, accessors); | ||
|
||
if (auto accessLevel = getActualAccessLevel(rawAccessLevel)) { | ||
var->setAccess(*accessLevel); | ||
} else { | ||
auto accessLevel = getActualAccessLevel(rawAccessLevel); | ||
if (!accessLevel) { | ||
error(); | ||
return nullptr; | ||
} | ||
|
||
var->setAccess(*accessLevel); | ||
|
||
if (var->isSettable(nullptr)) { | ||
if (auto setterAccess = getActualAccessLevel(rawSetterAccessLevel)) { | ||
var->setSetterAccess(*setterAccess); | ||
} else { | ||
auto setterAccess = getActualAccessLevel(rawSetterAccessLevel); | ||
if (!setterAccess) { | ||
error(); | ||
return nullptr; | ||
} | ||
var->setSetterAccess(*setterAccess); | ||
|
||
// If we have a less-accessible setter, honor that by adding the | ||
// setter access attribute. | ||
if (*setterAccess < *accessLevel) { | ||
AddAttribute( | ||
new (ctx) SetterAccessAttr(SourceLoc(), SourceLoc(), | ||
*setterAccess, /*implicit*/true)); | ||
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. This is unfortunate. I wish I had noticed it at the time, but it's weird to be different from the regular access. 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. I agree that it's unfortunate, but I'm not sure how else to preserve this. The rest of the compiler assumes setter access is determined by the presence of this attribute. If there's a better way than synthesizing this here, I'm happy to change it. |
||
} | ||
} | ||
|
||
if (isImplicit) | ||
|
@@ -3044,6 +3052,10 @@ ModuleFile::getDeclCheckedImpl(DeclID DID) { | |
if (var->getOverriddenDecl()) | ||
AddAttribute(new (ctx) OverrideAttr(SourceLoc())); | ||
|
||
// Add the @_hasStorage attribute if this var has storage. | ||
if (var->hasStorage()) | ||
AddAttribute(new (ctx) HasStorageAttr(/*isImplicit:*/true)); | ||
|
||
break; | ||
} | ||
|
||
|
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.
@rjmccall This patch introduces a
@_hasStorage
attribute that allows us to break an ambiguity in parseable interfaces.The mapping we've settled on is an understanding that
maps to
and
maps to
With that in mind, is this mapping correct?
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.
You should be able to rename the
@_sil_stored
attribute for this purpose.If you're changing this, could you change it to list/expect all the public accessors, i.e. including
modify
and (eventually)_read
? You might need to (1) move the logic for deciding the opaque accessors into Sema and then (2) changeStorageImplInfo
to store that bitset.Uh oh!
There was an error while loading. Please reload this page.
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.
I'm not sure how to handle
_modify
and_read
if@_hasStorage
is provided. Should they diagnose?What are the semantics of
@sil_stored var x: T { get set }
vs. just@sil_stored var x: T
? Or for@sil_stored let x: T { get }
vs. just@sil_stored let x: T
?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.
Currently it declares that the accessors are actually available. I'm not sure that's important to know in SIL. I do think there's a strong argument for it being useful to unambiguously list out the available opaque accessors, but it should be the full set, not just
{get set}
and then inferringmodify
andread
and so on. However, to express that properly, you might have to change the representation a bit.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.
I'm going to do this in a future patch, because testing parseable interfaces is currently blocked on this representational change. For now, there's a loud FIXME explaining how it should eventually work.
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.
Sounds good.