Commit Graph

15871 Commits

Author SHA1 Message Date
Pavel Yaskevich
f259286bd7 [CSFix] Convert missing explicit @escaping fix to be a contextual mismatch
Sometimes diagnostic needs both sides of the conversion e.g.
when there is an attempt to bind generic argument to non-escaping type.
2019-12-12 12:42:08 -08:00
Pavel Yaskevich
bb51a8f97d [ConstraintSystem] Use originating constraint as a source for a binding
Unify all of the fields of `PotentialBinding` which have to do with
location information into a single field with is either a constraint
(for regular bindings) or constraint locator (for "holes").

This helps to reduce the amount of space used by `PotentialBinding`
 as well as propagate more contextual information when binding gets
 attempted.
2019-12-12 12:41:44 -08:00
swift_jenkins
0896bef9f5 Merge remote-tracking branch 'origin/master' into master-next 2019-12-11 14:40:02 -08:00
Holly Borla
3d1ab4da67 Merge pull request #28712 from hborla/function-parameter-mismatch-diagnostics
[ConstraintSystem] Port function parameter type mismatch diagnostics.
2019-12-11 14:33:07 -08:00
swift_jenkins
6b53fd184c Merge remote-tracking branch 'origin/master' into master-next 2019-12-11 11:00:08 -08:00
Brent Royal-Gordon
7543a89cc4 Merge pull request #27683 from brentdax/i-understood-that-reference
[NFC] Distinguish references to names from declarations of those names by type
2019-12-11 10:50:57 -08:00
Holly Borla
51c7c8c8f1 [ConstraintSystem] Port function parameter type mismatch diagnostics. 2019-12-11 10:45:52 -08:00
swift_jenkins
27524eafc3 Merge remote-tracking branch 'origin/master' into master-next 2019-12-11 08:00:26 -08:00
Hamish Knight
a6168a93bb [CS] Don't adjust opened types of @dynamicMemberLookup overloa… (#28694)
[CS] Don't adjust opened types of @dynamicMemberLookup overloads
2019-12-11 07:56:47 -08:00
Brent Royal-Gordon
db15d82ffa [NFC] Miscellaneous improvements to Playground and PCMacro transforms 2019-12-11 00:55:18 -08:00
Brent Royal-Gordon
3570905613 [NFC] Update uses in TypeCheckConstraints
Seems to have been a mismerge or something?
2019-12-11 00:55:18 -08:00
Brent Royal-Gordon
6a8598a99c [NFC] Remove DeclNameRef staging calls 2019-12-11 00:55:18 -08:00
Brent Royal-Gordon
addbe3e5ed [NFC] Thread DeclNameRef through most of the compiler
This huge commit contains as many of the mechanical changes as possible.
2019-12-11 00:55:18 -08:00
Brent Royal-Gordon
da88512eda [NFC] Take DeclNameRef in UnqualifiedLookup and lookupQualified() 2019-12-11 00:55:17 -08:00
Brent Royal-Gordon
9a57554bdf [NFC] DeclNameRef-ify qualified and unqualified lookup 2019-12-11 00:55:17 -08:00
Brent Royal-Gordon
36b949c555 [NFC] Improve identifier usage in AST transforms
Change the various AST transforms to use prebuilt DeclName constants more heavily rather than an ad-hoc mix of Identifiers, string literals, std::strings, and StringRefs with questionable memory management.
2019-12-11 00:45:08 -08:00
Brent Royal-Gordon
1df792ae9f [NFC] Convert TypeRepr to use DeclName(Loc)?
Replaces `ComponentIdentTypeRepr::getIdentifier()` and `getIdLoc()` with `getNameRef()` and `getNameLoc()`, which use `DeclName` and `DeclNameRef` respectively.
2019-12-11 00:45:08 -08:00
Brent Royal-Gordon
8551b32af2 [NFC] Make EnumElementPattern carry a DeclName
This has the side effect of threading compound name support through more enum pattern code, although it’s still not complete.
2019-12-11 00:45:07 -08:00
Brent Royal-Gordon
93b9c0b0c6 [NFC] Use ASTContext::Id_Void constant in simplifyTypeExpr check 2019-12-11 00:45:07 -08:00
Brent Royal-Gordon
a3035eb925 [NFC] Add helpers for unresolved AST node synthesis
This change adds UnresolvedDotExpr::createImplicit() and UnresolvedDeclRefExpr::createImplicit() helpers. These calls simplify several tedious bits of code synthesis that would otherwise become even more tedious with DeclNameRef in the picture.
2019-12-11 00:45:07 -08:00
swift_jenkins
3140acc993 Merge remote-tracking branch 'origin/master' into master-next 2019-12-10 21:20:05 -08:00
Hamish Knight
bea99b194b [CS] Attempt to simplify a member constraint immediately
Now that overload binding for dynamic member
lookup occurs after having recorded the
`subscript(dynamicMember:)` overload, we can
attempt simplification of this constraint right
away.
2019-12-10 18:02:15 -08:00
Hamish Knight
58884002d8 [CS] Don't adjust opened types of @dynamicMemberLookup overloads
Rather than adjusting the opened types for choices
referring to `subscript(dynamicMember:)` down to
the result type, only use the result type to
bind the overload type variable. This avoids the
need for a couple of special cases in CSApply.

