-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[silgen] When performing existential erasure, be sure that we have a … #21099
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
[silgen] When performing existential erasure, be sure that we have a … #21099
Conversation
…plus one value. This both fixes the issue in SILGenPoly that exposed the problem and additionally introduces a check in asserts builds to ensure that we catch this problem in the future. rdar://43398898
@swift-ci smoke test |
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.
Looks good, thanks Michael!
bool allowEmbeddedNSError) { | ||
// Mark the needed conformances as used. | ||
for (auto conformance : conformances) | ||
SGM.useConformance(conformance); | ||
|
||
// A wrapper around inputF that makes sure we are passed a +1 value if we are |
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.
This feels like a hack. Why not convert it to a +1 value where necessary when you actually call F?
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.
Actually isn't the +1-ness supposed to be encoded in the SGFContext? The original intent of the code was that everything produced a +1 value unless SGFContext.allowPlusZero() was true.
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.
@slavapestov I don't think it makes sense to do existential erasure on +0 value. You are producing a new value independent of the original value. That says it must be an owned value.
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 am converting it to the +1 when calling F in the caller. This is just the callee can assert that is true in a way that should optimize out in no-asserts build.
I am fine changing the code in the caller to check the SGFContext though instead of doing ensurePlusOne.
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.
Yeah, Slava's right, it seems like we should be able to pass down a +1-only context to the payload generator function instead of patching things up ad-hoc.
I fixed it the way you guys suggested (figuring out why we were not respecting the +1 context and making us obey said context): #23216. |
…plus one value.
This both fixes the issue in SILGenPoly that exposed the problem and
additionally introduces a check in asserts builds to ensure that we catch this
problem in the future.
rdar://43398898