Commit Graph

91 Commits

Author SHA1 Message Date
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
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
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
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
Kavon Farvardin
13dd3d9ecf have the inferred isolation for properties change only in Swift 6
This patch delays the removal of redundant isolation for inferred
global-actor isolation to Swift 6 too, since we only warn about it
changing in Swift 5. Otherwise, only isolation that is a byproduct
of inference no longer needs an await, which will probably confuse
people.

This change is with respect to SE-327, which argues that the
non-static stored properties of ordinary structs do not need
global-actor isolation.
2022-02-04 14:43:12 -07:00
Kavon Farvardin
19bdfb1172 In a property-wrapper, global-actor isolation remains on wrappedValue
If a struct is a property-wrapper, then global-actor isolation
still applies to the `wrappedValue`, even if it's a stored property.
This is needed in order to support the propagation of global-actor
isolation through the wrapper, even when the programmer has opted
to use a stored property instead of a computed one for the
`wrappedValue`. Since this propagation is a useful pattern, I think
this exception is reasonable.
2022-02-04 14:41:49 -07:00
Pavel Yaskevich
fe9224d6a8 [TypeChecker] NFC: Add a test-case for mixed SwiftUI + multi-statement closures
This test-case used to crash with multi-statement closure inference
enabled in result builder contexts.
2021-12-26 21:16:27 -08:00
Pavel Yaskevich
55a75ed89b [TypeChecker] NFC: Add a test-case for rdar://80630127 2021-10-14 13:07:12 -07:00
Frederick Kellison-Linn
16a4031c32 [tests] Update tests with modified diagnostics 2021-08-19 14:53:34 -04:00
Pavel Yaskevich
71372bce67 [Diagnostics] Switch to use contextual purpose associated with locator
`ContextualFailure` is the main beneficiary of additional information
associated with `ContextualType` element because it no longer has to
query solution for "purpose" of the contextual information.

Resolves: rdar://68795727
2021-04-26 09:51:25 -07:00
Mishal Shah
22f61df98b Use %target-cpu in the tests to support running on Apple Silicon hardware 2021-04-08 23:26:18 -07:00
Pavel Yaskevich
6e628c4874 [CSGen] Fallback to a type variable if preferred type for placeholder is invalid
Type inside of an editor placeholder is more of a hint than anything else,
so if it's incorrect let's diagnose that and use type variable instead to
allow solver to make forward progress.

Resolves: SR-14213
Resolves: rdar://74356736
2021-03-23 18:56:21 -07:00
Pavel Yaskevich
2a9903dfe4 [Diagnostics] Check whether missing conformance could be fixed by using .rawValue
A lot of operators (and most likely regular functions a well) have
overloads that accept i.e. a generic parameter that conforms to
`StringProtocol`, so the best fix in situations when argument is
a raw representable type would be to check whether `.rawValue`
conforms to the expected protocol and use it if so.

Resolves rdar://problem/75367157
2021-03-15 16:53:45 -07:00
Pavel Yaskevich
cd08350fe5 [Diagnostics] Prioritize type mismatches over labeling failures for calls
Since labels are considered part of the name, mismatches in labeling
should be invalidate overload choices. Let's prefer an overload with
correct labels but incorrect types over the one with incorrect labels.

This also means that it's possible to restore performance optimizations
related to early filtering in diagnostic mode, which is important for
deeply nested code i.e. SwiftUI views.
2021-03-03 18:50:06 -08:00
Pavel Yaskevich
2274e17843 [CSFix] Allow diagnosing the same out-of-order argument in ambiguity cases
Is the same argument is out-of-order in multiple solutions, let's
diagnose it as if there was no ambiguity.

Resolves: SR-14093
Resolves: rdar://73600328
2021-02-18 17:21:49 -08:00
Pavel Yaskevich
a7524e59f4 [CSFix] Allow diagnosing missing conformance in ambiguity cases
It's possible that different overload choices could have the same
conformance requirement, so diagnostics should be able to emit an
error in situations where multiple solutions point to the missing
conformance at the same location (both in AST and requirement list).

Resolves: rdar://74447308
2021-02-18 17:21:03 -08:00
Pavel Yaskevich
80c4c90403 Merge pull request #34603 from xedin/rdar-70256351
[ResultBuilders] Account of a fact that re-write of a statement can fail
2020-11-06 14:07:29 -08:00
Pavel Yaskevich
1d3f3204ca [ResultBuilders] Account of a fact that re-write of a statement can fail
If one of the statements in the result builder body fails to
apply solution, let's fail entire rewrite attempt, otherwise
type-checker would end up with AST that has null pointers for
some child nodes.

