Skip to content

[Property Wrappers] Only re-write assign_by_wrapper to assignment if all fields have been initialized. #31248

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

Merged
merged 1 commit into from
Apr 24, 2020

Conversation

hborla
Copy link
Member

@hborla hborla commented Apr 23, 2020

Otherwise, the wrapped property's setter will be called with the potential to access uninitialized memory via observers.

Resolves: rdar://problem/60832285, rdar://problem/58312953
Resolves: SR-12341

@hborla hborla requested a review from slavapestov April 23, 2020 23:15
@hborla
Copy link
Member Author

hborla commented Apr 23, 2020

@swift-ci please smoke test

@hborla
Copy link
Member Author

hborla commented Apr 23, 2020

@swift-ci please test source compatibility

1 similar comment
@hborla
Copy link
Member Author

hborla commented Apr 24, 2020

@swift-ci please test source compatibility

// Only re-write assign_by_wrapper to assignment if all fields have been
// initialized.
if (isa<AssignByWrapperInst>(Use.Inst) &&
getAnyUninitializedMemberAtInst(Use.Inst, 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you still need the isFullyUninitialized check above? Unless I'm missing something, it seems like "property wrapper is uninitialized" would be a special case of "any field uninitialized".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That case is still needed for non-property-wrapped properties

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like we need to use assign_by_wrapper for everything then, but maybe not in this PR :-)

@hborla hborla force-pushed the property-wrapper-di branch from 6cb305c to 3aabdb5 Compare April 24, 2020 18:46
@hborla
Copy link
Member Author

hborla commented Apr 24, 2020

@swift-ci please smoke test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants