Commit Graph

561 Commits

Author SHA1 Message Date
Pavel Yaskevich
4d039686fd [CSSimplify] Failure to bind type variable to invalid dependent member makes it a hole
If the failure is not reflected in constraint system it would let
the solver to form a _valid_ solution as if the constraint between
the type variable and the unresolved dependent member type never
existed.

Resolves: https://github.com/apple/swift/issues/60649
2022-08-19 11:39:40 -07:00
Pavel Yaskevich
10bd9433ef [TypeChecker] NFC: Adjust test-case for rdar://98577451
Replace `-target` with `-disable-availability-checking`
and drop `REQUIRES:` lines that limit test to macOS.
2022-08-16 13:18:29 -07:00
Pavel Yaskevich
b4949a0b2c [CSApply] Attempt value-to-opaque-result abstraction only after canonicalization
`ExprRewriter::coerceToType` should canonicalize contextual type before
attempting to use it for value abstraction, because sugared type could
have typealias references that hide their underlying opaque result types.

Resolves: rdar://98577451
2022-08-15 21:30:17 -07:00
Pavel Yaskevich
0989f43bb1 [CSClosure] Add support for projected/wrapper values
To support referencing projected and/or wrapped var
in a closure solver needs to lookup a type of their
originator and based on the wrapper type compute and
assign types to projection and/or wrapper.

Resolves: https://github.com/apple/swift/issues/59295
Resolves: rdar://94506352
2022-08-04 16:55:02 -07:00
Anthony Latsis
a82d6f9272 Add type-checker regression scale test to close #43386 2022-07-09 16:47:51 +03:00
Anthony Latsis
7c73047bf2 Add x-failed scale test for type-checking nil-coalescing dictionary values 2022-07-09 16:46:02 +03:00
Anthony Latsis
a359f7745c Add type-checker performance tracking test for #43369
To make this test work, fix an issue in `ConstraintSystem::salvage` where a
threshold breach during solving went unnoticed due to exiting on ambiguity
before reaching the `isTooComplex` check. Address this by moving the
`isTooComplex` check to before we start processing solutions, and stick another
one in `findBestSolution` for short-circuiting while we're here.
2022-07-09 16:34:19 +03:00
Alejandro Alonso
2a2f70f944 Fix tests who aren't using %target-cpu (#59433)
don't import string processing
2022-06-14 20:39:03 -07:00
Pavel Yaskevich
066bbd18eb [CSClosure] Fix handling of property wrapped pattern bindings
Property wrappers trigger initializer synthesis. Synthesized
initializers should not be re-typechecked when encountered e.g.
 while re-solving closure with a different contextual type.

Resolves: https://github.com/apple/swift/issues/59294
Resolves: rdar://94506352
2022-06-07 13:41:53 -07:00
Pavel Yaskevich
27419446b6 Merge pull request #59064 from xedin/issue-59058
[CSSimplify] If function types mismatch on labels record a contextual…
2022-06-02 10:18:54 -07:00
Ben Barham
efc9469444 Merge pull request #58975 from bnbarham/make-features-consistent
[Tests] Make OS features consistent
2022-05-25 16:02:43 -07:00
Pavel Yaskevich
8fd8408075 [CSSimplify] If function types mismatch on labels record a contextual mismatch
`RelabelArguments` cannot possibly diagnose this issue because there
are no argument lists in this case. Let's report contextual mismatch
instead.

Resolves: https://github.com/apple/swift/issues/59058
2022-05-24 16:58:43 -07:00
Pavel Yaskevich
321b741351 [TypeChecker] NFC: Add a test-case for issue#59031 (crash in ConjunctionStep::resume) 2022-05-23 14:12:25 -07:00
Ben Barham
c163e0fe5e [Tests] Make OS features consistent
lit.py currently allows any substring of `target_triple` to be used as a
feature in REQUIRES/UNSUPPORTED/XFAIL. This results in various forms of
the OS spread across the tests and is also somewhat confusing since they
aren't actually listed in the available features.

Modify all OS-related features to use the `OS=` version that Swift adds
instead. We can later remove `config.target_triple` so that these don't
the non-OS versions don't work in the first place.
2022-05-20 19:51:23 -07:00
Pavel Yaskevich
f0ba1a859a [CSSimplify] Don't attempt to synthesize ~= for optional base types
`EnumElement` patterns with optional base type do member lookup
on both optional type and its wrapped type but do not synthesize
`~=` operator call.

