Commit Graph

2253 Commits

Author SHA1 Message Date
Holly Borla
c60b4860ab Merge pull request #64498 from hborla/diagnose-pack-outside-expansion-expr
[ConstraintSystem] Enforce `TVO_CanBindToPack`, and diagnose pack references outside of pack expansion expressions.
2023-03-21 14:00:52 -07:00
Alex Hoppen
9bd880ddde Merge pull request #64405 from ahoppen/ahoppen/fix-locator-simplification
[CS] Fix locator simplification with 'Member' path element
2023-03-21 09:19:14 -07:00
Holly Borla
cb19fc3a71 [ConstraintSystem] Enforce TVO_CanBindToPack, and diagnose pack references outside
of pack expansion expressions.
2023-03-20 20:13:48 -07:00
Alex Hoppen
cebc084367 [CS] Fix locator simplification with 'Member' path element
Previously, a `Member` path element in a `ConstraintLocator` was simplified to the base on which the member was accessed. This is incorrect.
2023-03-20 09:19:21 -07:00
Pavel Yaskevich
ff51291d30 [CSSimplify] Don't enable OneWayBindParam for result builder transformed closures
This means two things:

- transformed closures behave just like regular multi-statement closures
- It's now possible to pass partially resolved parameter types into
  the closure which helps with diagnostics.
2023-03-16 16:16:57 -07:00
Luciano Almeida
4d981e3c0b Merge pull request #63904 from LucianoPAlmeida/ambiguous-overload
[Sema] Diagnose function coercion ambiguity
2023-03-15 23:18:00 -03:00
Pavel Yaskevich
a7fbc04307 [CSSimplify] PointerToCPointer: Allow element type inference for "argument" pointers
If the type of the "argument" pointer is not yet resolved the solver
should equate it to that of the "parameter" pointer as regular
conversions do.
2023-03-14 15:06:24 -07:00
Pavel Yaskevich
e4eb271359 [CSSimplify] Implement ArrayToCPointer conversion
Extends implementation to support conversions between arrays
and pointers that are allowed by the SE-0324 proposal.

Resolved: rdar://99089335
2023-03-14 14:36:52 -07:00
Pavel Yaskevich
438ee330f1 [ConstraintSystem] Add new conversion kind - ArrayToCPointer
It's `ArrayToPointer` conversion that has PointerToCPointer
semantics for (un-)signed integer element types.
2023-03-14 11:22:52 -07:00
Hamish Knight
c77caf2c72 [CS] NFC: Simplify SyntacticElementTarget construction for ExprPattern 2023-03-14 11:56:01 +00:00
Pavel Yaskevich
c106705883 [CSSolver] NFC: Replace some uses of last() with endsWith() 2023-03-13 11:24:15 -07:00
Luciano Almeida
d5a9d6ab83 [ConstraintSystem] Introduce new locator path elemet to identify coercion 2023-03-11 18:47:53 -03:00
Pavel Yaskevich
a52800031a Merge pull request #64259 from xedin/variadic-matching-fix
[CSSimplify] Variadics: Allow unlabeled matching after pack expansion…
2023-03-10 08:06:46 -08:00
Pavel Yaskevich
36200101f8 [CSSimplify] Variadics: Allow unlabeled matching after pack expansion argument
Remove a bit of logic from `matchCallArgumentsImpl` that prevented
unlabeled argument matching after pack expansion argument until next
labeled argument because it incorrectly assumed that it represents
variadic forwarding.
2023-03-09 15:25:43 -08:00
Pavel Yaskevich
70c370d0b6 [CSSimplify] Propagate contextual result type into result builder transformed closure
Propagate fully or partially resolved contextual type down into
the body of result builder transformed closure by eagerly binding
intermediate body result type to the contextual one. This helps to
determine when closure body could be solved early.

Resolves: rdar://106364495
2023-03-08 10:46:02 -08:00
Holly Borla
df755d4f90 Merge pull request #64192 from xedin/rdar-106364495
[CSSimplify] Propagate contextual result type into result builder tra…
2023-03-08 09:53:38 -08:00
Hamish Knight
fdc9817471 Merge pull request #64174 from hamishknight/pattern-requests 2023-03-08 10:52:40 +00:00
Pavel Yaskevich
3ff03469e7 [CSSimplify] Propagate contextual result type into result builder transformed closure
Propagate fully or partially resolved contextual type down into
the body of result builder transformed closure by eagerly binding
intermediate body result type to the contextual one. This helps to
determine when closure body could be solved early.

