Commit Graph

1991 Commits

Author SHA1 Message Date
Pavel Yaskevich
48cdb58a91 [CSFix] Add a specific kind for AllowInOutConversion 2021-09-10 12:55:26 -07:00
Pavel Yaskevich
4f5b33b4dd [CSFix] Add a specific kind for IgnoreAssignmentDestinationType 2021-09-10 12:48:14 -07:00
Pavel Yaskevich
2e5ab93f0f [CSFix] Add a specific kind for IgnoreContextualType 2021-09-10 12:42:34 -07:00
Pavel Yaskevich
04b35e4c26 [CSFix] Add a specific kind for AllowAutoClosurePointerConversion 2021-09-10 12:37:08 -07:00
Pavel Yaskevich
934e875e7f [CSFix] Add a specific kind for DropAsyncAttribute 2021-09-10 12:30:02 -07:00
Pavel Yaskevich
d1d2846baa [CSFix] Add a specific kind for DropThrowsAttribute 2021-09-10 12:21:26 -07:00
Pavel Yaskevich
057563e783 [CSFix] Add a specific kind for AddSendableAttribute 2021-09-10 12:15:10 -07:00
Hamish Knight
77e6c083f3 [AutoDiff] [CS] Formalize function tupling behavior for @differentiable
Reject tupling into a `@differentiable` function,
and allow the stripping of `@noDerivative` given
we're also losing `@differentiable`.
2021-09-09 21:46:32 +01:00
Hamish Knight
cab39bf26c [CS] Formalize param flag handling for imploding params
By default avoid imploding params that have parameter
flags, but carve out exceptions for ownership flags,
which can be thunked, and `@_nonEphemeral` which can
be freely dropped without issue.
2021-09-09 21:46:31 +01:00
Hamish Knight
af14bba276 [AST] Simplify AnyFunctionType::composeTuple
Remove the canonicalVararg parameter and
CanParamArrayRef wrapper. Almost none of the
callers want canonicalVararg, and the one that
does calls `getCanonicalType` on the result
anyway.
2021-09-09 21:46:31 +01:00
Pavel Yaskevich
3bbde55052 [ConstraintSystem] Detect and diagnose incorrectly typed weak declarations
All `weak` declarations are supposed to have an optional type.
Detect situations when is not an optional, wrap it as a fix,
and diagnose the problem.
2021-09-08 09:39:54 -07:00
Pavel Yaskevich
3fac0fefc9 [CSFix] Add a skeleton of weak pattern with non-optional type fix 2021-09-07 17:36:56 -07:00
Holly Borla
df76275116 Merge pull request #39169 from hborla/bogus-missing-function-call-error
[ConstraintSystem] Fix a bogus missing function call error message.
2021-09-07 11:24:50 -07:00
LucianoAlmeida
63330f9a6e [Sema] Do not emit warning about conditional cast bridge when from type is optional 2021-09-07 01:43:58 -03:00
Holly Borla
03777c3fc9 [Diagnostics] Remove ContextualFailure::diagnoseMissingFunctionCall.
Instead, always diagnose missing call errors via MissingCallFailure.
2021-09-06 20:05:13 -07:00
Holly Borla
dc10f60198 [ConstraintSystem] Don't attempt missing function call diagnostics if
there is no function expression explicitly written in the source code.
2021-09-06 19:50:00 -07:00
Hamish Knight
dc60996f89 Merge pull request #38836 from hamishknight/toil-and-tuple 2021-09-04 19:30:04 +01:00
Pavel Yaskevich
e4e2cdd99b Merge pull request #39074 from LucianoPAlmeida/minor-fixes
[NFC] Remove old comment related to port diagnostics to new framework
2021-09-03 17:58:39 -07:00
Holly Borla
09f2ca7f25 Merge pull request #39146 from hborla/wrapped-param-diagnostics
[ConstraintSystem] Fix a misleading argument mismatch error when using wrapped parameters.
2021-09-02 22:10:21 -07:00
Holly Borla
947a6c32a5 [ConstraintSystem] In the solver, only generate constraints for wrapped
parameter attributes for closure parameters.

