Commit Graph

2217 Commits

Author SHA1 Message Date
Luciano Almeida
187cf81d16 [CS] Increase the score for implicit global actor function conversion 2022-12-12 00:08:18 -03:00
Alex Hoppen
9a0a7722f9 [IDE] Disable a few code completion specific paths for solver-based CursorInfo
The lexer will be responsible for knowing whether we have a code completion token, everything else will also work for other IDE inspection features.

The changes start to really make sense once I rename CodeCompletion -> IDEInspection in a lot of places.
2022-12-10 12:12:21 +01:00
Pavel Yaskevich
7588434007 [CSSimplify] Account for tuple splat when resolving closure parameters
SE-0110 allows tuple slat between function types. The solver needs to
account for that when trying to infer parameter types from context
while resolving a closure in order to propagate types and speed up
type-checking.

Resolves: https://github.com/apple/swift/issues/62390
2022-12-05 00:28:52 -08:00
Slava Pestov
b122977671 AST: Record both LHS and RHS index in PackExpansionMatcher.cpp 2022-12-01 15:25:20 -05:00
Doug Gregor
64f2c8ef0c Address a few comments about the specialization arguments constraint. 2022-11-28 18:33:11 -08:00
Doug Gregor
8adee85cb6 [Macros] Add support for explicit generic arguments of macros.
Enable type checking support for explicitly specifying generic arguments to
a macro, e.g., `#stringify<Double>(1 + 2)`. To do so, introduce a new
kind of constraint that performs explicit argument matching against the
generic parameters of a macro only after the overload is chosen.
2022-11-28 18:32:43 -08:00
Pavel Yaskevich
c17d35dc3e Merge pull request #62146 from xedin/rdar-102085039
[AST] `getParameterAt` should check index before retrieving it
2022-11-28 10:01:51 -08:00
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Pavel Yaskevich
77fb90ee19 [Sema/SILGen] Add asserts to getParameterAt call sites that expect non-null parameter 2022-11-17 11:52:00 -08:00
Angela Laar
dcfeff715b Merge pull request #61944 from angela-laar/refactor-generate-constraints-for-closures
[CSClosure] Refactor generateConstraints
2022-11-17 07:44:05 -08:00
Holly Borla
72e296e32b Merge pull request #62140 from hborla/variadic-generics-locators
[ConstraintSystem] Add locator path elements for pack expansion patterns and pack shapes.
2022-11-16 19:22:27 -08:00
Holly Borla
16b9654d4b [ConstraintSystem] Use specific locators when matching pack types. 2022-11-16 09:24:21 -08:00
Holly Borla
72d87b5ca5 [ConstraintSystem] Add a locator path element for the pattern of a pack expansion. 2022-11-16 09:06:58 -08:00
Holly Borla
5218a0d77a [ConstraintSystem] Add a locator path element for pack shapes, and use it for
type variables representing pack shapes.
2022-11-15 21:33:17 -08:00
Doug Gregor
e8838bc169 Merge pull request #62123 from DougGregor/pretty-stack-trace-macros 2022-11-15 19:26:24 -08:00
Angela Laar
8257cc1e10 [CSClosure] Generate constraints for empty closure body
We should do this in the ConstraintGenerator instead of in a ConstraintSystem method.
2022-11-15 16:14:38 -08:00
Angela Laar
b4549d63f0 [Constraint System] Refactor generateConstraints
We don't need a separate generateConstraints function for closures.
2022-11-15 16:13:58 -08:00
Doug Gregor
636e0145e0 [Constraint system] Make sure to check NULL for getParameterList(). 2022-11-15 15:00:52 -08:00
Doug Gregor
51fcde7b76 Merge pull request #62086 from DougGregor/macro-decl 2022-11-13 20:25:48 -08:00
Doug Gregor
bdf7762f55 [Macros] Start threading argument labels through macros. 2022-11-13 14:38:07 -08:00
Slava Pestov
30a1211a3b AST: Move getReducedShape() from CSSimplify.cpp to a method on TypeBase 2022-11-12 02:13:54 -05:00
Slava Pestov
16a84fc382 AST: Rename ProtocolDecl::getExistentialType() to getDeclaredExistentialType() 2022-11-07 18:38:06 -05:00
Pavel Yaskevich
cf5d41c6dd [CSSimplify] Increase contextual element mismatch impact when related to Any{Hashable}
Impact is higher in this case because it means that other collection
or a pattern (in case of for-in loop) is structurally incompatible with
collection's element type.
2022-11-01 17:09:46 -07:00
Pavel Yaskevich
91c013cae6 [CSSimplify] Don't record a fix if element/pattern type is a hole
The situation would already be "fixed" at the source.
2022-10-31 12:21:45 -07:00
Pavel Yaskevich
d56e62d65c [CSSimplify] Bind for-in patterns to holes if element type is Any
If the element type is `Any` i.e. `for (x, y) in [] { ... }`
it would never match the pattern and the pattern (`rhs` = `(x, y)`)
doesn't have any other source of contextual information,
so instead of waiting for elements to become holes with an
unrelated fixes, let's proactively bind all of the pattern
elements to holes.

