Commit Graph

1259 Commits

Author SHA1 Message Date
Max Moiseev
d4359b83c7 Merge pull request #12819 from moiseev/filtermap
[stdlib] Introduce compactMap and deprecate one flatMap variant
2017-12-19 17:06:32 -08:00
swift-ci
adf83617ec Merge pull request #13526 from DougGregor/remove-conditional-conformances-flag 2017-12-19 11:17:44 -08:00
Doug Gregor
ffb0d55b35 Eliminate extraneous uses of -enable-experimental-conditional-conformances 2017-12-18 22:56:22 -08:00
Pavel Yaskevich
366356f9ca [Mangling/ABI] NFC: Fix Sema tests to reflect label mangling changes 2017-12-18 15:44:25 -08:00
Ben Cohen
9361a6b66f [stdlib] Nest Iterator and Index types for various stdlib types (#13489)
* Nest various top-level Iterator and Index types, and flatten extensions.

* Fix tests from nesting iterator

* Nest Unsafe*BufferPointer.Iterator, extensionify UnsafeBufferPointer

* Degyb LazyCollection

* Nest Flatten iterator and index
2017-12-18 15:27:35 -08:00
Maxim Moiseev
128092a7d6 Rename filterMap to compactMap 2017-12-18 09:22:41 -08:00
Max Moiseev
96d3439669 Update tests after deprecating flatMap variant 2017-12-18 09:16:37 -08:00
Mark Lacey
32989cc341 IUO: Add some additional tests. 2017-12-15 17:10:28 -08:00
Pavel Yaskevich
b6dbafba29 Merge pull request #13471 from CodaFi/array-of-sunshine
[DiagnosticsQoI] Refactor ArrayExpr visitor for better QoI
2017-12-15 16:19:40 -08:00
Robert Widmann
1d6f11ab54 Refactor ArrayExpr visitor for better QoI
Also remove mention of the word “contextual” type from the diagnostic
that rewrites array literals into dictionary literals and scale back
the scope of the diagnostic.  This method was catching and
mis-diagnosing too many errors that could better be handled by invalid
conversion diagnostics.
2017-12-15 18:20:36 -05:00
Pavel Yaskevich
4aad7de6e5 [TypeChecker] NFC: Add test case for rdar://problem/36054961 2017-12-14 12:32:37 -08:00
Mark Lacey
b0f790982a IUO: Add tests for failable init and static functions with IUO results. 2017-12-12 16:45:43 -08:00
Doug Gregor
9b2c462709 [Conformance checking] Factor out associated type inference.
Move associated type inference into its own class, to make this
code easier to understand/maintain/improve. Minor diagnostics changes
because we're properly passing uninference associated type declarations
to the "group" checker.
2017-12-09 23:05:24 -08:00
Slava Pestov
9ac4d391fd Merge pull request #13345 from slavapestov/fixed-on-accident-lets-add-a-test
Add regression test for https://bugs.swift.org/browse/SR-6509
2017-12-08 13:47:44 -08:00
Mark Lacey
bae62d7e80 Merge pull request #13343 from rudkx/iuo-test
Add the test case I am using to bring up the new IUO implementation.
2017-12-08 13:04:21 -08:00
Slava Pestov
8a31bc7609 Add regression test for https://bugs.swift.org/browse/SR-6509 2017-12-08 12:54:03 -08:00
Ben Cohen
4ddac3fbbd [stdlib] Eradicate IndexDistance associated type (#12641)
* Eradicate IndexDistance associated type, replacing with Int everywhere

* Consistently use Int for ExistentialCollection’s IndexDistance type.

* Fix test for IndexDistance removal

* Remove a handful of no-longer-needed explicit types

* Add compatibility shims for non-Int index distances

* Test compatibility shim

* Move IndexDistance typealias into the Collection protocol
2017-12-08 12:00:23 -08:00
Mark Lacey
d07af8ad80 Add the test case I am using to bring up the new IUO implementation.
This is a nice contained test case that has the goal of testing all
the new functionality. Having this committed before the code changes
will make it clear whether any behavior changes between the old and
new implementation (I expect some small diagnostic changes like
uttering T? instead of T! for some types).
2017-12-08 11:16:39 -08:00
Max Moiseev
8dbaa2a752 Revert "[stdlib] Temporarily exclude DoubleWidth from the standard library" 2017-12-05 15:37:07 -08:00
Doug Gregor
dc8b970051 [SE-0143] Eliminate assertions blocking the use of conditional conformances.
Early on in the development of conditional conformances, we put in a bunch
of assertions for code that uses `conformsToProtocol()` but wasn't handling
conditional conformances. Now, `conformsToProtocol()` handles conditional
conformances by default, and these assertions are tripping up code
that would work.

Remove the assertions and add test cases that used to trip up the
assertions (but now work).
2017-12-04 11:28:00 -08:00
Pavel Yaskevich
6973cfda29 Merge pull request #13109 from xedin/rdar-35541153
[CSBindings] Avoid binding type variables to collection types directly
2017-12-02 23:31:05 -08:00
Pavel Yaskevich
5d5872bb83 [CSBindings] Avoid binding type variables to collection types directly
Instead of binding collection types directly let's try to
bind using temporary type variables substituted for element
types, that's going to ensure that subtype relationship is
always preserved.

Resolves: rdar://problem/35541153
2017-12-01 23:04:19 -08:00
Max Moiseev
156e6eb848 Exclude DoubleWidth due to the binary size concerns
<rdar://problem/32726173>
2017-12-01 14:29:53 -08:00
Ben Cohen
dcab9493ae Removed some warnings (#12753) 2017-11-30 15:12:56 -08:00
Pavel Yaskevich
0783890b03 [CSGen] Fix LinkedExprAnalyzer greedy operator linking
Let's not attempt to link arithmetic operators together in
presence of concrete and literal (int, float, string) types.

Resolves: rdar://problem/35740653
2017-11-29 22:13:45 -08:00
Arnold Schwaighofer
c544a2779d Revert "[CSGen] Fix LinkedExprAnalyzer greedy operator linking"
This reverts commit 29ea599f30.

SR-6505
2017-11-29 19:42:47 -08:00
Pavel Yaskevich
e4d83a7a2e Merge pull request #13152 from xedin/rdar-35740653
[CSGen] Fix `LinkedExprAnalyzer` greedy operator linking
2017-11-29 16:57:52 -08:00
Pavel Yaskevich
29ea599f30 [CSGen] Fix LinkedExprAnalyzer greedy operator linking
Let's not attempt to link arithmetic operators together in
presence of concrete and literal types.

Resolves: rdar://problem/35740653
2017-11-29 14:48:10 -08:00
Doug Gregor
ba6f605d47 Fix some tests due to Equatable Optional/Array/Dictionary change. 2017-11-27 21:09:50 -08:00
Doug Gregor
8342f77bc4 [Overloading] Adjust @autoclosure parameter types to their result types.
For the purposes of partial ordering of declarations (e.g., in
overload resolution), adjust `@autoclosure` parameter types to the
result type of the autoclosure, i.e., the type against which the
argument will be matched. This makes overload resoluton agnostic to
`@autoclosure`.

Fixes SR-6472.
2017-11-27 15:32:23 -08:00
Mark Lacey
8b55a0f61b SE-0054: Rework diagnostics for IUOs and revise Swift 3 /4 semantics.
For Swift 3 / 4:

Deprecate the spelling "ImplicitlyUnwrappedOptional", emitting a warning
and suggesting "!" in places where they are allowed according to
SE-0054.

In places where SE-0054 disallowed IUOs but we continued to accept them
in previous compilers, emit a warning suggesting "Optional" or "?"  as
an alternative depending on context and treat the IUO as an Optional,
noting this in the diagnostic.

For Swift 5:

Treat "ImplicitlyUnwrappedOptional" as an error, suggesting
"!" in places where they are allowed by SE-0054.

In places where SE-0054 disallowed IUOs, emit an error suggestion
"Optional" or "?" as an alternative depending on context.
2017-11-18 11:41:53 +09:00
Pavel Yaskevich
05d524d6e0 [CSApply] Fix source breakage related to deep-equality types and SE-0110
Fix problem related to Swift 3 mode (with assertions),
since Swift 3 mode allows passing arguments with extra parens
to parameters which don't expect them, it should be supported
by "deep equality" types e.g. Optional<T>:

```swift
func foo(_: (() -> Void)?) {}
func bar() -> ((()) -> Void)? { return nil }
foo(bar) // This expression should compile in Swift 3 mode
```

Resolves: rdar://problem/35198459
2017-11-16 21:56:24 -08:00
Arnold Schwaighofer
0971d82f70 SILGen: Remaining fixes for @callee_guaranteed closures and enable it
- Fix block to func reabstraction thunks block argument handling
- Forward cast ownership
- Fix applyPartiallyAppliedSuperMethod ownership for @callee_guaranteed closures
- Avoid a copy in buildBlockToFuncThunkBody
- Update tests for callee_guaranteed closures

SR-5441
rdar://33255593
2017-11-15 19:46:08 -08:00
Greg Parker
e8475cc130 Revert "Use conditional conformances to implement Equatable for Optional, Array and Dictionary" 2017-11-15 14:17:22 -08:00
Doug Gregor
1f9b28a117 [Type checker diags] Check generic arguments for any generic function.
This includes functions without type parameters that are generic
because they are members of a generic context. This addresses a
diagnostics regression because the '==' operators for Optional, Array,
and Dictionary were made into members.

The resulting error message is a little ugly, but is more informative
(and much shorter) than what we had before.
2017-11-14 16:23:20 -08:00
Doug Gregor
9f68fdae80 [Conditional conformances] Fix up test cases that changed for the better. 2017-11-14 16:23:20 -08:00
Xi Ge
0d9745f6eb libSyntax: teach parser to parse dictionary and array literals. (#12821)
This commit also adds ArrayExpr and DictionaryExpr to the libSyntax nodes
family. Also, it refactors the original parser code for these two
expressions to better fit to the design of SyntaxParsingContext.

This commit has also fixed two crashers.
2017-11-09 09:00:43 -08:00
Pavel Yaskevich
66e13bcc85 [ConstraintSolver] Avoid unnecessarily increasing score when matching function types
Remove function-to-function type match score increase, which should only
happen contextually in presence of other restrictions, this used to fix
the case related to matching of arrays of functions with and w/e `throws`
as function parameters which used to be ambigious, and now handled by
collection-upcast conversion score.

Resolves: rdar://problem/35142121
2017-10-31 23:14:35 -07:00
Doug Gregor
3452dda95c [GSB] Stop warning about 'bare' associated type redeclarations.
Associated type redeclarations occasionally occur to push around
associated type witness inference. Suppress the warning about redeclarations
that add no requirements (i.e., have neither an inheritance nor a
where clause).
2017-10-26 14:58:00 -07:00
Doug Gregor
e1e0deca33 Reject unbound generic types in case patterns.
Fixes SR-6100 / rdar://problem/34898452.
2017-10-25 23:19:28 -07:00
Slava Pestov
d23e2bce62 Sema: Fix a failure to emit a diagnostic in pre-check expression pass
This has been broken for four years at least. What a bummer.

Fixes <rdar://problem/35116378>.
2017-10-22 20:05:00 -07:00
gregomni
cdce937c51 Beginning changes to provide more info out about unresolved params, but even
changing is<UnresolvedType> to hasUnresolvedType turns out is enough to fix a
radar.
2017-10-21 19:33:36 -07:00
Pavel Yaskevich
7d2e29a349 [AST] Fix canonicalization of the function input types
Currently canonicalization of the input type was happening standalone
which means that outer parens are regarded as suger and removed,
this is incorrect after SE-0110 and such parens can't be stripped.
2017-10-05 16:11:56 -07:00
Pavel Yaskevich
4317074a9a [ConstraintSolver] Prioritize certain type variables while looking for bindings
Presence of some constraints (Subtype at least) requires a certain
contextual ranking of the type variables associated with them when
it comes to picking bindings, otherwise it might lead to no or
invalid solutions, because only a set of the bindings for the best
type variable is attempted.

Resolves: rdar://problem/22898292
2017-10-03 10:41:35 -07:00
Pavel Yaskevich
695baccc3e Revert "[ConstraintSolver] Prioritize certain type variables while looking for bindings"
This reverts commit 001b09747a.
2017-10-02 17:30:18 -07:00
Pavel Yaskevich
3100088217 Merge pull request #12198 from xedin/rdar-22898292
[ConstraintSolver] Prioritize certain type variables while looking for bindings
2017-10-02 11:34:39 -07:00
Pavel Yaskevich
001b09747a [ConstraintSolver] Prioritize certain type variables while looking for bindings
Presence of some constraints (Subtype at least) requires a certain
contextual ranking of the type variables associated with them when
it comes to picking bindings, otherwise it might lead to no or
invalid solutions, because only a set of the bindings for the best
type variable is attempted.

Resolves: rdar://problem/22898292
2017-09-30 14:36:16 -07:00
Slava Pestov
8ff8b7e8a1 Add another test case for <https://bugs.swift.org/browse/SR-5932> 2017-09-29 16:58:19 -07:00
swift-ci
caffda1b58 Merge pull request #12188 from moiseev/floating-modulo-message 2017-09-29 13:19:03 -07:00
Max Moiseev
6ea3644568 [stdlib] Clarify an availability message for % on floating point types
<rdar://problem/27855641>
2017-09-29 12:18:15 -07:00