To facilitate this change, add
`ConstraintSystem::bindOverload`, which deals with
adding the necessary constraints to bind the
overload's type variable. The eventual goal here
is to remove `adjustTypeOfOverloadReference`, with
adjustments to the opened type being moved to
`getTypeOfMemberReference`, and the adding of
constraints being moved to `bindOverloadType`.
2019-12-10 18:02:14 -08:00
Robert Widmann
785bda0250 Discard ResolveEncodable and ResolveDecodable 2019-12-10 16:28:51 -08:00
Robert Widmann
fbdd907a1f Add a way to just synthesize CodingKeys 2019-12-10 16:28:51 -08:00
Robert Widmann
9c234d5d17 Make deriving CodingKeys Cheap
The semantic checks for CodingKeys are being duplicated across the value witness synthesis code paths.  Just synthesize a CodingKeys enum and let validateCodingKeysEnum do the heavy lifting when we actually need to go emit diagnostics.
2019-12-10 16:28:51 -08:00
Robert Widmann
fefb800e74 Eliminate CodableConformanceType
CodableConformanceType::TypeNotValidated is unused since the InterfaceTypeRequest changes went through.  We can just use the validity of the ProtocolConformanceRef here.
2019-12-10 16:28:51 -08:00
Robert Widmann
06d27f08fd Define @_implicitly_synthesizes_nested_requirement
State the previously unstated nested type requirement that CodingKeys adds to the witness requirements of a given type. The goal is to make this member cheap to synthesize, and independent of the expensive protocol conformance checks required to append it to the member list.

Further, this makes a clean conceptual separation between what I'm calling "nested type requirements" and actual type and value requirements.

With luck, we'll never have to use this attribute anywhere else.
2019-12-10 16:28:50 -08:00
swift_jenkins
51b2144406 Merge remote-tracking branch 'origin/master' into master-next 2019-12-10 16:20:02 -08:00
Joe Groff
fb34044408 Merge remote-tracking branch 'origin/master' into master-next 2019-12-10 12:46:41 -08:00
Joe Groff
4742968454 Serialization support for SIL substituted function types 2019-12-10 12:09:06 -08:00
Joe Groff
84e20b630e SIL parser support for substituted function types 2019-12-10 12:08:42 -08:00
Hamish Knight
73098687b0 [CS] Pass SelectedOverload in a couple of places (#28649)
[CS] Pass SelectedOverload in a couple of places
2019-12-10 11:13:46 -08:00
Robert Widmann
a9ce2babd2 Merge pull request #28624 from CodaFi/heres-looking-up-you-kid
[NFC] Pull Semantic Member Synthesis into TypeChecker's Lookup Entrypoints
2019-12-10 10:40:31 -08:00
Dan Zheng
0585eb0e90 [AutoDiff upstream] Add @derivative(of:) attribute. (#28321)
The `@derivative(of:)` attribute registers a function as a derivative of another
function. This patch adds the `@derivative(of:)` attribute definition, syntax,
parsing, and printing.

Resolves TF-826.

Todos:
- Type-checking (TF-829).
- Serialization (TF-837).
2019-12-10 09:29:43 -08:00
Varun Gandhi
3cc452eee8 Merge pull request #28479 from varungandhi-apple/vg-allow-clang-types-in-convention-attr
Allow spelling out a C type in the convention attribute.
2019-12-09 18:36:56 -08:00
Hamish Knight
54bfa59348 [CS] Suppress a no-asserts warning 2019-12-09 15:27:58 -08:00
Hamish Knight
5d7fb487eb [CS] Remove a couple of dead types 2019-12-09 15:27:57 -08:00
Hamish Knight
e2fbe3a020 [CS] Pass SelectedOverload in a couple of places
Rather than passing separate parameters for the
choice, openedType, and openedFullType, just pass
the selected overload.
2019-12-09 15:27:57 -08:00
Holly Borla
edb4e70d66 Merge pull request #28600 from hborla/tuple-mismatch-diagnostics
[ConstraintSystem] Port tuple type mismatch diagnostics
2019-12-09 13:26:34 -08:00
Robert Widmann
7c46df68c7 Merge pull request #28633 from kitaisreal/classes-equatable-hashable-synthesis-diagnostics
[Type checker]: Classes `Hashable` and `Equatable` synthesis diagnostic
2019-12-09 13:16:18 -08:00
Holly Borla
94e9fd1d67 [Diagnostics] Use a generic "tuple type not convertible" error message
when there is no contextual type.
2019-12-09 11:25:32 -08:00
Holly Borla
50abedd45c [Diagnostics] Keep track of the indices of the tuple elements whose
types do not match in AllowTupleTypeMismatch/TupleContextualFailure.
2019-12-09 11:04:34 -08:00
Pavel Yaskevich
3d7306a066 Merge pull request #28630 from xedin/dynamic-member-diagnostics
[Diagnostics] Port/Improve diagnostics for `@dynamicCallable` and `callAsFunction`
2019-12-09 10:24:27 -08:00
Hamish Knight
bfdc2c701b [CS] Change openedType -> openedFullType in a couple of cases
This helps avoid confusion with SelectedOverload's
`openedType` member.
2019-12-09 07:53:52 -08:00
Hamish Knight
aa3e2d510c [CS] Stop passing FunctionRefKind in a couple of places
We can retrieve it from the passed OverloadChoice.
2019-12-09 07:53:52 -08:00
Kita, Maksim
9963fce1f7 SR-11902: Fixed code review issues. Updated tests. 2019-12-07 15:23:31 +03:00
Kita, Maksim
30faac8124 SR-11902: Improve Error Message for Auto-synthesized Equatable Conformance on Classes
1. Added note for 'Hashable' and 'Equatable' protocol synthesis for classes.
2019-12-07 14:09:56 +03:00
Brent Royal-Gordon
e1e7a3fe75 Merge pull request #25656 from brentdax/file-name-basis
Shorten #file and add #filePath (behind an experimental flag)
2019-12-06 21:34:58 -08:00
Pavel Yaskevich
61b7b3b28d Merge pull request #28626 from xedin/rdar-57668763
[ConstraintSystem] Fix a case of too eager force optional unwrap with…
2019-12-06 17:10:56 -08:00