Resolves: rdar://92327807
2022-04-29 10:09:31 -07:00
Pavel Yaskevich
1359840ab3 Merge pull request #58400 from xedin/too-complex-improvements
[ConstraintSystem] Improve precision of "too complex" diagnostic
2022-04-27 19:58:31 -07:00
Pavel Yaskevich
7869b73a73 [TypeChecker] NFC: Add a "slow" perf test-case for rdar://91310777 2022-04-25 14:10:58 -07:00
Pavel Yaskevich
a40e8e80c1 [ConstraintSystem] Use affected range (if any) to diagnose 'too complex' failures 2022-04-25 14:09:45 -07:00
Pavel Yaskevich
b8046e1064 [TypeChecker] NFC: Remove a literal to make test-case less flaky
Multi-statement closure + simd perf test-case still (albeit very
rarely) fails, so let's remove `/ 4` in attempt to prevent that
happening.

Resolves: rdar://92025732
2022-04-22 15:44:42 -07:00
Pavel Yaskevich
384d508200 Merge pull request #42483 from xedin/rdar-90366182
[CSApply] Rewrite types of a constructed tuple
2022-04-21 10:00:40 -07:00
Pavel Yaskevich
ef4793e191 Merge pull request #42500 from xedin/rdar-91849144
[TypeChecker] NFC: Adjust SwiftUI to use %target-cpu instead of x86_64
2022-04-21 09:43:49 -07:00
Doug Gregor
4116d7a3d7 Rename the -strict-concurrency= options to be more descriptive.
The three options are now:

* `explicit`: Enforce Sendable constraints where it has been explicitly adopted and perform actor-isolation checking wherever code has adopted concurrency. (This is the default)
* `targeted`: Enforce Sendable constraints and perform actor-isolation checking wherever code has adopted concurrency, including code that has explicitly adopted Sendable.
* `complete`: Enforce Sendable constraints and actor-isolation checking throughout the entire module.
2022-04-20 18:17:33 -07:00
Pavel Yaskevich
1c426a30d1 Merge pull request #42484 from xedin/drop-se-0326-flag
[TypeChecker] NFC: Remove `-experimental-multi-statement-closures` flag
2022-04-20 14:39:35 -07:00
Pavel Yaskevich
2b3661570f [TypeChecker] NFC: Adjust SwiftUI to use %target-cpu instead of x86_64
Resolves: rdar://91849144
2022-04-20 14:38:24 -07:00
Pavel Yaskevich
6db0001863 [TypeChecker] NFC: Remove -experimental-multi-statement-closures flag
SE-0326 has been enabled by default, so this flag is no longer necessary.
2022-04-20 10:40:27 -07:00
Pavel Yaskevich
879bd6578d [CSApply] Rewrite types of a constructed tuple
When construction call is rewritten into a tuple conversion,
rewriter has to make sure that AST types are reset otherwise
it would end up with types set by `packIntoImplicitTupleOrParen`
which could contain l-values.

Resolves: rdar://90366182
2022-04-20 10:35:06 -07:00
Doug Gregor
3f4bc7df37 Add -strict-concurrency=limited to one more test. 2022-04-20 09:11:10 -07:00
Pavel Yaskevich
d8ade63521 [TypeChecker] NFC: Un-XFAIL SwiftUI test-case which has been fixed
Test-case should no longer produce "type of expression is ambiguous"
fallback diagnostic.

Resolves: rdar://66110075
2022-04-14 13:38:01 -07:00
Pavel Yaskevich
df549dbdb3 [TypeChecker] SE-0326: Check whether function declaration is a result builder context
This is a follow-up to https://github.com/apple/swift/pull/40708 which only considers
closures, but it missed the case when builder is applied to function body - in such
cases the declaration context is going to be a function/getter declaration.

Resolves: rdar://91150414
2022-04-04 01:13:46 -07:00
Pavel Yaskevich
19ebc9b73c Merge pull request #42122 from xedin/rdar-90445018-x86_64-only
[TypeChecker] NFC: Restrict flaky perf test to x86_64 || arm64 macOS
2022-04-01 09:55:19 -07:00
Doug Gregor
b94d6eb874 Merge pull request #42121 from xedin/rdar-91110069
[ConstraintSystem] Fix a bug in existential Self erasure
2022-03-31 20:55:34 -07:00
Pavel Yaskevich
bac42d14b3 [TypeChecker] NFC: Restrict flaky perf test to x86_64 || arm64 macOS
Resolves: rdar://90445018
2022-03-31 14:18:27 -07:00
Pavel Yaskevich
9e3432a833 [ConstraintSystem] Fix a bug in existential Self erasure
`typeEraseExistentialSelfReferences` shouldn't account for
contextual signature because that signature could have
generic parameters of it's own unrelated to the reference
which would be located before generic parameters of the
member, e.g. when the code is located in a protocol extension,
which invalidates the assumption that `Self` is located at
depth = 0, index = 0.

