Commit Graph

9116 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis
94d0e4e7a1 Merge pull request #13271 from rintaro/cmake-syntax-headers
[CMake] Add swift-syntax-generated-headers to the global dependencies
2017-12-05 16:14:46 -08:00
Nobuo Saito
18815fb78c Improve sample code of deriveHashable_hashValue (#13273)
Seems `SomeEnumWithAssociatedValues` implements require `result` initial value.
2017-12-06 09:07:26 +09:00
Mark Lacey
0d45b7884a Merge pull request #13265 from rudkx/minor-refactor
Add an early return and unindent some code. NFC.
2017-12-05 00:53:32 -08:00
Rintaro Ishizaki
08ef4e324f [CMake] Add swift-syntax-generated-headers to the global dependencies 2017-12-05 17:03:12 +09:00
Mishal Shah
1006a6e76c Merge pull request #13259 from rudkx/do-not-decay-iuo-to-optional
For Swift 3/4 mode, do not treat IUOs in illegal positions as Optionals.
2017-12-04 17:48:05 -08:00
Mark Lacey
6b32849610 Add an early return and unindent some code. NFC. 2017-12-04 17:08:32 -08:00
Mark Lacey
73a492dc4f For Swift 3/4 mode, do not treat IUOs in illegal positions as Optionals.
Instead, just emit a deprecation warning and suggest switching to Optionals.

The old behavior caused several projects to break, so before we change
the behavior here we need to investigate whether we can mitigate most
of those breaks.
2017-12-04 16:15:13 -08:00
Pavel Yaskevich
6ca3d3fc72 Merge pull request #13138 from xedin/rdar-35702810
[CSSolver/SILGen] Fix solver to support function conversion with collection subtyping
2017-12-04 15:05:37 -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
Doug Gregor
04a9714d9b [Type checker] Short-circuit uses of concrete typealiases in protocols.
Hack to allow IndexDistance to become a deprecated typealias. The actual
fix here involves deeper surgery into the substitution machinery.
2017-12-04 10:05:48 -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
Mark Lacey
66a11ce66b Revert "[ConstraintSystem] Use semantics providing exprs when dealing with favored types."
This reverts commit 2f80af15ec.

I expected this to have no effect, but it results in one of the
expression type checker tests taking longer, so that test was disabled.

This commit also re-enables the test since it now passes again.
2017-12-02 21:46:31 -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
Mark Lacey
c0af43aaec Merge pull request #13197 from rudkx/rework-iuo
Some small constraint system cleanups.
2017-12-01 22:19:10 -08:00
Jordan Rose
ace0f56e9c Be way more conservative about marking dependencies as non-cascading (#13214)
Being part of the type of a private declaration isn't sufficient,
because that could be used for the inferred type of a non-private
variable/constant/property.

Also, introduce a new kind of dependency test that shows both that a
file A changes its interface based on a change in another file B, and
that the swiftdeps output for file A includes the dependency on file B
as cascading.

https://bugs.swift.org/browse/SR-6149
2017-12-01 18:35:18 -08:00
Mark Lacey
6cebc924af [ConstraintSystem] Only record fixes that result in a correct solution.
It's probably harmless to record the ones for failures which later cause
us to back out in the solver, but it means we cannot easily set
breakpoints in places like recordFix and stop only in the places where
the fixes actually cause the solution to make progress.
2017-12-01 17:27:12 -08:00
Mark Lacey
4f7f5d7c09 [ConstraintSystem] Simplify some logic around attempting fixes for Optionals.
Only record the fixes when they have made the solution to this point
successful.
2017-12-01 17:15:37 -08:00
Mark Lacey
fda51bb6b2 [ConstraintSystem] Eliminate the notion of FixKind::None
These purportedly mark that we should stop attempting fixes for a given
constraint, but in fact the only code creating these is clearly
unreachable so these serve no purpose.
2017-12-01 16:18:16 -08:00
Mark Lacey
2f80af15ec [ConstraintSystem] Use semantics providing exprs when dealing with favored types.
This allows us to eliminate some special casing around things like
parens, and allows the code to work for other code involving expressions
that are semantically neutral.
2017-11-30 19:11:59 -08:00
Pavel Yaskevich
515520e524 [CSSolver/SILGen] Fix solver to support function conversion with collection subtyping
Fix collection subtyping relation in function argument position
by emiting special re-abstraction thunk with collection upcast.

Resolves: rdar://problem/35702810
2017-11-30 16:47:18 -08:00
Doug Gregor
33de34bc38 Merge pull request #13178 from DougGregor/coding-conditional-conformances
[Coding] Make Codable conformances for Optional and collections conditional.
2017-11-30 13:43:30 -08:00
Jordan Rose
8f8f00012a Merge pull request #12834 from jrose-apple/restrict-cross-module-struct-initializers-2
Implementation of SE-0189 "Restrict cross-module struct initializers to be delegating"

rdar://problem/34777878
2017-11-30 13:32:45 -08:00
Doug Gregor
ffe79e047f [Codable] Remove compiler hack faking conditional conformances.
The Codable synthesis code was checking the conditional requirements of
Optional/Array/Set/Dictionary's Codable conformances, which had to be
unconditional. Now that they are properly conditional conformances, we
no longer need the hack.

Thanks to @itaiferber for pointing this out!
2017-11-30 11:47:12 -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
4ab6e763e7 Merge pull request #13171 from aschwaighofer/revert_csgen
Revert "[CSGen] Fix `LinkedExprAnalyzer` greedy operator linking"
2017-11-29 19:46:06 -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
Slava Pestov
e360da57bb Sema: Use the correct source range when emitting fixits for unresolved member expressions
Fixes <rdar://problem/34421732>.
2017-11-29 18:23:17 -08:00
swift-ci
6c4ed9c3c2 Merge pull request #13158 from DougGregor/type-checker-simplify-error-type 2017-11-29 17:05:32 -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
Doug Gregor
d8fddee726 [Type checker] Don’t simplify to an error type.
Type variables cannot be bound to error types, so don’t simplify to
them.
2017-11-29 16:12:19 -08:00
John McCall
02d7fe36ba Extend the addObserver/removeObserver to AnyObject lookup idioms.
rdar://33850465
2017-11-29 18:04:22 -05: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
Slava Pestov
47e239056c Sema: Use pointer equality instead of isSpelledLike() to compare sugar 2017-11-28 20:25:21 -08:00
swift-ci
cdab55a202 Merge pull request #13124 from DougGregor/se-0143-experimental-flag 2017-11-28 16:59:27 -08:00
Doug Gregor
b59c30c1af [SE-0143] Put conditional conformances behind an "experimental" flag.
Conditional conformances aren't quite ready yet for Swift 4.1, so
introduce the flag `-enable-experimental-conditional-conformances` to
enable conditional conformaces, and an error when one declares a
conditional conformance without specifying the flag.

Add this flag when building the standard library (which will vend
conditional conformances) and to all of the tests that need it.

Fixes rdar://problem/35728337.
2017-11-28 16:01:51 -08:00
swift-ci
36de380542 Merge pull request #13115 from xedin/rdar-35699666 2017-11-28 14:14:50 -08:00
Pavel Yaskevich
f5d9c2eb79 [Diagnostics] Fix crash related to diagnostics of trailing closures
While trying to diagnose a problem related to contextual result type
of the trailing closure, don't assume that declaration context is properly
set, instead directly set it to correct one before running type-check.

Resolves: rdar://problem/35699666
2017-11-28 13:12:25 -08:00
Doug Gregor
61448ccfff Merge pull request #13093 from DougGregor/sr-6472-overload-autoclosure
[Overloading] Adjust @autoclosure parameter types to their result types.
2017-11-27 17:20:12 -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
swift-ci
31f32be27e Merge pull request #13047 from xedin/fix-locators 2017-11-27 14:39:27 -08:00
Pavel Yaskevich
df0fd6abfb [ConstraintSystem] Improve type parameter requirement locators
When opening generic types with type parameter requirements,
add information about requirement location to the locator of each
generated constraint to make it easier to extract such information
if needed.
2017-11-27 13:38:38 -08:00
David Zarzycki
a550042391 Merge pull request #13050 from davezarzycki/nfc_enum_class_TypeResolutionFlags
NFC: Use 'enum class' for TypeResolutionFlags
2017-11-27 07:07:11 -05:00
Chris Lattner
3f5790fb37 Enhance MemberLookupResult's UnviableCandidates list, NFC.
We now store an entire OverloadChoice in the unviable candidates
list (which is used for error recovery), just like we store them
for viable candidates.

The additional information isn't used, so NFC.
2017-11-26 14:29:00 -08:00
Chris Lattner
0670deffcb Rework OverloadChoice to use PointerEmbeddedInt instead of reimplementing it
in a gross way.  Also, handle DeclViaDynamic the same way as DeclViaBridge
and DeclViaUnwrappedOptional.

Also, OverloadChoiceKind says that TupleIndex must be the last entry in the
enum list, so make it the last one (even though this doesn't actually cause
a bug right now).

All this is just cleanup, NFC.
2017-11-24 17:17:22 -08:00
David Zarzycki
835d1a221c NFC: Use 'enum class' for TypeResolutionFlags 2017-11-22 09:14:33 -05:00
Doug Gregor
4f9cb35f6a [Type checker] Fix ranking of _OptionalNilComparisonType overloads of ==/!=.
Always prefer them to Optionals ==/!=, because they are @transparent and
more efficient.
2017-11-21 22:56:08 -08:00
swift-ci
2eca3aa27a Merge pull request #13045 from DougGregor/se-0143-check-all-conditional-requirements 2017-11-21 22:55:49 -08:00
Doug Gregor
e3a5318b97 [Type checker] Teach conformsToProtocol() to check conditional requirements.
conformsToProtocol() is the main way in which we check whether a given type
conforms to a given protocol. Extend it to check conditional requirements by
default, so that an unmodified caller will get the "does not conform" result
(with diagnostics when a location is present) rather than simply ignoring
the conditional requirements.

Some callers take responsibility for conditional requirements, e.g., to
push them into the constraint system. Allow those callers to opt out of
this checking, and do so wherever appropriate.

Fixes rdar://problem/35518088, where we were ignoring the conditional
requirements needed to verify that Equatable synthesis could be performed.
2017-11-21 21:02:00 -08:00
Doug Gregor
33810d9a6a [Constraint solver] Add a constraint locator element for conditional requirements.
Using this constraint locator element, we can check when a failed
constraint is due to an unsatisfied conditional requirement of a
protocol conformance. Unfortunately, it's hard to turn this into
an actionable diagnostic right now.
2017-11-20 21:07:13 -08:00
swift-ci
2e6e0ece5b Merge pull request #13033 from DougGregor/se-0143-conditional-requirements-type-erasure 2017-11-19 23:59:03 -08:00