Commit Graph

59 Commits

Author SHA1 Message Date
Pavel Yaskevich
d5b11a6136 [CSFix] Make it possible to diagnose calls to non-functions in ambiguity contexts
Resolves: rdar://86611718
2021-12-20 18:12:45 -08:00
Pavel Yaskevich
2bf05b96e5 [CSFix] Make it possible to diagnose keypath inference failure in ambiguous contexts
Resolves: rdar://85458997
2021-12-20 15:03:28 -08:00
Pavel Yaskevich
a6755f1754 [CSFix] Diagnose multiple solutions with missing closure param as un-ambiguous
If there are multiple overloads and all of them require closure
to have a parameter, let's diagnose that as such instead of
ambiguity.
2021-12-03 10:53:28 -08:00
Doug Gregor
365f0afa9f Downgrade concurrency-related function type errors in existing code
When in "existing" Swift code that is Swift 5.x and has not adopted
concurrency, allow mismatches in function types that only involve
ABI-neutral concurrency changes (e.g., adding `@Sendable` or removing
a global actor) by downgrading the diagnostic to a warning. This
improves the story for incremental adoption of concurrency in an
existing code base.

As part of this, generalize the facility for downgrading an error to a
warning when performing diagnostics in the constraint solver, using the
new diagnostic behavior limits rather than duplicating diagnostics.
2021-12-02 10:33:01 -08:00
Pavel Yaskevich
bc54bc6bb7 Revert "[TypeChecker] SE-0326: Enable multi-statement closure inference by default" 2021-11-29 17:26:08 -08:00
Xi Ge
03c76bd32d sema: diagnose passing a non-constant value into a constant parameter 2021-11-22 11:52:57 -08:00
Hamish Knight
237338b504 Merge pull request #40224 from hamishknight/super-tuple-shuffle 2021-11-18 09:50:09 +00:00
Hamish Knight
4aaec65780 [CS] Warn on mismatched tuple labels for subtyping
This is something that we'd like to fix to bring
in line with tuple conversion, so start warning on
cases where it occurs.
2021-11-17 17:06:21 +00:00
Pavel Yaskevich
3f78f4d238 [CSFix] Diagnose multiple solutions with missing closure param as un-ambiguous
If there are multiple overloads and all of them require closure
to have a parameter, let's diagnose that as such instead of
ambiguity.
2021-11-15 16:42:04 -08:00
Pavel Yaskevich
4343227d19 [Diagnostics] Determine affected elements early in collection element mismatches
Diagnostics cannot assume that solution would always be applied
to the constraint system, so all of the elements affected by the
mismatch have to be determined by the fix.

Resolves: rdar://85021348
2021-11-12 10:10:44 -08:00
Pavel Yaskevich
f53bcea60c [CSFix] Add a tailored fix for invalid Swift -> C pointer conversions
This is a skeleton of a fix that would be used to diagnose situations
when Swift -> C pointer conversion was attempted on a Swift function.
2021-09-20 17:22:26 -07:00
Pavel Yaskevich
06a762b64a [CSFix] Add a specific kind for IgnoreResultBuilderWithReturnStmts 2021-09-10 15:46:27 -07:00
Pavel Yaskevich
0a425480d0 [CSFix] NFC: Rename fix/diagnostic for checked casts that always succeed 2021-09-10 13:55:15 -07:00
Pavel Yaskevich
4c845972b4 [CSFix] Require all sub-classes of ContextualMismatch to supply a kind 2021-09-10 13:18:37 -07:00
Pavel Yaskevich
0f2ee14cad [CSFix] Add a specific kind for CollectionElementContextualMismatch 2021-09-10 13:07:22 -07:00
Pavel Yaskevich
152cf0b66c [CSFix] Add a specific kind for IgnoreKeyPathContextualMismatch 2021-09-10 13:01:26 -07:00
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
Pavel Yaskevich
1039b76671 [CSFix] NFC: Fix code formatting for SpecifyKeyPathRootType fix 2021-09-10 10:02:47 -07:00
Pavel Yaskevich
3265042eff [CSFix] NFC: Add classof implementation to most of the fixes 2021-09-10 10:00:45 -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
Frederick Kellison-Linn
5f07747cb3 [Sema] Diagnose user-specified placeholders which couldn’t be resolved 2021-08-19 14:53:33 -04:00
Pavel Yaskevich
4b0d9a2509 [ResultBuilders] Diagnose pre-check errors inline
Not all of the pre-check errors could be diagnosed by re-running
`PreCheckExpression` e.g. key path expressions are mutated to
a particular form after an error has been produced.

To make the behavior consistent, let's allow pre-check to emit
diagnostics and unify pre-check and constraint generation fixes.

