Commit Graph

9116 Commits

Author SHA1 Message Date
Doug Gregor
60f5a6529e Add Fix-Its suggesting @NSKeyedArchiveLegacy when it can be used. 2017-05-02 22:38:32 -07:00
Doug Gregor
aaf7933a6d Add the @NSKeyedArchiveLegacy attribute.
This attribute allows one to provide the "legacy" name of a class for
the purposes of archival (via NSCoding). At the moment, it is only
useful for suppressing the warnings/errors about classes with unstable
archiving names.
2017-05-02 22:38:32 -07:00
Slava Pestov
e8f4930cb5 Merge pull request #9192 from slavapestov/anyobject-removal-vol-4
AnyObject removal volume 4
2017-05-02 22:03:44 -07:00
Doug Gregor
28560ec005 [Type checker] Warn about NSCoding-conforming classes with unstable mangled names.
The name mangling changed from Swift 3 to Swift 4, and may get slight
tweaks as we lock down ABI stability. Identify and warn about (in
Swift 3) or error about (in Swift 4) the cases where we don't have
obviously-stable name mangling, e.g.,

* private/fileprivate classes (whose mangled names involve the file name)
* nested classes (whose mangled names depend on their enclosing type)
* generic classes (whose mangled names involve the type arguments)
2017-05-02 21:45:18 -07:00
Slava Pestov
b5721e8d8e AST: Remove AnyObject protocol 2017-05-02 19:45:00 -07:00
Slava Pestov
82d2d3ee43 Sema: Tweak inheritance clause checks for primitive AnyObject 2017-05-02 19:24:03 -07:00
Mark Lacey
44882d2d2a [Constraint solver] Fix Swift 3 compatibility issue with overloaded operators.
Recent changes to the stdlib resulted in some expressions involving
literals and operators that have both generic and non-generic overloads
to become ambiguous. The ambiguity is due to an old performance hack in
the solver which unfortunately needs to remain in place at the moment to
avoid regressing expression type checker performance.

This commit changes the performance hack a bit in that instead of
stopping visiting the options in a disjunction as soon as we have a
solution involving non-generic operators and come across a constraint
involving generic operators, we instead continue visiting the elements
in the disjunction, but just skip over the generic operators.

Fixes rdar://problem/31695865 and rdar://problem/31698831.
2017-05-02 18:27:15 -07:00
Xi Ge
0b172f520b fix compiler error. 2017-05-02 14:10:23 -07:00
Xi Ge
6b31126a9f Merge branch 'master' into separate-note-switch 2017-05-02 14:00:26 -07:00
Robert Widmann
ab9f2805a1 Merge pull request #9180 from CodaFi/cross-pollination
Improve multi-file enum diagnostics
2017-05-02 16:46:17 -04:00
Huon Wilson
4fc27a1f3e Merge pull request #9150 from huonw/keypath-syntax
Implement \ syntax for Swift key paths.
2017-05-03 06:22:47 +10:00
Xi Ge
0ce9f7522d update test 2017-05-02 13:15:26 -07:00
Robert Widmann
5722984571 Rewrite flattening to be more effective with nested products 2017-05-02 16:09:24 -04:00
Xi Ge
d95fbf9e07 udpate test 2017-05-02 13:04:52 -07:00
Xi Ge
1acbf56d7b Sema: Move the fixit for adding missing enum cases to a separate note instead of attaching to the exhaustive error itself. 2017-05-02 12:13:18 -07:00
Doug Gregor
6d241509e6 Merge pull request #9168 from DougGregor/se-0160-disable-warnings-by-default
[SE-0160] Make deprecated @objc inference warnings opt-in.
2017-05-01 22:12:53 -07:00
Robert Widmann
ce6862731f Improve multi-file decompositions through validation 2017-05-02 00:31:03 -04:00
Slava Pestov
214c7f8e5a Sema: Update getDefaultGenericArgumentsString() for primitive AnyObject 2017-05-01 19:30:43 -07:00
Robert Widmann
55b7d17bfa Merge pull request #9155 from CodaFi/redundant-notes-for-redundant-folks
Remove an unnecessary StringRef from a Space Engine diagnostic
2017-05-01 22:23:11 -04:00
Slava Pestov
e5cc508415 Sema: Update inheritance clause checking for primitive AnyObject 2017-05-01 17:25:02 -07:00
Doug Gregor
66b11cbc3d [SE-0160] Make deprecated @objc inference warnings opt-in.
The warnings about deprecated @objc inference in Swift 3 mode can be a
bit annoying; and are mostly relevant to the migration workflow. Make
the warning emission a three-state switch:

