Commit Graph

378 Commits

Author SHA1 Message Date
Doug Gregor
d07fa5ab69 Switch many callers of ClassDecl::getSuperclass() to ClassDecl::getSuperclassDecl().
ClassDecl::getSuperclass() produces a complete interface type describing the
superclass of a class, including any generic arguments (for a generic type).
Most callers only need the referenced ClassDecl, which is (now) cheaper
to compute: switch those callers over to ClassDecl::getSuperclassDecl().

Fixes an existing test for SR-5993.
2018-07-31 10:14:44 -07:00
swift-ci
7296555ad7 Merge remote-tracking branch 'origin/master' into master-next 2018-07-30 11:49:04 -07:00
Jordan Rose
2d88bb6721 Merge pull request #18081 from pitiphong-p/objc-rename-attribute
Use the custom @objc name in the available attribute when generates ObjC headers

https://bugs.swift.org/browse/SR-8231
2018-07-30 11:35:52 -07:00
swift-ci
fd7d5c86dd Merge remote-tracking branch 'origin/master' into master-next 2018-07-29 19:29:07 -07:00
Mark Lacey
ffb74a5a87 [PrintAsObjC] Replace a couple uses of getInput() with getParams(). 2018-07-29 14:27:25 -07:00
Pitiphong Phongpattranont
e006d700e0 Change from early exit to assert instead 2018-07-25 15:16:02 +07:00
Pitiphong Phongpattranont
a2c877a4f3 Rename renamedFuncDecl to renamedDecl 2018-07-25 14:07:27 +07:00
Pitiphong Phongpattranont
acd28c4915 Fallback to the name in the Attribute when found duplicated candidates 2018-07-24 13:55:50 +07:00
Pitiphong Phongpattranont
f852f3f82e Change the type of D parameter to ValueDecl 2018-07-24 08:50:23 +07:00
Pitiphong Phongpattranont
18ac6f9340 Mark the renamedFuncDecl variable as const 2018-07-24 08:49:57 +07:00
Pitiphong Phongpattranont
045fb7cd65 Fix the wrong checking condition on the case where both of them should be instance members or otherwise 2018-07-22 00:09:37 +07:00
Pitiphong Phongpattranont
16ccb19e81 Ditch the unneccessary Optional type on renamedFuncDecl variable 2018-07-21 22:13:37 +07:00
Pitiphong Phongpattranont
4661166ea1 Pass the UnqualifiedLookup::Flags::TypeLookup option when doing the Type lookup 2018-07-21 22:13:37 +07:00
Pitiphong Phongpattranont
7a9b890cc7 Rename findRenamedDecl method to printRenameForDecl 2018-07-21 22:13:30 +07:00
Pitiphong Phongpattranont
7da1f303c1 Use the custom @objc name in the Availablity attributes on classes and protocols when generates the ObjC header 2018-07-21 17:40:41 +07:00
Pitiphong Phongpattranont
12d0024188 Reserve the white spaces 2018-07-21 17:40:41 +07:00
Pitiphong Phongpattranont
d0801890ec Use the custom @objc name in the Availablity attributes when generates the ObjC header 2018-07-21 17:40:41 +07:00
swift-ci
403cb35abc Merge remote-tracking branch 'origin/master' into master-next 2018-07-20 00:29:49 -07:00
Slava Pestov
fd8a7b8d01 PrintAsObjC: Remove uses of AbstractFunctionDecl::getParameterLists() 2018-07-19 21:25:21 -07:00
swift-ci
60de11c4f0 Merge remote-tracking branch 'origin/master' into master-next 2018-07-11 19:29:17 -07:00
Jordan Rose
c8b61f990b Merge pull request #17615 from maniramezan/master
[SR-2250] Include Foundation framework instead of minimal NSObject.h
2018-07-11 19:14:49 -07:00
swift-ci
c616a40bf6 Merge remote-tracking branch 'origin/master' into master-next 2018-07-03 14:09:31 -07:00
Slava Pestov
45fb11ce3c AST: Add ExistentialLayout::getSuperclass(), rename superclass to explicitSuperclass
More groundwork for protocols with superclass constraints.
In several places we need to distinguish between existential
types that have a superclass term (MyClass & Proto) and
existential types containing a protocol with a superclass
constraint.

