Commit Graph

168 Commits

Author SHA1 Message Date
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
Luciano Almeida
ac65e6fcc4 [Sema] Detect if we should use a conditional binding when recording the CoerceToCheckedCast fix 2020-12-01 09:03:17 -03:00
Pavel Yaskevich
da8159c1b4 [ConstraintSystem] Add a new fix to diagnose extraneous return(s) in result build body 2020-11-19 17:21:00 -08:00
Nathan Hawes
edbbefce91 [CodeCompletion][Sema] Add fix to treat empty or single-element array literals as dictionaries when used as such
In the single-element case, it is treated as the dictionary key.

func takesDict(_ x: [Int: String]) {}
takesDict([]) // diagnose with fixit to add missing ':'
takesDict([1]) // diagnose with fixit to add missing ': <#value#>'
takesDict([foo.<complete>]) // prioritise Int members in completion results -
                            // the user just hasn't written the value yet.

The above previously failed with a generic mismatch error in normal type
checking (due to the literal being parsed as an array literal) and code
completion could not pick up the expected type from the context.
2020-11-11 11:48:39 -08:00
Pavel Yaskevich
7e854eff44 [CSFix] Allow invalid decl references be diagnostic in ambiguity cases 2020-11-04 12:18:15 -08:00
Pavel Yaskevich
f1fd528a1b [CSFix] Add a fix to detect/diagnose references to invalid declarations
Upon attempt to generate constraints for invalid declaration reference
let's turn that into a hole and record this new fix to diagnose it
once solution has been reached.
2020-11-03 17:52:40 -08:00
Doug Gregor
6d41524fe6 [SE-0289] Finish renaming source code, tests to "result builders" 2020-10-20 22:18:51 -07:00
Doug Gregor
0d568a93d4 [SE-0289] Update diagnostics & many other strings to "result builders" 2020-10-20 21:44:09 -07:00
Nathan Hawes
15f5222bbd [CodeCompletion][Sema] Allow missing args when solving if the completion location indicates the user may intend to write them later.
func foo(a: Int, b: Int) {}
func foo(a: String) {}

// Int and String should both be valid, despite the missing argument for the
// first overload since the second arg may just have not been written yet.
foo(a: <complete here>

func bar(a: (Int) -> ()) {}
func bar(a: (String, Int) -> ()) {}

// $0 being of type String should be valid, rather than just Int, since $1 may
// just have not been written yet.
bar { $0.<complete here> }
2020-10-19 12:16:19 -07:00
Pavel Yaskevich
4954763524 [ConstraintSystem] NFC: Move CSFix.h to include/swift/Sema 2020-10-08 10:43:18 -07:00