Commit Graph

7 Commits

Author SHA1 Message Date
Saleem Abdulrasool
bc27395838 Inputs: sprinkle _Null_unspecified to silence nullability-completness
When trying to figure out errors from an import failure, the nullability
completeness warnings would clutter the output making it difficult to
identify the errors.  Sprinkle the declaarations with
`_Null_unspecified` to maintain the current nullability semantics and
silence the warnings.  NFC.
2018-06-11 09:23:22 -07:00
Doug Gregor
24b96a7480 Delay import-as-member resolution even without an explicit swift_name.
When forming the Swift name lookup tables, import-as-member'd
declarations can precede the declaration of the context into which
they'll be imported as a member. In such cases, we already had logic
to delay the resolution until the end of the model (when the context
must be complete).

However, we would only delay when there is a swift_name attribute on
the declaration, which is... conceptually correct. If the swift_name
exists but is versioned (e.g., it is present only for Swift 4+), and
we're building before the swift_name took effect (e.g., in Swift 3
mode), the swift_name is buried under a "versioned" attribute in the
Clang AST. Therefore, we would end up dropping the declaration from
the name lookup table, which almost doesn't matter, except...

Serialization records the newest names for such declarations (e.g.,
Swift 4+ name in this case), so deserialization would fail to find the
declaration that had been dropped, causing a crash.

Eliminate the "optimization" that looks for the swift_name attribute
before delaying the resolution of such a declaration, so we'll visit
these later. Fixes rdar://problem/39115605.
2018-04-03 11:26:05 -07:00
Slava Pestov
1ed2cf09df AST: Don't find non-objc members with dynamic lookup
This can come up when we use import-as-member to turn top-level functions
into methods in an @objc class. Previously dynamic lookup would find
these, causing a SILGen crash.

Fixes <rdar://problem/36492980>.
2018-01-18 22:52:54 -08:00
Slava Pestov
dfdd3a795d SILGen: Fix bug with NSString import-as-member globals
This is not really the right fix if we want to have physically
addressed lvalues support bridging in general, but doing so
requires adding a new LValue component type and doing a bunch
more refactoring, so just hack in a narrow fix for now since
it only seems to occur in one case.

Fixes <rdar://problem/34913892>.
2017-10-16 19:22:30 -07:00
Doug Gregor
1255a5cdb9 [Clang importer] Make sure an unavailable superclass init doesn't override an available import-as-member-init.
More generally, an unavailable initializer shouldn't stomp on an
available initializer, because it's possible that (for example) a
designated initializer will be unavailable but a factory initializer
will be available, so one still construct objects of that type.
Fixes rdar://problem/26238032.
2016-05-20 09:39:57 -07:00
Doug Gregor
138bbe2167 [Clang importer] Delay resolution of import-as-member declarations when needed.
It's possible for swift_name to make a global declaration into a
member of another entity that has not been seen yet. In such cases,
delay resolution until the end of the translation unit (module). Fixes
the rest of rdar://problem/25502497.
2016-04-05 00:03:36 -07:00
Doug Gregor
398d216eca [Clang importer] Always pass an effective context to importDeclContextOf.
Some of the callers to importDeclContextOf could and should have
passed an effective context, but didn't, so (e.g.) an enum defined in
C couldn't be mapped to a nested type in Swift. Eliminate the
single-argument importDeclContextOf honeypot so we remember to pass
down the effective Clang context. Fixes rdar://problem/25502497.
2016-04-04 15:18:37 -07:00