Commit Graph

34 Commits

Author SHA1 Message Date
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
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Michael Ilseman
9d76ce983e [Import as Member] Fix oversight where we skip getter validation.
In the code that makes sure to pair up getters/setters only from the
same top level module, we were accidentally skipping the final
validity checks (e.g. do the number of parameters line up). This fixes
that.
2016-06-30 18:34:29 -07:00
Jordan Rose
2fa3da4089 Drop the notion of "alias" names for CF types.
Previously we imported a Core Foundation type "CCFooRef" as "CCFoo",
but also provided a typealias "CCFooRef". In Swift 3, we decided to
mark "CCFooRef" unavailable to force developers to consistently use
"CCFoo". Now that we have infrastructure to mark /all/ renamed
declarations as unavailable, just use that to track the renaming,
i.e. pretend that "CCFooRef" was the "Swift 2" name for the type.

This doesn't change the conflict resolution behavior: if there's
another name "CCFoo" in the same module, the CF type will be
imported as just "CCFooRef".

Groundwork cleanup for rdar://problem/26347297, which notes that our
import-as-member fix-its use the "Ref" names rather than the short
names.
2016-05-19 13:21:47 -07:00
Doug Gregor
1ddad6bd59 test/IDE/infer_import_as_member.swift requires Objective-C interop 2016-05-06 22:41:44 -07:00
Michael Ilseman
667615307c [Import as Member] Skip needless prefix words.
When adding a prefix to the first argument of an initializer, skip
needless leading words such as "With" or "CF".
2016-05-06 14:50:58 -07:00
Michael Ilseman
0c011c328c Merge pull request #2170 from milseman/coregraphics
[Import as member] Don't pair up get/set pairs from other modules
2016-04-27 07:00:00 -07:00
Doug Gregor
2477206ed4 [Clang importer] Mark discardableResult attribute "implicit".
The Clang importer implicitly synthesizes @discardableResult for
nearly all imported functions. Printing this attribute in the
generated interface leads to a lot of noise. Mark it as implicit so we
don't print it.
2016-04-26 14:48:39 -07:00
Michael Ilseman
08ac432d3c [Import as member] Don't pair up get/set pairs from other modules
While inferring get/set, we paired them up even when one of them was
available through a custom objc header (e.g. a private
header). Instead, fail to pair them up. Test case added.
2016-04-13 13:08:16 -07:00
Trent Nadeau
8a55e428f4 Imported C decls w/o warn_unused_result get @discardableResult 2016-04-13 00:39:07 +00:00
Jordan Rose
bc83940301 Make pointer nullability explicit using Optional.
Implements SE-0055: https://github.com/apple/swift-evolution/blob/master/proposals/0055-optional-unsafe-pointers.md

- Add NULL as an extra inhabitant of Builtin.RawPointer (currently
  hardcoded to 0 rather than being target-dependent).
- Import non-object pointers as Optional/IUO when nullable/null_unspecified
  (like everything else).
- Change the type checker's *-to-pointer conversions to handle a layer of
  optional.
- Use 'AutoreleasingUnsafeMutablePointer<NSError?>?' as the type of error
  parameters exported to Objective-C.
- Drop NilLiteralConvertible conformance for all pointer types.
- Update the standard library and then all the tests.

I've decided to leave this commit only updating existing tests; any new
tests will come in the following commits. (That may mean some additional
implementation work to follow.)

