Commit Graph

22 Commits

Author SHA1 Message Date
Doug Gregor
f316c5fcfe Update tests for map switching to typed throws 2024-01-12 10:17:59 -08:00
Doug Gregor
3baf6ac31a Revert "[Typed throws] Support overrides that are contravariant in the thrown error" 2023-11-16 10:40:23 -08:00
Doug Gregor
b93e228f9d Update tests for map switching to typed throws 2023-11-13 14:13:44 -08:00
Anthony Latsis
7fc8377e1c Gardening: Migrate test suite to GH issues: Constraints (1/5) 2022-08-17 15:21:51 +03:00
LucianoAlmeida
41e31e46eb [tests] Add regression diagnostics tests for SR-14408 2021-08-25 20:14:06 -03:00
Anthony Latsis
a3340e80b3 [NFC] Add a test where a contextual type is necessary to resolve an EnumElementPattern 2020-08-10 17:15:13 +03:00
Pavel Yaskevich
0cd44a83a7 [ConstraintSystem] Don't record general contextual mismatch if there are restrictions present
If there are any conversion restrictions present while trying to repair
failures related to contextual type, let's give `simplifyRestrictedConstraintImpl`
a chance to run and fix the problem.

Resolves: rdar://problem/59773317
2020-03-02 11:07:31 -08:00
Pavel Yaskevich
79b757d3cd [ConstraintSystem] Detect and diagnose mismatches in single parameter function conversions
When there is a conversion from e.g. `(A) -> Void` to `(B) -> Void`
matching between `A` and `B` is going to have a special locator which
doesn't end in `TupleElement`, so `repairFailures` has to account
for that and fix it just like regular argument mismatch.

Resolves: rdar://problem/59066040
2020-02-17 16:09:11 -08:00
Pavel Yaskevich
2d10a8a9a0 [ConstraintSystem] Extend function type conversion mismatch coverage
Originally type mismatches associated with conversions between
function types were only covered for coercions and assignments
but fix coverage grew since then and now it makes sense
to remove special case and let `repairFailures` take care of it.
2020-01-30 09:45:36 -08:00
Faiçal Tchirou
4a590cea5a Add missing ? in “did you mean …” diagnostics 2019-12-19 10:37:20 +01:00
Holly Borla
a9a0bba31b [Diagnostics] Don't apply the single parameter tuple splat fix if the
parameter type is a generic parameter.
2019-11-18 16:19:33 -08:00
Pavel Yaskevich
e09e8c3d72 [Diagnostics] NFC: Adjust diagnostics improved by extraneous arguments fix 2019-10-16 10:19:26 -07:00
Pavel Yaskevich
51476cde58 [Diagnostics] Clarify tuple splat message when single parameter is generic parameter
Since it's hard to say whether tuple use is really intended, let's
add `did you mean to pass a tuple?` note to the error message.
2019-10-09 10:58:31 -07:00
Pavel Yaskevich
7e6b4e4d57 [Diagnostics] Extend single parameter tuple splat to support generic parameters
Currently single parameter tuple splat fix/diagnostic supports only
cases where parameter is a concrete tuple type, let's enhance that to
support generic parameters as well e.g.:

```swift
func foo<T>(_: T) {}
foo(0, 1, 2) // `T` expects arguments to form a tuple e.g. `foo((0, 1, 2))`
```
2019-10-08 18:11:48 -07:00
Pavel Yaskevich
ec6a874ac8 [TypeChecker] NFC: Update test-cases improved by new missing arguments diagnostic 2019-09-25 10:47:26 -07:00
Slava Pestov
39a22f3d6a AST: Remove ParameterTypeFlags::Escaping
Escapingness is a property of the type of a value, not a property of a function
parameter. Having it as a separate parameter flag just meant one more piece of
state that could get out of sync and cause weird problems.

Instead, always look at the noescape bit in a function type as the canonical
source of truth.

This does mean that '@escaping' is now printed in a few diagnostics where it was
not printed before; we can investigate these as separate issues, but it is
correct to print it there because the function types in question are, in fact,
escaping.

Fixes <https://bugs.swift.org/browse/SR-10256>, <rdar://problem/49522774>.
2019-04-15 00:25:03 -04:00
Pavel Yaskevich
fe7ea486a1 [CSSimplify] Teach disjunction filtering that some enum cases have curried self
Cases with arguments form `(Self.Type) -> (Arg...) -> Self`
function types, so `areConservativelyCompatibleArgumentLabels`
should remove curried self before trying to match argument/parameter
labels.

Resolves: rdar://problem/49159472
2019-03-25 19:37:05 -07:00
Pavel Yaskevich
74a8ee177e [Diagnostics] Diagnose missing members via fixes
Try to fix constraint system in a way where member
reference is going to be defined in terms of its use,
which makes it seem like parameters match arguments
exactly. Such helps to produce solutions and diagnose
failures related to missing members precisely.

These changes would be further extended to diagnose use
of unavailable members and other structural member failures.

Resolves: rdar://problem/34583132
Resolves: rdar://problem/36989788
Resolved: rdar://problem/39586166
Resolves: rdar://problem/40537782
Resolves: rdar://problem/46211109
2019-01-09 17:29:49 -08:00
Doug Gregor
dee02c42a4 Update test cases for constraint solver performance hack 2018-02-08 22:57:05 -08:00
Pavel Yaskevich
1ffac2e651 [QoI] Improve diagnostics related to member calls
When trying to diagnose problems related to calls where
function is represented by a member of nominal type let's
attempt to be more cautious while type-checking function
expression without it's arguments, because it could produce
unrelated diagnostics.

Resolves: rdar://problem/32551313, rdar://problem/28456467, rdar://problem/31671195
2017-06-27 15:49:11 -07:00
Mark Lacey
0ba4a312af Roll back a portion of SE-0110
As described in:
  https://lists.swift.org/pipermail/swift-evolution-announce/2017-June/000386.html

Specifically allow an N-ary argument function to be passed as an
argument in a place where a function of a single N-tuple is expected.

Fixes: rdar://problem/32875953
2017-06-20 11:05:28 -07:00
Pavel Yaskevich
5523ca7b9f [ConstraintSystem] Strip labels from enum elements when passed as values
Enum elements have to be treated the same way as regular functions
when passed as values, which means labels have to be stripped from
their argument types.

Resolves: rdar://problem/32300339.
2017-05-26 15:32:48 -07:00