Resolves: rdar://106364495
2023-03-07 16:17:10 -08:00
Hamish Knight
98855963ac [Sema] Introduce EnumElementExprPatternRequest
This is needed to ensure we only ever synthesize
a single unique ExprPattern when solving an
EnumElementPattern that we failed to lookup a
member for.
2023-03-07 15:16:36 +00:00
Hamish Knight
37b0a6074f [Sema] Introduce ExprPatternMatchRequest
This replaces `synthesizeTildeEqualsOperatorApplication`,
and synthesizes the match expression and var
on-demand.

Additionally, it pushes the lookup logic into
pre-checking.
2023-03-07 15:16:35 +00:00
Holly Borla
75c1b6e199 Merge pull request #64166 from hborla/parameter-pack-substitution 2023-03-07 06:39:50 -08:00
Hamish Knight
43f0694fa3 Merge pull request #64149 from hamishknight/more-nfc-changes 2023-03-07 10:49:54 +00:00
John McCall
db4b16e3dd [WIP] Always use PackTypes as the substitutions for type parameter packs
This simplifies the representation and allows clients to handle fewer
cases.  It also removes an ambiguity in the representation which could
lead us to have two canonical types for the same type.

This is definitely not working yet, but I'm not making progress on
it quickly enough to unblock what we need to unblock; it'll have to
be fixed in parallel.
2023-03-06 17:08:35 -08:00
Holly Borla
b0211233a9 Merge pull request #64146 from hborla/shape-of-assertion
[ConstraintSystem] Don't propagate errors for invalid `DeclRef`s in the pattern of a pack expansion.
2023-03-06 14:23:13 -08:00
Hamish Knight
2976edbe20 [CS] Rename SolutionApplicationTarget -> SyntacticElementTarget 2023-03-06 20:54:06 +00:00
Holly Borla
721b846e16 [ConstraintSystem] Don't propagate errors for invalid DeclRefs in the pattern
of a pack expansion.
2023-03-06 10:51:43 -08:00
Pavel Yaskevich
342e5f6725 Merge pull request #64036 from xedin/rdar-106054263
[CSSimplify] Detect and diagnose generic argument mismatches individually
2023-03-06 10:18:09 -08:00
Holly Borla
8012e45109 [Diagnostics] Diagnose pack element expressions containing a non-pack subexpression. 2023-03-05 00:11:54 -08:00
Pavel Yaskevich
b7745b04bd [CSSimplify] Detect and diagnose generic argument mismatches individually
Generic arguments types are not always resolved enough to enable
aggregated mismatch fixes, which means that the solver should be
able to handle standalone generic argument matching constraints
and create a fix per mismatch location to coalesce them during
diagnostics.

