Commit Graph

4 Commits

Author SHA1 Message Date
Robert Widmann
c9b316433a Correct the DeclContext Used For 'super.init()' Synthesis
When a subclass inherits from a superclass that declares a no-args
desginated initializer and no other visible inits, the subclass may
elide calls to 'super.init()'. The way this was enforced was by looking
into the superclass *from the subclass' init*, not from the subclass.
This ensured that not only would we get results for initializers, we'd
get results for initializers that were actually _callable_ from the
subclass.

The changes in apple/swift#33515 accidentally swapped the decl context
here, which caused this lookup to start returning additional results.
In that case, we consider it ambiguous as to which designated
initializer we should synthesize, and so we bail.

The net result is DI errors where there previously were none. Let's put
this back in order.

rdar://67560590, rdar://67686660, rdar://67690116, SR-13427
2020-08-24 16:12:13 -07:00
Jordan Rose
85e84a85ef DI: Handle cross-module initializers for empty structs in pre-Swift-5
These also have to delegate to another initializer even though there
are no stored properties to initialize.
2017-11-10 14:10:14 -08:00
Jordan Rose
8bf0b0c010 [test] Add a cross-module struct initializer test with private fields 2017-11-10 11:25:14 -08:00
Jordan Rose
14198a360c Treat cross-module struct initializers as delegating in Swift 5
(and when the struct in question is non-fixed-layout, which was
already implemented)

This ensures that these initializers are never fieldwise in Swift 5
mode, which makes it safe for library authors to add new fields.
2017-11-10 10:59:24 -08:00