The other major piece that's missing here is migration. I'm hoping we get
a lot of that with Swift 1.1's work for optional object references, but
I still need to investigate.
2016-04-11 20:06:38 -07:00
Michael Ilseman
151a19d3b8 [Import as member] Fixes to apinotes and tests
Fixes and clarifies a few API notes, and adds some test cases showing
current SILGen issues.
2016-04-11 11:31:12 -07:00
Michael Ilseman
427bf752a4 [Import as member] Perform checks on get-only property inference
Fixes a bug where we weren't performing enough checks on inferred
computed properties that did not have a pair-ed up setter.
2016-04-06 11:03:18 -07:00
Michael Ilseman
2eda983846 [Import as member] Don't create empty Identifiers
Instead of creating empty Identifiers for empty parameter labels,
create null ones. This fixes issues where we meant to infer wildcard
labels.
2016-04-04 15:46:38 -07:00
Michael Ilseman
bb43d88792 [Import as member] Bring up to date with fixes from master 2016-03-23 17:02:03 -07:00
Michael Ilseman
216847bcb9 [Import as member] Update tests to reflect ToT changes 2016-03-23 14:06:33 -07:00
Michael Ilseman
eab9f975f7 [Import as member] Fix test case to test class importing 2016-03-11 13:50:46 -08:00
Michael Ilseman
2fc931494e [Import as member] Desugar to find the effective Clang decl context.
Adds incremental de-sugaring to any non-CF typedefs we find in our
types when trying to determine the effective DC. Additionally, cleans
up some logic and allows us to fail earlier on types we cannot
possibly extend.
2016-03-10 16:42:47 -08:00
Michael Ilseman
c494f2478a [Import as member] Extend 'Mutable' skipping to method inference 2016-03-10 13:27:44 -08:00
Michael Ilseman
de913b3512 [Import as member] Ignore all case for unique-concat-ing labels 2016-03-10 12:49:30 -08:00
Michael Ilseman
3dbbd69912 [Import as member] Special case 'Mutable' types
Recognize the special word Mutable in type names and other matches, so
as to import them onto the mutable type despite word re-ordering.
2016-03-10 11:55:38 -08:00
Michael Ilseman
594cf05331 [Import as member] Omit needless words
This hooks up omitNeedlessWords to import as member.

Unfortunately, we are now left straddling different approaches to
handling our strings, I'll be refactoring that soon.
2016-03-10 11:21:59 -08:00
Michael Ilseman
81f16c311a [Import as member] Skip globals whose names begin with underscore 2016-03-09 15:40:11 -08:00
Michael Ilseman
6757d2a361 [Import as member] Drop redundancies when forming new names 2016-03-09 15:21:55 -08:00
Michael Ilseman
3c690d422d [Import as method] Create an empty tuple first parameter
For function that we are importing as init, if there's dangling words
after the "Create" or "Make", we move them onto the first argument
label. This introduces the creation of an empty tuple parameter when
that init has no arguments.
2016-03-09 15:20:04 -08:00
Michael Ilseman
32faa62502 [Import as member] Lower case initialisms 2016-03-09 14:26:43 -08:00
Michael Ilseman
ff2db64b6f [Clang importer] Infer import as member name uniquing
In many contexts we may end up concatinating strings which introduce
redundancy in the resulting names. This uniques them.
2016-03-08 18:25:26 -08:00
Michael Ilseman
bbe1f7a0a5 [Clang importer] Extra correctness checks for inferring as properties.
Introduces validToImportAsProperty, which has to perform extra
checking the make sure that a get/set pair are compatible with import
as a property. This includes matching up 'self' parameters, matching
get's return type with the set's argument type, etc. Includes more
extensive tests.
2016-03-08 16:35:30 -08:00
Michael Ilseman
f96b8d64f7 [Clang importer] Infer init: move extra words onto first parameter 2016-03-07 17:55:13 -08:00
Michael Ilseman
73f7fd2eb6 [Clang importer] Infer get-only properties and static properties.
Expands support for inference of computed properties, whether instance
or static, to include get-only. Adds test cases for both inference and
manual annotation for static computed properties.
2016-03-07 16:51:34 -08:00
Michael Ilseman
c39aebce24 [Clang importer] Infer static properties and methods
Adds inference support for static properties and methods, requiring us
to accurately do longest-prefix typename searches.

Tests cases included.
2016-03-07 16:36:59 -08:00
Michael Ilseman
3b8f498324 [Clang importer] Lower camel-case inferred names 2016-03-07 10:50:08 -08:00
Michael Ilseman
ff03498797 [Clang importer] Hook up inference system
Import as member inference hooked up, though not producing the final
results we want, yet.

Basic test case included.
2016-03-07 10:37:34 -08:00