* None (the default): don't warn about these issues.
* Minimal (-warn-swift3-objc-inference-minimal): warn about direct
  uses of @objc entrypoints and provide "@objc" Fix-Its for them.
* Complete (-warn-swift3-objc-inference-complete): warn about all
  cases where Swift 3 infers @objc but Swift 4 will not.

Fixes rdar://problem/31922278.
2017-05-01 16:25:50 -07:00
Huon Wilson
07c5ab8fb2 Implement \ syntax for Swift key paths.
This introduces a few unfortunate things because the syntax is awkward.
In particular, the period and following token in \.[a], \.? and \.! are
token sequences that don't appear anywhere else in Swift, and so need
special handling. This is somewhat compounded by \foo.bar.baz possibly
being \(foo).bar.baz or \(foo.bar).baz (parens around the type), and,
furthermore, needing to distinguish \Foo?.bar from \Foo.?bar.

rdar://problem/31724243
2017-05-01 16:06:15 -07:00
Slava Pestov
4fd870b81d AST: Change ExistentialLayout::requiresClass from a field to a method
We need to compute it lazily to avoid calling
ProtocolDecl::requiresClass() before the protocol's
inheritance clause has been type checked.
2017-05-01 15:49:03 -07:00
Doug Gregor
5bd609c98f Merge pull request #9156 from DougGregor/redundant-conformance-warnings
[Type checker] Downgrade some "redundant conformance" errors to warnings.
2017-05-01 15:00:14 -07:00
Doug Gregor
f7bccb0e68 [Type checker] Downgrade some "redundant conformance" errors to warnings.
When an extension introduces a conformance that already exists, the
type checker will reject the conformance and then ignore it. In cases
where the original conformance is in the same module as the type or
protocol (but the new, redundant conformance is in some other module),
downgrade this error to a warning. This helps with library-evolution
cases where a library omitted a particular conformance for one of its
own types/protocols in a previous version, then introduces it in a new
version.