Resolves: rdar://91110069
2022-03-31 13:19:33 -07:00
Slava Pestov
b4b873332f Update -requirement-machine-* flags in various tests
- Don't pass 'verify' since it's now the default
- Update tests where diagnostics changed in a correct way to pass 'on' instead
- Delete compiler_scale/explicit_requirements_perf.swift since it's not testing anything with the requirement machine
2022-03-31 15:57:36 -04:00
Pavel Yaskevich
c03e8b5544 Merge pull request #41899 from xedin/rdar-90419017
[Diagnostics] Ignore type mismatches related to synthesized arguments
2022-03-25 14:47:52 -07:00
Pavel Yaskevich
9d413b3668 Merge pull request #41939 from xedin/rdar-87407899
[Diagnostics] Fix out-of-bounds index while fixing argument mismatch
2022-03-22 22:46:54 -07:00
Pavel Yaskevich
b6c2b3edff [Diagnostics] Fix out-of-bounds index while fixing argument mismatch
Although the overload choice has two parameters, it doesn't
mean that there are exactly two arguments passed to it.

Resolves: rdar://87407899
2022-03-21 14:57:50 -07:00
Kavon Farvardin
9b1fcedf2f backtrack on part of SE-327 dealing with default-value exprs
This effectively reverts 6823744779

The blanket removal of isolation in default-value expressions had
unintented consequences for important workflows. It's still
a problem that needs to be addressed, but we need to be more precise
about the problematic situations.
2022-03-18 18:41:05 -07:00
Pavel Yaskevich
fc83c6fa68 [Diagnostics] Ignore type mismatches related to synthesized arguments
The main issue is the absence of the argument itself.

Resolves: rdar://90419017
2022-03-18 14:54:15 -07:00
Pavel Yaskevich
10324641f9 [TypeChecker] NFC: Restrict multi-statement closure + simd test-case to macOS
Resolves: rdar://90445018
2022-03-17 12:10:31 -07:00
Pavel Yaskevich
839b483f1b Merge pull request #41824 from xedin/rdar-85516390
[CSDiagnostics] Contextual failure could result in optional chain hav…
2022-03-16 10:33:39 -07:00
Pavel Yaskevich
5331e276d5 Merge pull request #41730 from xedin/se-0326-solve-pattern-bindings-via-conjunctions
[SE-0326] Re-enable multi-statement closure inference by default
2022-03-15 13:21:03 -07:00
Pavel Yaskevich
6fb5c3042b [CSDiagnostics] Contextual failure could result in optional chain having non-optional type
Fixes a crash during diagnostics by not assuming that optional chain
would always produce an optional type, which is not true because in
error scenarios it could get assigned an invalid type from context.

Resolves: rdar://85516390
2022-03-15 13:14:48 -07:00
Erik Eckstein
6a020f8f15 Stabilize and simplify SIL linkage and serialization
The main point of this change is to make sure that a shared function always has a body: both, in the optimizer pipeline and in the swiftmodule file.
This is important because the compiler always needs to emit code for a shared function. Shared functions cannot be referenced from outside the module.
In several corner cases we missed to maintain this invariant which resulted in unresolved-symbol linker errors.

As side-effect of this change we can drop the shared_external SIL linkage and the IsSerializable flag, which simplifies the serialization and linkage concept.
2022-03-09 15:28:05 +01:00
Pavel Yaskevich
5c3fb222e1 [CSClosure] Explode pattern binding declarations into conjunctions
`one-way` constraints disable some optimizations related to component
selection because they imply strict ordering. This is a problem for
multi-statement closures because variable declarations could involve
complex operator expressions that rely on aforementioned optimizations.

In order to fix that, let's move away from solving whole pattern binding
declaration into scheme that explodes such declarations into indvidual
elements and inlines them into a conjunction.

For example:

```
let x = 42, y = x + 1, z = (x, test())
```

Would result in a conjunction of three elements:

```
x = 42
y = x + 1
z = (x, test())
```

Each element is solved indepedently, which eliminates the need for
`one-way` constraints and re-enables component selection optimizations.
2022-03-08 21:37:40 -08:00
Holly Borla
12459cff80 [Diagnostics] Print 'any' in diagnostic arguments. 2022-03-05 14:26:45 -08:00
Pavel Yaskevich
c22649e050 Merge pull request #41504 from xedin/rdar-84580119
[CSDiagnostics] Look through l-value conversions when mismatch is in …
2022-02-23 09:16:38 -08:00
Pavel Yaskevich
874d0fbe8f [TypeChecker] NFC: Add a test-case for rdar://88256059 2022-02-21 16:34:53 -08:00
Pavel Yaskevich
bf820c5dab [CSDiagnostics] Look through l-value conversions when mismatch is in subscript setter
`repairFailures` needs a special case when l-value conversion is
associated with a result type of subscript setter because otherwise
it falls through and treats result type as if it's an argument type,
which leads to crashes.

Resolves: rdar://84580119
2022-02-21 16:32:25 -08:00
Slava Pestov
1784aee148 Add '-requirement-machine-protocol-signatures=verify -requirement-machine-inferred-signatures=verify' to a few validation tests 2022-02-17 19:40:58 -05:00