For regular function parameters, these constraints will have already been
generated and solved when computing the backing property wrapper type at
the function declaration. If the solver also generates these constraints
when type checking a function call, it leads to misleading diagnostics
about an argument mismatch that will appear at the function declaration
instead of the call-site.
2021-09-02 17:37:44 -07:00
Konrad `ktoso` Malawski
b73050e49e Merge pull request #39095 from AnthonyLatsis/se-309
SE-0309: Unlock existential types for all protocols
2021-09-02 11:27:39 +09:00
Holly Borla
d2bdbd6208 [ConstraintSystem] Fix a silly crash in repairFailures.
The code checked if the last element of locator path vector
is a certain kind of element without first ensuring that the
vector isn't empty.
2021-09-01 13:48:29 -07:00
Hamish Knight
3e28bbbd2c Update for review feedback
- Remove OriginalArguments in favor of storing the
pre-rewritten argument list, which simplifies things
nicely
- Adopt llvm::indexed_accessor_iterator
2021-09-01 18:40:29 +01:00
Hamish Knight
8c2b88abc0 [CS] Adopt ArgumentList
- Explicitly limit favoring logic to only handle
unary args, this seems to have always been the
case, but needs to be handled explicitly now that
argument lists aren't exprs
- Update the ConstraintLocator simplification to
handle argument lists
- Store a mapping of locators to argument lists
in the constraint system
- Abstract more logic into a getArgumentLocator
method which retrieves an argument-to-param locator
from an argument anchor expr
2021-09-01 18:40:25 +01:00
Amritpan Kaur
9a4572e17f [NFC] Rename argNumber to avoid confusion with numArgs. 2021-08-31 09:28:52 -07:00
Anthony Latsis
e49ca21bf0 Sema: Check for invalid reference *before* checking for unsupported existential member access 2021-08-31 19:21:27 +03:00
Rintaro Ishizaki
49547a5378 [NFC][Basic] Import llvm::isa_and_nonnull to 'swift' namespace
Just for convenicence.

* Replace `llvm::isa_and_nonnull` with imported `isa_and_nonnull`
* Repalce some `EXPR && isa<T>(EXPR)` with `isa_and_nonnull<T>(EXPR)`
2021-08-27 11:36:21 -07:00
LucianoAlmeida
78ffd65187 [NFC] Remove old comment related to port diagnostics to new framework 2021-08-27 09:21:16 -03:00
Kavon Farvardin
c0607b345f Revert "Merge pull request #33767 from theblixguy/chore/remove-self-or-associated-type-diagnostic"
The following regression test added for this feature is not passing:

Swift(linux-x86_64) :: decl/protocol/protocols_with_self_or_assoc_reqs_executable.swift

with a compiler crash happening during SILFunctionTransform "Devirtualizer".

Reverting to unblock CI.

This reverts commit f96057e260, reversing
changes made to 3fc18f3603.
2021-08-26 16:46:42 -07:00
Konrad `ktoso` Malawski
f96057e260 Merge pull request #33767 from theblixguy/chore/remove-self-or-associated-type-diagnostic
SE-0309: Unlock existential types for all protocols
2021-08-27 06:09:47 +09:00
LucianoAlmeida
b5dbb694cc [Sema][SR-14408] Increase the impact of missing member fix when member is on argument position 2021-08-25 20:13:46 -03:00
Pavel Yaskevich
beb23718f8 [Diagnostics] Improve diagnostics related to pointer initialization
- Increase impact of a generic pointer-to-pointer mismatch fix to
  match that of a contextual type failure. This allows more specific
  fixes to take precedence.

- De-prioritize generic argument mismatch fix when both types are
  pointers. This allows pointer-to-pointer conversion produce a
  more specific fix.

- De-prioritize fixes that involve `Builtin.RawPointer` or `OpaquePointer`
  in parameter positions. This helps to produce better diagnostics
  for argument mismatches during pointer initialization e.g.
  `UnsafeRawPointer(<pointer>)`.
2021-08-20 15:44:56 -07:00
Pavel Yaskevich
d5b30a671b Merge pull request #38941 from xedin/improve-inout-variadic-inference-for-closures
[ConstraintSystem] Always propagate inout/variadic flags to type-less…
2021-08-20 09:51:53 -07:00
Frederick Kellison-Linn
5f07747cb3 [Sema] Diagnose user-specified placeholders which couldn’t be resolved 2021-08-19 14:53:33 -04:00
Pavel Yaskevich
2aa98ebbf1 [ConstraintSystem] Always propagate inout/variadic flags to type-less closure parameters
Instead of infer all of the flags only for anonymous parameters,
let's infer inout/variadic for all type-less parameters - anonymous
and named. This allows to correctly form internal parameter type and
reduce amount of inference in the body (e.g. `BindParam` could be
simplified inline).
2021-08-18 14:53:55 -07:00
Doug Gregor
725624fc1b [SE-0286] Disable backward scanning for trailing closures in Swift 6 mode. 2021-08-18 05:54:54 -07:00
LucianoAlmeida
da234d0d74 [Sema][SR-15038] Use LocatorPathElt::GenericArgument to propagate (array, set, dictionary) generic elt in CheckedCast constraint and not record extraneous cast fixes for it 2021-08-16 21:34:29 -03:00
Anthony Latsis
9a522205ee Sema: Check for invalid reference *before* checking for unsupported existential member access 2021-08-16 18:30:26 +03:00
Robert Widmann
d75b34be22 Merge pull request #38753 from CodaFi/modulo-modules
[NFC] Remove Unused Module Parameter to Conformance Lookup
2021-08-11 10:36:39 -07:00
LucianoAlmeida
434ff12062 [Sema] Check for extra optionals injected on checked cast subexprs when recording extraneous cast warnings 2021-08-07 17:27:31 -03:00
Robert Widmann
592e90af9b Add Sugar for Variadics
We used to represent the interface type of variadic parameters directly
with ArraySliceType. This was awfully convenient for the constraint
solver since it could just canonicalize and open [T] to Array<$T>
wherever it saw a variadic parameter. However, this both destroys the
sugaring of T... and locks the representation to Array<T>. In the
interest of generalizing this in the future, introduce
VariadicSequenceType. For now, it canonicalizes to Array<T> just like
the old representation. But, as you can guess, this is a new staging
point for teaching the solver how to munge variadic generic type bindings.

