Commit Graph

1426 Commits

Author SHA1 Message Date
Christopher Rogers
b68ae2e230 Preserve availability on ObjC subscript getters and setters (#17105)
This resolves SR-7398.
2018-06-27 08:35:06 -07:00
swift-ci
a36b6407f4 Merge remote-tracking branch 'origin/master' into master-next 2018-06-22 13:29:27 -07:00
Jordan Rose
2107bdf392 [ClangImporter] Defend against ObjC properties without getters (#17429)
Objective-C provides no way to declare such a thing, so for this to
occur something else must have gone wrong. Unfortunately all we have
is a SourceKit crash log, so I couldn't write a test case. Hopefully
some day the assert will fire and we can handle this properly.

rdar://problem/41305904
2018-06-22 13:27:48 -07:00
swift-ci
2a0e83dc0d Merge remote-tracking branch 'origin/master' into master-next 2018-06-18 11:00:19 -07:00
Jordan Rose
05d0a2dfef [Serialization] Mark decls that can never be cross-referenced (#17223)
This allows us to filter them out in cases that would otherwise be
ambiguous. The particular prompting situation looks a lot like the
test case: a protocol, plus a forward-declared class with the same
name. (Normally we ignore forward-declared classes, but SourceKit's
module interface generation feature makes dummy ClassDecls for them
instead.)

https://bugs.swift.org/browse/SR-4851
2018-06-18 10:50:35 -07:00
swift-ci
4538ce9818 Merge remote-tracking branch 'origin/master' into master-next 2018-06-17 15:38:24 -07:00
John McCall
69f4dd1ec9 Generalize accessor storage to preserve the original accessor list.
Only not NFC because it's detectable by source tools.
2018-06-16 18:16:31 -04:00
swift-ci
bfe796b93e Merge remote-tracking branch 'origin/master' into master-next 2018-06-16 01:32:31 -07:00
Bob Wilson
5df3d1f100 Merge remote-tracking branch 'origin/master' into master-next 2018-06-14 20:51:48 -07:00
Doug Gregor
2b2e143f59 [Request-Evaluator] Introduce a request for getting an "inherited type". 2018-06-14 15:29:57 -07:00
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