The specific driver for this is the conformance of String to
Collection, which affects source compatibility. Fixes
rdar://problem/31104415.
2017-05-01 13:22:15 -07:00
Bob Wilson
84d1630727 Merge pull request #9142 from shajrawi/loadable_by_addr_split
Code Size: Pass large loadable types by address instead of by value - Updated Version
2017-05-01 12:56:38 -07:00
Robert Widmann
616284f603 Remove an unnecessary StringRef from a Space Engine diagnostic 2017-05-01 15:44:01 -04:00
Doug Gregor
b6494f6daf Merge pull request #4785 from jrose-apple/trailing-closures-and-default-arguments
When ranking overloads, always match up final closure parameters.
2017-05-01 09:53:09 -07:00
Robert Widmann
4e2f36c763 Lift case redundancy checks into Sema 2017-05-01 01:32:02 -04:00
Garric G. Nahapetian
7863e29279 Add fix-it to error and add note - SR-4637 (#8947)
Specialize the diagnostic emitted to remove the @escaping attribute from type refs to mention that arrows in optionals are implicitly escaping anyway.
2017-04-30 16:17:05 -04:00
Joe Shajrawi
d17258cac7 @in_constant calling convention - part of passing large loadable types by address 2017-04-30 10:13:02 -07:00
Mark Lacey
de10c41915 Fix another case where the type checker will set the correct types.
We should not be providing types that we can/should derive
automatically.
2017-04-29 23:06:17 -07:00
Mark Lacey
9e38a8efea Do not hard-code a result type that the type checker will fill in.
Small clean-up.
2017-04-29 21:37:01 -07:00
swift-ci
ce2abf1662 Merge pull request #9130 from rudkx/disjunction-selection 2017-04-29 18:23:20 -07:00
Mark Lacey
ecfa406fc5 Re-instate "Improve disjunction selection"
Thie reinstates 3c5b393e0c, which was
backed out due to it exposing an ambiguous expression in a recent stdlib
commit.
2017-04-29 17:53:13 -07:00
Robert Widmann
253d0080ef Improve diagnostic for attempted initialization of non-nominal types 2017-04-29 20:29:20 -04:00
Mark Lacey
1de530e229 Revert "Improve disjunction selection" 2017-04-29 10:45:15 -07:00
Mark Lacey
2e9858d5c7 Merge pull request #9059 from rudkx/disjunction-selection
Improve disjunction selection
2017-04-29 10:10:16 -07:00
Doug Gregor
447dce6c1f Merge pull request #9004 from itaiferber/swift-archival-serialization
Swift Archival & Serialization API
2017-04-28 20:02:33 -07:00
Robert Widmann
2a7eee86fc Merge pull request #8908 from CodaFi/space-engine
Redo Exhaustiveness Analysis
2017-04-28 21:28:31 -04:00
Graydon Hoare
cd48479d14 Merge pull request #9110 from graydon/grab-bag-of-metrics
Add an assortment of new "always-on" metrics.
2017-04-28 16:59:09 -07:00
Graydon Hoare
b5292f04f8 Add an assortment of new "always-on" metrics. 2017-04-28 13:56:13 -07:00
Slava Pestov
3130c3cbd7 AST: Remove an overload of GenericSignature::getSubstitutions() 2017-04-28 13:26:02 -07:00
Doug Gregor
7be3a142f9 Merge pull request #9093 from DougGregor/warn-unavailable-witnesses
[Type checker] Warn about unavailable witnesses used to satisfy a requirement
2017-04-28 10:20:59 -07:00
Mark Lacey
3c5b393e0c [Constraint solver] Rework how we select the next disjunction to visit.
We previously used a simple heuristic of visiting the disjunction with
the fewest number of elements in it.

Instead, this commit introduces a new way to select the best disjunction
to explore based on attempting disjunctions based on either how much
information we have about the associated type variables (e.g. how many
of the arguments of a function call in the case of bind overload
disjunctions) or by other criteria that help constraint the search or
split the connected components (e.g. coercions and calls to
initializers).

A key part of the improvement here is allowing the type checker to
attempt bindings of types to type variables when there are still
argument conversion constraints between type variables in the
system. The insight here is if there are no other constraints blocking
an attempt to bind types and we have types to try, we will be able to
test those types against active conformance constraints and potentially
fail much earlier while solving.

Visiting disjunctions in a different order exposed some other problems
with the type checker including a couple cases where map is used that
are now considered ambiguous due to problems in how we are ranking
solutions.

I measured an 11-13% reduction in type checking time for the standard
library using a release build of the compiler.
2017-04-28 00:50:16 -07:00
Robert Widmann
1dfab98931 Look through parens to the semantic pattern below 2017-04-28 02:33:09 -04:00
Robert Widmann
39494b2ba2 Rearrange test code for exhaustiveness 2017-04-28 02:06:39 -04:00
Robert Widmann
42c59554a0 Introduce the Space Engine
Implement exhaustiveness checking in Sema with rich error messages.  The
algorithm used is a variant of the one described in Fengyun Liu's paper
"A Generic Algorithm for Checking Exhaustivity of Pattern Matching"
published in the EPFL conference, and Luc Maranget's seminal paper
"Warnings for Pattern Matching"

The Space Engine views pattern matching as a problem of projecting the
scrutinee of a pattern-match into a "Space", then iteratively
constructing a Space from the cases.  Taking the difference of this
master space and the covered spaces yields the "holes" left over or
reveals a completely covered space.

The algorithm also extends trivially to redundancy checks in patterns,
but that check is already implemented in SILGen and this algorithm does
not improve upon it.
2017-04-28 02:06:39 -04:00
Doug Gregor
9ebc4caa41 [Type checker] Warn about unavailable witnesses used to satisfy a requirement. 2017-04-27 22:40:21 -07:00
Slava Pestov
e3b68e7bdd Remove -enable-experimental-subclass-existentials staging flag 2017-04-27 20:46:37 -07:00