This is similar to how I can write 'AnyObject & Proto', or
write 'Proto1 & Proto2' where Proto1 has an ': AnyObject'
in its inheritance clause.

Note that some of the usages will be revisited later as
I do more refactoring and testing. This is just a first pass.
2018-07-02 22:06:33 -07:00
Mani Ramezan
3c824ddaa5 Include Foundation framework instead of minimal NSObject.h
This change is for preventing scenarios like https://bugs.swift.org/projects/SR/issues/SR-2250
2018-06-28 19:27:24 -04:00
Bob Wilson
1386e82e19 [master-next] Update for Clang r331155
CharSourceRange now requires the use of getBegin()
2018-05-04 18:02:50 -07:00
Huon Wilson
0516915a81 [PrintAsObjC] std::function -> llvm::function_ref for some non-escaping params. 2018-05-01 08:29:07 +10:00
Jordan Rose
d734ce800c [PrintAsObjC] Sort imports alphabetically. (#15899)
This ensures that 'Foo' always gets imported before 'Foo_Private'.
This shouldn't strictly be necessary but does end up with more
reliable results in practice.

rdar://problem/36159006
2018-04-12 20:57:42 -07:00
Doug Gregor
b2b69e8abf Rename BoundNameAliasType to NameAliasType.
NameAliasType is dead! Long live NameAliasType!
2018-03-25 21:35:17 -07:00
Doug Gregor
c43f96a855 [AST] Remove now-unused NameAliasType. 2018-03-25 21:35:16 -07:00
Doug Gregor
bde6401f5b Support BoundNameAliasType everywhere we support NameAliasType.
This doesn't have a specific effect now, because all of these places
are likely to only see NameAliasType, but it is refactoring with the
intent of eliminating NameAliasType entirely.
2018-03-25 20:46:07 -07:00
Jordan Rose
1b1a4cb22e [PrintAsObjC] Use enum_extensibility to represent @_frozen
Previously (a03c40cb2c) we assumed all Swift enums were non-frozen in
ObjC, a weird choice in retrospect. Now that we actually distinguish
frozen and non-frozen enums in Swift, we can use the
'enum_extensibility' attribute to mark them as open or closed in ObjC.

Note that this only matters for Swift libraries compiled with
-enable-resilience, i.e. those that might get a new implementation at
runtime. Everyone else is now declaring a "closed" enum, matching the
behavior in Swift.
2018-03-20 14:49:11 -07:00
Mark Lacey
85f25003ce Replace uses of getOptionalObjectType(bool &).
Instead, use the one that doesn't have a reference parameter.
2018-03-16 21:19:49 -07:00
Sho Ikeda
cea6c03eb2 [gardening] Use !empty() over size() > 0 2018-03-08 09:21:09 +09:00
Sho Ikeda
26d650292f [gardening] Use empty() over size() == 0 2018-03-05 14:43:13 +09:00
Tapan Thaker
bb6db49f80 [PrintAsObjC] Fixes [SR-6884]. Prints availability information for properties. (#14561) 2018-02-13 18:09:29 -08:00
Mark Lacey
d63bb3fc53 Remove most uses of OptionalTypeKind.
What remains are places where we are conflating optionality with
either nullability or failability.
2018-02-10 16:24:09 -08:00
Mark Lacey
be8defb29e Rename lookThroughAllAnyOptionalTypes to lookThroughAllOptionalTypes. 2018-02-05 23:59:01 -08:00
Mark Lacey
b4b66bc8e8 Replace getAnyOptionalObjectType with getOptionalObjectType. 2018-02-05 23:59:00 -08:00
Greg Parker
4953262288 Fix a build warning. (#13985)
"specified comparator type does not provide a const call operator"
2018-01-17 14:56:22 -08:00
John McCall
52bb547a7e Merge pull request #13866 from rjmccall/accessor-decl
Split AccessorDecl out from FuncDecl.  NFC.
2018-01-12 17:02:35 -05:00
John McCall
7f0f8830cd Split AccessorDecl out from FuncDecl. NFC.
This has three principal advantages:

- It gives some additional type-safety when working
  with known accessors.

- It makes it significantly easier to test whether a declaration
  is an accessor and encourages the use of a common idiom.

- It saves a small amount of memory in both FuncDecl and its
  serialized form.
2018-01-12 14:20:27 -05:00
Mark Lacey
5b7ebd7c4f IUO: Updates to PrintAsObjC to use the decl attribute for IUO.
Use the attribute to update the OptionalTypeKind used for various
decls that we print.

I added test cases to make sure we were exercising all the modified
code paths.
2018-01-11 23:48:32 -08:00
David Zarzycki
9b48b5074a [AST] Perf: Unite DictionaryType with SyntaxSugarType
1) Move existing SyntaxSugarTypes under a new subclass called UnarySyntaxSugarType.
2) Make DictionaryType subclass SyntaxSugarType.

This helps improve getDesugaredType() performance by ensuring that
ImplOrContext is stored at the same field offset in memory.

This also de-boilerplates some AST walking.
2018-01-02 15:14:07 -05:00
Jordan Rose
9a9ea6915f [PrintAsObjC] Downgrade +new unavailability to deprecation in Swift 4
The general policy has been that even if something crashes at run
time, we don't make it a hard error in Swift 4 mode (or Swift 3 mode!)
if it wasn't a hard error in Swift 4.0 (3.0). In this case, we thought
we could get away with it, and then it turns out it actually caused
some problems. (And as 2bc010681 shows, we can still make mistakes.)

This change isn't perfect because the diagnostic appears in /clients/
rather than in the module that's being compiled as Swift 4 (instead of
Swift 5). But it still means that someone who hasn't changed
/anything/ from a valid Swift 4.0 project will be able to compile
without any changes, even if they were relying on being able to call
+new when -init was unavailable for some reason.

