Commit Graph

13 Commits

Author SHA1 Message Date
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
405b641246 ClangImporter: Synthesize typealiases instead of relying on associated type inference
Right now the ClangImporter relies on Sema to synthesize typealiases
in some cases, which doesn't work if a Sema instance is not available,
for example when the ClangImporter is asked to import a declaration
while deserializing SIL during optimization.

Begin addressing this by synthesizing typealiases for the following
conformances:

- ExpressibleByArrayLiteral.ArrayLiteralElement while importing
  OptionSets.

- RawRepresentable.RawValue while importing raw-valued enums.

- ObjectiveCBridgeable._ObjectiveCType while importing bridged
  newtypes.

Until further changes land, this is mostly NFC, except for a change
in generated interface printing where the new typealiases are now
explicitly shown.

Note that non-bridged newtypes whose raw type is ObjectiveCBridgeable
still rely on associated type inference, because the ClangImporter
cannot safely "copy" the _ObjectiveCType typealias from the raw type
to the newtype, for various reasons mostly having to do with
circularity. Subsequent patches will address this, in a rather novel
fashion that will shock you.
2017-09-07 00:30:44 -07:00
Doug Gregor
940af98e4a [Clang importer] Synthesize Element typealias for OptionSet types.
Rather than requiring associated type witness inference to go and
figure out the Element type from the other witnesses for imported
OptionSet types, synthesize the typealias directly in the
importer. This is a simplification and a performance optimization.
2017-04-13 15:49:34 -07:00
Doug Gregor
3e5b191ad9 [Clang importer] Synthesize RawValue typealias for RawRepresentable.
Rather than requiring associated type witness inference to go and
figure out the RawValue type from the rawValue witnesses for imported,
RawRepresentable types, synthesize the typealias directly in the
importer. This is a simplification and a performance optimization.
2017-04-13 15:49:34 -07:00
Jordan Rose
1432f84929 [ASTPrinter] Stop skipping unavailable-in-Swift-version decls. (#8181)
We already have an option to skip /all/ unavailable decls. Singling
out the ones that are specifically unavailable-in-Swift just makes
testing harder.

This will not affect interface generation in Xcode, which sets that
option to skip all unavailable decls.
2017-03-20 11:48:50 -07:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
Jordan Rose
258a0ade12 [APINotes] Protocols cannot use import-as-member. (#4482)
We could support this in the future but right now it's causing problems.
There's also a potential ambiguity issue here where a protocol and class
could have the same name.

In addition to updating the importer, remove the two entries from the
CryptoTokenKit API notes that were trying to use this feature.

rdar://problem/27990168
2016-08-24 16:02:28 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -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
Joe Groff
e248f83df9 Fix up some more non-prototyped declarations with swift_names.
This is now diagnosed on the Clang side.
2016-05-18 16:05:51 -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
Doug Gregor
f86ea9d0dd Split out the parts of import-as-member tests that actually require Objective-C interoperability. 2016-04-04 15:18:37 -07:00