Commit Graph

2 Commits

Author SHA1 Message Date
Erik Eckstein
a263263f9e DefiniteInitialization: correctly handle implicit closures in initializers of derived classes.
Support for implicit closures was already added in c452e4cc13:

    init() {
      bool_member1 = false
      bool_member2 = false || bool_member1 // implicit closure
    }

But this didn't work for initializers of derived classes.

rdar://66420045
2021-07-06 13:12:46 +02:00
Erik Eckstein
c452e4cc13 DefiniteInitialization: correctly handle implicit closures.
Correctly handle implicit closures in initializers, e.g. with boolean operators:

init() {
  bool_member1 = false
  bool_member2 = false || bool_member1 // implicit closure
}

The implicit closure ('bool_member1' at the RHS of the || operator) captures the whole self, but only uses 'bool_member1'.
If the whole captured 'self' is considered as use, we would get a "'self.bool_member2' not initialized" error at the partial_apply.
Therefore look into the body of the closure and only add the actually used members.

rdar://66420045
2021-01-07 23:46:50 +01:00