Commit Graph

1616 Commits

Author SHA1 Message Date
John McCall
9022b5152f Rename accessor kinds from IsGetter -> IsGet, etc.
Introduce some metaprogramming of accessors and generally prepare
for storing less-structured accessor lists.

NFC except for a change to the serialization format.
2018-06-14 17:08:55 -04:00
swift-ci
526de1f08d Merge remote-tracking branch 'origin/master' into master-next 2018-06-14 00:28:56 -07:00
Pavel Yaskevich
2be766dd35 Merge pull request #17164 from xedin/rdar-39849926
[ClangImporter] Forward generic parameters while importing generic @c…
2018-06-14 00:10:35 -07:00
swift-ci
09ffbea54b Merge remote-tracking branch 'origin/master' into master-next 2018-06-13 21:28:57 -07:00
Slava Pestov
296ce3f312 AST: Remove hack-around for getInterfaceType() on ParamDecl returning InOutType
Most callers did not want the InOutType here, and checked
the ParamDecl's flags instead.
2018-06-13 15:38:52 -07:00
Pavel Yaskevich
1f3714f264 [ClangImporter] Forward generic parameters to renamed typealias
While trying to import declaration which requires renaming forward
generic parameters (if any) to newly created typealias.
2018-06-13 14:59:47 -07:00
Pavel Yaskevich
094949a461 [ClangImporter] Forward generic parameters while importing generic @compatibility_alias
When importing @compatibility_alias declarations check if underlying declaration
is generic and if so, forward generic environment and generic parameters (if any)
to newly created typealias declaration, otherwise there is going to be a mismatch
between type associated with typealias and its declaration which leads to crashes.

Resolves: rdar://problem/39849926
2018-06-13 14:59:34 -07:00
swift-ci
aabdb29b50 Merge remote-tracking branch 'origin/master' into master-next 2018-06-12 17:29:28 -07:00
swift-ci
39cd2f93be Merge pull request #17127 from CodaFi/liliput 2018-06-12 17:20:07 -07:00
Bob Wilson
c3e02955bb [master-next] Adjust for VersionTuple moving from clang to llvm.
LLVM r334399 (and related Clang changes) moved clang::VersionTuple to
llvm::VersionTuple. Update Swift to match.

