Skip to content

Conversation

@hborla
Copy link
Member

@hborla hborla commented Dec 24, 2020

  • When creating the assign_by_wrapper instruction, substitute generic arguments in the setter type before emitting code to capture the base object. Otherwise, the setter would be incorrectly applied to the address of self instead of loading the value if self is a generic type and the setter is nonmutating.
  • Check for load instructions to ignore in LifetimeChecker::shouldEmitError in order to avoid incorrectly recording a non-erroneous location as erroneous.

These changes correct a compiler crash that occurred when a generic type has a property wrapper with a nonmutating setter that is re-assigned in the initializer, e.g.

struct S<T> {
  @State var value: Int?

  init() {
    value = 10
  }
}

This also allows out-of-line initialization via wrapped value when a struct contains a reference type property wrapper.

Resolves: rdar://67445345
Resolves: rdar://66561517

the setter type before attempting to emit a load in the case where
the setter is nonmutating and must capture self by value.
is in an init or if the wrapped var is a local variable.
LifetimeChecker::shouldEmitError in order to avoid incorrectly
populating EmittedErrorLocs when no error is emitted.

This fixes a few corner cases where DI would error out or crash
while assigning to a wrapped property with a nonmutating setter.
@hborla
Copy link
Member Author

hborla commented Dec 24, 2020

@swift-ci please test source compatibility

1 similar comment
@hborla
Copy link
Member Author

hborla commented Jan 5, 2021

@swift-ci please test source compatibility

@hborla
Copy link
Member Author

hborla commented Jan 5, 2021

@swift-ci please smoke test

@hborla hborla marked this pull request as ready for review January 5, 2021 17:11
@hborla hborla requested a review from slavapestov January 5, 2021 17:11
@hborla
Copy link
Member Author

hborla commented Jan 6, 2021

@swift-ci please test source compatibility release

1 similar comment
@hborla
Copy link
Member Author

hborla commented Jan 7, 2021

@swift-ci please test source compatibility release

@hborla
Copy link
Member Author

hborla commented Jan 8, 2021

@swift-ci please smoke test

@hborla
Copy link
Member Author

hborla commented Jan 9, 2021

@swift-ci please smoke test macOS platform

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