More rdar://problem/35942058
2017-12-13 17:59:55 -08:00
Jordan Rose
7493eccaa9 [PrintAsObjC] Include a message when making +new unavailable
Another follow-up to 49c65facc9. We've seen a few people run into
this and not know what changed.

rdar://problem/35942058
2017-12-13 17:59:55 -08:00
Jordan Rose
2bc0106810 [PrintAsObjC] Reintroduce +new when reintroducing -init. (#13320)
Follow-up to 49c65facc9 to account for subclasses. An unavailable
-init makes +new unavailable, but reintroducing it in a subclass
should reintroduce +new if the root class is NSObject (where +new is
implemented).

rdar://problem/35914080
2017-12-07 15:15:43 -08:00
Rintaro Ishizaki
08ef4e324f [CMake] Add swift-syntax-generated-headers to the global dependencies 2017-12-05 17:03:12 +09:00
Nathan Hawes
3006fb9b44 Add missing DEPENDS swift-syntax-generated-headers to ensure SyntaxKind.h is generated before it's used 2017-10-31 12:57:42 -07:00
Jordan Rose
34e602b93a [PrintAsObjC] Don't define char{16,32}_t in C++-pre-11 (#12537)
Turns out libc++ already defines compatibility typedefs in this case,
and we don't care about any other C++ stdlibs on Apple platforms at
the moment.

rdar://problem/34861807
2017-10-23 10:46:01 -07:00
Jordan Rose
01add3aec1 [PrintAsObjC] Defend against macros named 'any' (#12396)
SourceKit uses a clever pragma to automatically attach an attribute to
every declaration in the file. However, the form of this pragma (clang
attribute push) uses a parenthesized list marked with 'any', which turns
out to be a name that people sometimes use for macros. Guard against this
using the push_macro pragma (originally from MSVC), under the assumption
that anyone who supports the highly-use-specific 'external_source_symbol'
attribute probably implements this more common extension. This does make
the generated header a little uglier, but it's not like it was really
pretty to begin with.

rdar://problem/34168022
2017-10-12 13:39:07 -07:00