Patch by Jason Molenda.
rdar://problem/41025046
2018-06-12 16:44:11 -07:00
Bob Wilson
796122fa45 Merge remote-tracking branch 'origin/master' into master-next 2018-06-12 15:06:47 -07:00
Jordan Rose
a6ae2d7742 Hack: Force UIEdgeInsets.zero to always come from the SDK (#17122)
...instead of relying on the one in the overlay in pre-4.2 versions of
Swift. This caused crashes in deserialization, which (deliberately)
doesn't respect availability.

There are three changes here:

- Remove UIEdgeInsets.zero and UIOffset.zero from the UIKit overlay.
- Always use the 4.2 name for UIEdgeInsetsZero and UIOffsetZero from
  the underlying UIKit framework. (This is the nested name.)
- Ignore the unavailability messages for those two constants in
  pre-4.2 Swift, since we're now relying on them being present.

The latter two, the compiler changes, can go away once UIKit's API
notes no longer specify different pre-4.2 behavior, but meanwhile we
need to keep compatibility with the SDKs released in Xcode 10b1.

https://bugs.swift.org/browse/SR-7879
2018-06-12 13:40:23 -07:00
Robert Widmann
26d2795efc Excise simpler uses of getInput 2018-06-11 17:29:29 -07:00
swift-ci
9b3cec17d6 Merge remote-tracking branch 'origin/master' into master-next 2018-06-07 00:09:42 -07:00
Slava Pestov
c968a2014a Fix a couple of nits 2018-06-06 22:55:01 -07:00
swift-ci
ce158d0650 Merge remote-tracking branch 'origin/master' into master-next 2018-06-06 13:29:09 -07:00
Doug Gregor
bc0445d1f7 Narrow a few LazyResolver::resolveDeclSignature() calls to what they really need.
Specifically, introduce entrypoints for "resolve overridden decl" and "is @objc". These can
be computed cheaply in many more cases.
2018-06-04 18:15:39 -07:00
swift-ci
7fff7b3ddf Merge remote-tracking branch 'origin/master' into master-next 2018-05-21 21:49:25 -07:00
Rintaro Ishizaki
b3453c17fe [ClangImporter] Take isCompatibilityAlias() into account in interface printing (#16625)
If the Clang declrations are *types*, canonical declaration in Swift is
imported for newest version of Swift. In interface generation, if the
declaration is versioned and it's imported as a member in either or both
version of Swift, we have to take compatibility typealias into account.

* Fixed 'ClangModuleUnit::getTopLevelDecls' to take isCompatibilityAlias() into account
* Fixed bugs in ClangImporter where member-to-member versioned types aren't properly imported.
  * Fixed 'SwiftDeclConverter::importFullName' to check equality of getEffectiveContext()
  * Fixed 'importer::addEntryToLookupTable' to check equality of getEffectiveContext()
    (moved 'ClangImporter::Implementation::forEachDistinctName' to 'NameImporter')
2018-05-22 13:38:45 +09:00
Michael Gottesman
9ff5694acc [upstream-update] Remove usage of removed method clang::VersionTuple::UseDotAsSeparator().
As of r332598, clang::VersionTuple only stores '.' as delimiters. On input any
'_' are converted to the '.' representation. So by the time it gets to swift, we
are guaranteed to have a '.' representation. So we can just drop any reference
to the flag and carry on.

rdar://36765072
2018-05-18 10:44:54 -07:00
Ted Kremenek
5c22751c76 Use '4.2' and not just the major version for 'introduced' in availability. 2018-05-09 11:39:20 -07:00
Ted Kremenek
cc3024d7c5 Swift 4.x (x < 2) names are obsoleted in 4.2, not 5.
In APINotes, when an unversioned name overrides
a previously declared name with a Swift version, if the
previously declared name is guarded under version 4
the obsoleted version should be 4.2, not 5.  In all other
cases, the obsoleted version is the next major Swift
version.

Fixes rdar://problem/39950937
2018-05-09 00:19:42 -07:00
Michael Gottesman
a264b1ed9c [gardening] Use SmallPtrSetImpl instead of SmallPtr<N> in more function parameters/return values.
This is good practice like using SmallVectorImpl instead of SmallVector.
2018-05-07 10:35:51 -07:00
Doug Gregor
ebf9cdcc44 [AST] Collapse storage for ConcreteDeclRef.
Rather than ASTContext-allocating ConcreteDeclRef’s storage when there is a
non-empty substitution map, put the SubstitutionMap directly in the
ConcreteDeclRef. Simplify the various interfaces along the way.
2018-05-02 13:39:21 -07:00
Doug Gregor
192234415d [AST] Store SubstitutionMaps in ConcreteDeclRef and Witness data structures.
Replace two prominent uses of SubstitutionList, in ConcreteDeclRef and
Witness, with SubstitutionMap. Deal with the myriad places where we
now have substitution maps and need substitution lists (or vice versa)
caused by this change.

Overall, removes ~50 explicit uses of SubstitutionList (of ~400).
2018-05-02 13:38:14 -07:00
Doug Gregor
b0fc56d8ff [Clang importer] Honor swift_bridged_typedef attribute.
When the swift_bridged_typedef attribute is present on a typedef,
import the underlying type as bridged (e.g., String) rather than as
its unbridged type (e.g., NSString).

Fixes rdar://problem/39497900.
2018-04-27 17:02:58 -07:00
swift-ci
1d2b218916 Merge pull request #16097 from DougGregor/nonthrowing-reinterpret-cast 2018-04-23 00:21:45 -07:00
Doug Gregor
8502d49cae [Clang importer] Mark implicit calls to reinterpretCast() non-throwing. 2018-04-22 23:21:37 -07:00
Slava Pestov
cd4bb3fc6a ClangImporter: Bypass addImplicitConstructors() on imported structs
Unfortunately imported classes still have to go through this
code path because it's the only place where we can calculate
inheritsSuperclassInitializers().
2018-04-19 18:00:50 -07:00
Jordan Rose
3cf00637fa AST-verify that 'open' is only used on classes and overridable members (#15996)
...and fix places where it was being used inappropriately.

- Don't use 'open' on non-class members in the importer.
- Use the existing 'copyFormalAccessFrom' instead of an ad hoc version
  for synthesized typealiases for protocol conformances. (This can
  change 'internal' down to 'fileprivate', but only where the
  enclosing type was already 'private' or 'fileprivate'.)
- Fix 'copyFormalAccessFrom' to not copy '@usableFromInline' onto
  declarations that don't support it (namely, the above typealiases).

This should have no visible effect in practice.
2018-04-18 16:47:54 -07:00
Slava Pestov
911d201d51 ClangImporter: Remove RegisteredExternalDecls and finishPendingActions() logic 2018-04-02 23:17:58 -07:00
Robert Widmann
03580d2fe5 Add a parameter list to EnumElementDecl
This models, but does not plumb through, default arguments.
2018-03-28 00:05:56 -04: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
e82e7ee908 [Type checker] Use BoundNameAliasType for all typealiases.
Rather than relying on the NameAliasType we get by default for references
to non-generic typealiases, use BoundNameAliasType consistently to handle
references to typealiases that are formed by the type checker.
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
Slava Pestov
9ffff87621 ClangImporter: Don't fall back on Sema for synthesizing the memberwise init
The importer would only synthesize its own memberwise init if the
declaration had a zero initializer, which supresses Sema's automatic
synthesis. Trouble is we cannot rely on Sema synthesizing the
memberwise init in case we deserialize declarations after type
checking.

Some other changes caught this with an assert, so fix the importer
to do the right thing here.
2018-03-21 21:41:38 -07:00
Jordan Rose
d150f96967 Merge pull request #14945 from jrose-apple/frozen-enums
Implementation for /most/ of SE-0192 (frozen and non-frozen enums)
2018-03-21 11:06:31 -07:00
Jordan Rose
0c8ad65027 [ClangImporter] Add a comment to 'recursivelySubstituteBaseType' (#15381)
As Doug pointed out in the original review where this went in, this
isn't the normal way to do a type substitution. However, all the usual
methods depend on the conformance's generic signature being fully
filled in. Add a comment because, well, I don't have a better answer.
2018-03-20 16:07:43 -07:00
Jordan Rose
52af3f3f65 [ClangImporter] Translate Clang's enum_extensibility to @_frozen
Still to do: test and fix up the use of multiple enum_extensibility
annotations, possibly with API notes. This is important because the
definition of NS/CF_ENUM /includes/ enum_extensibility(open) as of
Xcode 9.0; there should be a convenient out people can use to declare
exhaustive enums in C that's backwards-compatible.
2018-03-20 14:49:10 -07:00
Jordan Rose
5e9b5472c9 Add Parse + Sema support for '@_frozen'
(currently spelled with an underscore to indicate its WIP state)

Later commits will handle imported enums correctly and implement the
checks for switch cases.
2018-03-20 10:39:01 -07:00
Jordan Rose
8a66d998fa Decide if a class inherits convenience inits alongside implicit inits
We have a predicate in ClassDecl, 'inheritsSuperclassInitializers',
that is used in a few places to decide if we need to do lookups into a
superclass to find all relevant initializers. That's useful, but the
actual work being computed in that function is almost identical to the
work done in figuring out whether the class has provided all its
superclass's /required/ initializers, which is part of the type
checker operation 'resolveImplicitConstructors'. Furthermore,
'inheritsSuperclassInitializers' is /already/ calling
'resolveImplicitConstructors' because those implicit constructors
might affect the result.

Simplify this whole mess and prevent further inconsistencies like the
previous commit by just making 'resolveImplicitConstructors' decide
whether superclass convenience initializers are inherited. It does
make that function more complicated, but with the benefit of not
having duplication anymore.

No intended user-visible change, except that this bit is now
serialized instead of being recomputed, which means the module format
changed.
2018-03-19 18:28:41 -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
Slava Pestov
34fd4ae512 AST: Use DeclBaseName::Kind::Constructor
Fixes <rdar://problem/35852727>, <https://bugs.swift.org/browse/SR-1660>,
<https://bugs.swift.org/browse/SR-6557>.
2018-03-16 00:25:56 -07:00
Jordan Rose
520d6b9b91 Make NS_TYPED_ENUMS ObjectiveCBridgeable when they wrap an object (#15270)
This allows them to be used in generic arguments for NSArray et al.
We already do this for the ones that wrap bridged values (like
NSString/String), but failed to do it for objects that /weren't/
bridged to Swift values (class instances and protocol compositions),
or for Error-which-is-special.

In addition to this being a sensible thing to do, /not/ doing this led
to IRGen getting very confused (i.e. crashing) when we imported a
Objective-C protocol that actually used an NS_TYPED_ENUM in this way.

(We actually shouldn't be using Swift's IRGen logic to emit protocol
descriptors for imported protocols at all, because it's possible we
weren't able to import all the requirements. But that's a separate
issue.)

https://bugs.swift.org/browse/SR-6844
2018-03-15 16:17:38 -07:00
Slava Pestov
93d271900c ClangImporter: Don't import initializers as functions named 'init' 2018-03-14 20:18:52 -07:00
Jordan Rose
342743a0a5 [ClangImporter] Don't import C structs with non-trivial fields (#15209)
Swift currently assumes that copies and deinitializations of C structs
are always "trivial", i.e. a copy can be done by just copying the raw
bits of the value, and a deinit requires no work at all. Until we do
anything to change that, just don't import any of the new C structs
that have non-trivial copy or deinitialization operations (those with
ARC references in them).

rdar://problem/35698831
2018-03-14 17:56:44 -07:00
Huon Wilson
b330c6078f Merge pull request #14948 from huonw/at-owned
Make __owned functional, maybe
2018-03-08 13:18:19 +11:00
Huon Wilson
b1115af1eb Switch a pile of VarDecl::Specifier::Owneds to ::Default.
A lot of these probably should be Owned, but deciding that is work for
another time.
2018-03-08 12:36:37 +11:00
Jordan Rose
e202e90294 Clean up _BridgedNSError and _BridgedStoredNSError (#14682)
Despite their similar names and uses, these protocols no longer share
much functionality - the former is used to take @objc enums defined in
Swift that conform to Error and expose them as NSErrors, and the
latter handles NS_ERROR_ENUM C enums, which get imported into Swift as
a wrapper around NSError. We can actually simplify them quite a bit.

- Eliminate base protocol __BridgedNSError, which no longer provides
  any implementation for _BridgedStoredNSError.

- Eliminate default implementations that match what the compiler would
  synthesize.

- Adopt recursive constraints and where-clauses on associated types
  (and update the Clang importer to handle this).

- Collapse signed and unsigned default implementations when reasonable.

- Fold _BridgedStoredNSError's _nsErrorDomain into the existing public
  requirement CustomNSError.errorDomain.

rdar://problem/35230080
2018-03-07 13:14:36 -08:00