Resolves: rdar://77466241
2021-05-10 11:06:58 -07:00
Strieker
4e2b67cbae [NFC] Resolved merge conflict in CSSimplify.cpp after making changes to improve error handling for composed wrapped value mismatches 2021-04-22 11:49:21 -07:00
Strieker
c9b53ec66f [ConstraintSystem] Created a locator in CSGen to store the location where the wrappedValue type of a property wrapper was determined and added necessary logic so that a constraint locator can recognize a composed property wrapper’s wrapped value type in CSFix.cpp, CSFix.h, and CSSimplify.cpp. 2021-04-22 11:31:41 -07:00
Holly Borla
76c4c3dc3f [Diagnostics] Add back a dedicated fix/diagnostic for using an invalid
type as a property wrapper.
2021-03-24 11:24:21 -07:00
Holly Borla
f05589f6c4 [Diagnostics] Improve diagnostics for passing an invalid projected
value argument.
2021-03-24 11:24:21 -07:00
Doug Gregor
52096a640e SE-0302: Rename ConcurrentValue/@concurrent to Sendable/@Sendable. 2021-03-18 23:48:21 -07:00
Doug Gregor
d6fc1fd60f Implement conversions for global-actor-qualified functions.
One can convert from a function value without a global actor to a
similar function type that does have a global actor, but one cannot
remove or change a global actor on a function type.
2021-03-17 00:51:26 -07:00
Holly Borla
133dec0e05 [ConstraintSystem] Implement implicit property wrapper attribute
inference for closure parameters.
2021-02-25 18:35:14 -08:00
Holly Borla
ea3fe03c98 [Property Wrappers] Add a constraint fix and diagnostic for the case
where the programmer tries to pass a projection argument to a wrapped
parameter without 'var projectedValue'.
2021-02-25 18:35:14 -08:00
Pavel Yaskevich
e8f7a71870 [CSBindings] Update static member lookup to utilize new isDelayed API 2021-02-23 11:33:11 -08:00
Pavel Yaskevich
618f5633c0 [CSFix] NFC: Fix a bad rebase of invalid static member lookup fix 2021-02-23 11:33:11 -08:00
Pavel Yaskevich
03d869ad8b [Diagnostics] Extract invalid result type from overload choice
Instead of threading it through the constraint system all the way
to a diagnostic, let's extract it from overload choice instead.
2021-02-23 11:33:10 -08:00
Pavel Yaskevich
9231acf202 [Diagnostics] Implement a tailored diagnostic for invalid static member refs on protocol metatypes 2021-02-23 11:32:24 -08:00
Pavel Yaskevich
eaabd24746 [CSFix] Add a new fix to diagnose invalid static member refs on protocol metatype 2021-02-23 11:32:24 -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
1b7795b5e3 [CSFix] Allow diagnosing invalid references in key path with multiple solutions
If multiple solutions have exactly a fix for exactly the same invalid member
reference in key path, let's diagnose that as if there is no ambiguity there.
2021-02-18 17:21:37 -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
Luciano Almeida
d55eed46e8 [Sema][CSApply] Moving some checked cast diagnostics to a fix format (#34980)
* [Sema] Implementing is runtime check always true diagnostic as a fix

* [AST] Implement getWithoutThrows on function type

* [CSSimplify] Detect that checked cast types conversion is always true and record warning fix

* [test] Some additional test cases for SR-13789

* [Sema] Fixing typo on fix name

* [Sema] Move and adjust the ConditionalCast diagnostics to the fix format

* [Sema] Remove some checked cast diagnostics from check constraints and move to fix

* [Sema] Renaming checked cast coercible types fix

* [Sema] Some adjustments and rewrite on the logic for downcast record fix

* [Sema] Move logic of runtime function type to AllowUnsupportedRuntimeCheckedCast::attempt

* [Sema] Abstract checked cast fix logic to static function and minor adjustments

* [Sema] Renamings from review
2021-02-10 08:31:06 -03:00
Doug Gregor
ba8819eb58 [Concurrent] Introduce concurrent function types.
Introduce `@concurrent` attribute on function types, including:
* Parsing as a type attribute
* (De-/re-/)mangling for concurrent function types
* Implicit conversion from @concurrent to non-@concurrent
- (De-)serialization for concurrent function types
- AST printing and dumping support
2021-01-27 14:22:32 -08:00
Luciano Almeida
e4d4c0b32e [Sema] Moving detection of fix base type for optional member to attempt fix method 2020-12-08 00:19:39 -03:00
Luciano Almeida
c8ea08df78 [Sema] Creating ambiguous base for none member warning diagnostic as a fix 2020-12-05 22:48:09 -03:00
Doug Gregor
50cdddaf95 [Concurrency] Enable implicit conversion from synchronous -> asynchronous. 2020-12-03 12:44:21 -08:00
Pavel Yaskevich
85181360b1 Merge pull request #34810 from xedin/rdar-66709164
[ConstraintSystem] Detect and diagnose extraneous return(s) in result build body
2020-12-02 15:51:10 -08:00