Resolves:  rdar://100343275
2022-10-31 12:21:45 -07:00
Slava Pestov
3adb1dd1d0 Sema: Remove OpenParameterPackElements 2022-10-27 17:00:22 -04:00
Slava Pestov
46e782200a Sema: More complex PackExpansionType matching 2022-10-27 13:46:58 -04:00
Slava Pestov
12d21e42aa Sema: Handle PackExpansionType inside PackType when splitting up ConformsTo/SubclassOf constraints 2022-10-27 13:46:58 -04:00
Slava Pestov
9e5371d11a Sema: Fix long line 2022-10-27 13:46:58 -04:00
Doug Gregor
ed935297fa Merge pull request #61321 from DougGregor/open-existential-for-optional-param 2022-10-26 20:54:22 -07:00
Holly Borla
e2a41d126a Merge pull request #61737 from hborla/generic-environment-helpers
[GenericEnvironment] Add helper methods for mapping pack types to opened element types and vice versa.
2022-10-26 16:16:12 -07:00
Holly Borla
d09ea98ba6 [GenericEnvironment] Add helper methods to map pack interface types to
element archetypes, and element interface types to pack archetypes.
2022-10-26 00:04:56 -07:00
Holly Borla
1ab9f8f7c6 [AST] Add helper methods to GenericTypeParamType for converting a given type
parameter to and from a pack type parameter.
2022-10-26 00:04:56 -07:00
Slava Pestov
bb045423b3 Sema: Add diagnostics for ShapeOf constraint 2022-10-25 13:20:38 -04:00
Slava Pestov
731d903a43 Sema: Add ConstraintKind::ShapeOf 2022-10-25 12:55:04 -04:00
Holly Borla
25eb9efc60 Merge pull request #61678 from hborla/pack-expansion-expression-checking
[Sema] Implement basic type checking for pack expansion expressions.
2022-10-25 08:07:59 -07:00
Holly Borla
032c511754 [ConstraintSystem] Add a PackElementOf constraint to delay mapping opened
element pattern types to pattern archetypes until after type variables are
resolved.
2022-10-24 19:46:44 -07:00
Pavel Yaskevich
927b846a8f Merge pull request #61672 from xedin/rdar-101412179
[CSSimplify] Diagnose contextual mismatch between fully resolved depe…
2022-10-24 19:36:51 -07:00
Holly Borla
5584752b3e [ConstraintSystem] Implement value parameter pack forwarding. 2022-10-22 13:41:48 -07:00
Slava Pestov
c34f8d3a0b Sema: Check AnyObject requirements of variadic generic functions 2022-10-22 01:17:13 -04:00
Slava Pestov
f3fcc44d17 Sema: Handle PackElement locator in repairFailures() 2022-10-21 22:17:38 -04:00
Slava Pestov
cbce4a52ca Sema: Support PackExpansionTypes in matchPackTypes() 2022-10-21 22:17:38 -04:00
Slava Pestov
7d0de80bfc Sema: Check requirements when calling a variadic generic function 2022-10-21 22:17:38 -04:00
Slava Pestov
46d5fa68f9 Sema: Introduce ConstraintKind::SubclassOf 2022-10-21 22:17:38 -04:00
Slava Pestov
c41341d98c Sema: Fix matchCallArguments() to allow empty pack type bindings
Thanks to @hborla for suggesting this fix.
2022-10-21 22:17:08 -04:00
Slava Pestov
68514b10b5 AST: Introduce ElementArchetypeType 2022-10-21 21:55:35 -04:00
Pavel Yaskevich
a796c45e4c [CSSimplify] Diagnose contextual mismatch between fully resolved dependent member types
If a constraint has fully resolved but incorrect (not simplifiable)
dependent member types, let's diagnose that as a contextual mismatch
instead of failing (which sometimes leads to a fallback diagnostic).

Resolves: rdar://101412179
2022-10-21 22:28:31 +01:00
Slava Pestov
4e70f4fb19 Sema: Simplify matching logic for PackExpansionType 2022-10-17 23:23:09 -04:00
Slava Pestov
7e9995b1bc Sema: Use ParamPackMatcher in matchFunctionTypes() 2022-10-16 21:37:25 -04:00
Slava Pestov
9d16b821a8 AST: Move Sema's TuplePackMatcher to AST
I'm also going to use it in TypeMatcher, for the Requirement Machine's
same-type requirement desugaring.
2022-10-16 21:37:25 -04:00