Resolves: rdar://106054263
2023-03-04 21:57:53 -08:00
Holly Borla
e063f02a42 [ConstraintSystem] Handle invalid pack element bindings during PackElementOf
simplification.
2023-03-04 19:43:43 -08:00
Joe Groff
5ef0c4eaad Merge pull request #64058 from jckarter/minimize-abi-effect-of-parameter-modifiers-b
Only mangle `borrowing`/`consuming` when they would change ABI.
2023-03-03 07:01:50 -08:00
Joe Groff
5345e982e9 Only mangle borrowing/consuming when they would change ABI.
`__shared` and `__owned` would always get mangled, even when they don't have any effect
on ABI, making it unnecessarily ABI-breaking to apply them to existing API to make
calling conventions explicit. Avoid this issue by only mangling them in cases where they
change the ABI from the default.
2023-03-02 21:33:29 -08:00
Holly Borla
ad3a385cd2 [Sema] Eliminate single-element tuples after parameter pack substitution. 2023-03-02 19:37:52 -08:00
Pavel Yaskevich
1dd6d349d1 [ConstraintSystem] NFC: Pass down matcher flags to repairFailures 2023-03-02 11:02:30 -08:00
Andrew Trick
f1ff6958a3 Merge pull request #63825 from atrick/diagnose-implicit-raw-bitwise
Warn on implicit pointer conversion from nontrivial inout values.
2023-03-02 10:57:30 -08:00
Holly Borla
b78b6b9a77 Merge pull request #63991 from hborla/materialize-pack-from-tuple
[ConstraintSystem] Implement type checking for converting a tuple to a pack using the `.element` syntax.
2023-03-01 16:19:33 -08:00
Hamish Knight
f6f5e89bcd Merge pull request #63996 from hamishknight/nfc-pattern-changes 2023-03-01 21:27:34 +00:00
Hamish Knight
9b8bc6033c [AST] NFC: Refactor ExprPattern construction
Introduce 3 separate factory constructors, and
remove the ability to specify the match expr and
var, as those should be synthesized on-demand.
2023-03-01 15:53:41 +00:00
Holly Borla
509188630b [ConstraintSystem] Implement type checking for converting a tuple to a
pack using the `.element` syntax.
2023-02-28 22:56:59 -08:00
Kavon Farvardin
f41ed5926b implement the forget statement
Currently, this is staged in as `_forget`,
as part of SE-390. It can only be used on
`self` for a move-only type within a consuming
method or accessor. There are other rules, see
Sema for the details.

A `forget self` really just consumes self and
performs memberwise destruction of its data.
Thus, the current expansion of this statement
just reuses what we inject into the end of a
deinit.

Parsing of `forget` is "contextual".
By contextual I mean that we do lookahead to
the next token and see if it's identifier-like.
If so, then we parse it as the `forget` statement.
Otherwise, we parse it as though "forget" is an
identifier as part of some expression.

This way, we won't introduce a source break for
people who wrote code that calls a forget
function.

This should make it seamless to change it from
`_forget` to `forget` in the future.

resolves rdar://105795731
2023-02-28 21:15:17 -08:00
Alex Hoppen
0ed6deea9b Merge pull request #63712 from ahoppen/ahoppen/completion-misc
[CodeCompletion] Collection of minor changes to prepare migrating remaining completion kinds to solver-based
2023-02-28 16:02:58 +01:00
Andrew Trick
185e6fabd5 Add TypeBase::isArrayType helper API.
This is also needed in SIL diagnostics, not just Sema diagnostics,
because implicit Array conversion generates special SIL patterns.
2023-02-27 21:51:17 -08:00
Pavel Yaskevich
dd353b948b Merge pull request #63794 from xedin/rdar-105348781
[CSSimplify] Make "force optional unwrap" fix less aggressive
2023-02-24 10:47:23 -08:00
Alex Hoppen
46f5119113 [CodeCompletion] Don’t crash if constructors in member lookup have an error type 2023-02-22 22:33:42 +01:00
Luciano Almeida
1e4fa6a08d [Sema] Fix variable invalid optional chaining in if context diagnostic 2023-02-22 17:52:02 -03:00
Pavel Yaskevich
084543566e [CSSimplify] Make "force optional unwrap" fix less aggressive
Don't attempt the fix until sub-expression is resolved
if chain is not using leading-dot syntax. This is better
than attempting to propagate type information down
optional chain which is hard to diagnose.

Resolves: rdar://105348781
2023-02-20 16:24:11 -08:00
Hamish Knight
c82189dc02 Merge pull request #63747 from hamishknight/oh-bool 2023-02-18 14:57:24 +00:00
Hamish Knight
eac3fb4506 [CS] NFC: Default the allowFreeTypeVariables parameter
All but one client wants to set this to anything
other than `FreeTypeVariableBinding::Disallow`.
2023-02-17 20:58:46 +00:00
L-j-h-c
913dcd62b8 [Gardening] fix typos across docs and codebase
fix typos across docs and codebase
2023-02-17 23:55:16 +09:00
Pavel Yaskevich
4b6b5109f4 Merge pull request #63694 from apple/revert-63140-two-way-args-in-result-builders
Revert "[CSSimplify] Don't enable `OneWayBindParam` for result builder transf…"
2023-02-16 09:40:11 -08:00