Resolves: rdar://problem/70256351
2020-11-05 16:29:58 -08:00
Pavel Yaskevich
8e95096e85 [TypeChecker] NFC: Add a test-case for rdar://70880670 2020-11-04 16:19:51 -08:00
Mishal Shah
2b18b5067c [XFAIL] Sema/SwiftUI/rdar57201781.swift and Constraints/trailing_closures_objc.swift to support Xcode 12 beta 3 2020-07-26 23:24:26 -07:00
Varun Gandhi
a1716fe2a6 [Diagnostics] Update compiler diagnostics to use less jargon. (#31315)
Fixes rdar://problem/62375243.
2020-04-28 14:11:39 -07:00
Doug Gregor
b94a5c8dd4 Update a test case's expected output 2020-02-25 20:39:42 -08:00
Pavel Yaskevich
6d671020b9 [TypeChecker/BuilderTransform] Make sure implicit load expression updates types in AST
Can't use `ConstraintSystem::addImplicitLoadExpr` because that would
only cache types in constraint system and wouldn't propagate them to AST,
since that happens in `ExprRewritter::finalize` during regular solution
application. `TypeChecker::addImplicitLoadExpr` should be used directly
in cases like that.

Resolves: rdar://problem/58972627
2020-02-03 11:45:55 -08:00
Doug Gregor
8283a67648 Revert "Revert "Reimplement function builders as statement transformations."" 2020-01-21 10:07:20 -08:00
Doug Gregor
86c13d3c74 Revert "Reimplement function builders as statement transformations." 2020-01-17 15:52:49 -08:00
Doug Gregor
a49f0091cb [Constraint application] Skip error expressions when applying builders.
If we encountered an error, just skip it; there's nothing more to do.
2020-01-16 13:19:21 -08:00
Pavel Yaskevich
8bcc192591 [Diagnostics] Diagnose inability to infer (complex) closure return type 2019-12-19 12:16:30 -08:00
Pavel Yaskevich
fa77285c62 Revert "[TypeChecker] NFC: Disable SwiftUI test-case due to possible infinite…" 2019-12-09 12:12:51 -08:00
Pavel Yaskevich
e0aa646310 [TypeChecker] NFC: Disable SwiftUI test-case due to possible infinite loop
Resolves: rdar://problem/57756956
2019-12-09 10:58:05 -08:00
Pavel Yaskevich
1d393ebdd4 [ConstraintSystem] Guard against infinite recursion in key path dynamic member lookup
It's possible to construct subscript member responsible for key path
dynamic member lookup in a way which is going to be self-recursive
and an attempt to lookup any non-existent member is going to trigger
infine recursion.

Let's guard against that by making sure that the base type of the
member lookup is different from root type of the key path.

Resolves: rdar://problem/50420029
Resolves: rdar://problem/57410798
2019-12-05 12:42:17 -08:00
Pavel Yaskevich
94b4052321 [CSDiag] NFC: Remove all of the obsolete diagnoseGeneral*Failures logic 2019-12-03 12:07:16 -08:00
Pavel Yaskevich
addc2b06ab [ConstraintSystem] Introduce notion of constraint system phase
Some constraint transformations require knowledge about what state
constraint system is currently in e.g. `constraint generation`,
`solving` or `diagnostics` to make a decision whether simplication
is possible. Notable example is `keypath dynamic member lookup`
which requires a presence of `applicable fn` constraint to retrieve
some contextual information.

Currently presence or absence of solver state is used to determine
whether constraint system is in `constraint generation` or `solving`
phase, but it's incorrect in case of `diagnoseFailureForExpr` which
tries to simplify leftover "active" constraints before it can attempt
type-check based diagnostics.

To make this more robust let's introduce (maybe temporarily until
type-check based diagnostics are completely obsoleted) a proper
notion of "phase" to constraint system so it is always clear what
transitions are allowed and what state constraint system is
currently in.

Resolves: rdar://problem/57201781
2019-11-20 18:34:51 -08:00
Alexis Laferrière
fd191bff43 Fix test rdar56710317.swift for the iOS simulator
Fix rdar://problem/56999504
2019-11-07 15:19:46 -08:00
Doug Gregor
f4c45e8057 [Type check diagnostics] Add already-fixed test case from rdar://problem/56710317.
Ensures that we don't regress diagnostics for this case in the future.
2019-11-07 09:41:36 -08:00