rdar://81628287
2021-08-06 12:51:39 -07:00
Pavel Yaskevich
1509accca2 [ConstraintSystem] Open only directly declared opaque types related to return statements (#38762)
* [ConstraintSystem] NFC: Rename `openOpaqueTypeRec` and make `openOpaqueType` private for individual types

* [ConstraintSystem] Require a contextual purpose for `openOpaqueType(Type, ...)`

Some of the contexts require special handling e.g. return type of a function
can only open directly declared opaque result type(s), this would be
implemented in a follow-up commit.

* [ConstraintSystem] Open only directly declared opaque types related to return statements

Re-establish a check which would only open opaque types directly
declared in the return type of a function/accessor declaration,
otherwise constraint system would end up with type variables it
has no context for if the type had generic parameters.

Resolves: rdar://81531010
2021-08-05 20:45:46 -04:00
Robert Widmann
808220510e [NFC] Remove Unused Module Parameter to Conformance Lookup
It's been quite a long time since this unused parameter was introduced.
The intent is to produce the module as a root for the search - that is,
computing the set of conformances visible from that module, not the set
of conformances inside of that module. Callers have since been providing
all manner of module-scoped contexts to it.

Let's just get rid of it. When we want to teach protocol conformance
lookup to do this, we can revert this commit as a starting point and try
again.
2021-08-04 14:43:31 -07:00
willtunnels
319b3e64aa Add support for opaque result types in structural positions (#38392)
* [TypeResolver][TypeChecker] Add support for structural opaque result types

* [TypeResolver][TypeChecker] Clean up changes that add structural opaque result types
2021-08-03 23:45:02 -04:00
Doug Gregor
f9c34756ef Parameterize conformance lookup on whether "missing" conformances are allowed.
Many clients of the conformance lookup operations would prefer to get
an invalid conformance (== there is no conformance) rather than a
missing conformance. Parameterize the conformance lookup operations so
that most callers won't see missing conformances, by filtering them
out at the end. Opt-in those callers that do want to see missing
conformances so they can be diagnosed.
2021-08-03 00:10:45 -07:00
Holly Borla
2d851ff619 Merge pull request #38700 from hborla/improve-transitive-conformance-heuristic
[ConstraintSystem] Improve the "transitive conformance" heuristic and remove early conformance checking from `DisjunctionStep::shouldSkip`
2021-07-31 13:51:49 -07:00
Pavel Yaskevich
d61d9238e7 Merge pull request #38702 from nathawes/account-for-synthesized-args
[Sema][CSSimplify] Account for synthesized args when diagnosing labelling issues in matchCallArgumentsImpl
2021-07-30 09:09:38 -07:00
Nathan Hawes
82544451e6 [Sema][CSSimplify] Account for synthesized args when diagnosing labelling issues in matchCallArgumentsImpl
Unfulfilled params get arguments synthesized for them which are added
to the end of the argument list. Later logic to detect out-of-order
arguments and produce relabelling fixes didn't account for them though.
This improves several diagnostics for mislabelled call arguments in the
existing tests.
2021-07-30 14:53:34 +10:00
Holly Borla
0a617a8dc0 [ConstraintSystem] Fail transitive conformance constraints without checking
implicit conversions if the type does not conform and the current score
is equal to the best score.

Implicit conversions will always increase the score, so if the current
score is equal to the best score and an implicit conversion is needed to
satisfy a conformance requirement, the solver would end up pruning that
path later on anyway. It's better to fail early.
2021-07-29 19:27:35 -07:00
Hamish Knight
df566e3147 [AST] Rename decomposeInput/composeInput
Explicitly call out the fact we're dealing with
tuples.
2021-07-28 23:14:45 +01:00