Commit Graph

481 Commits

Author SHA1 Message Date
Doug Gregor
4c2a7bf1ac Revert "[Constraint solver] Be more careful about NULL parent expression."
This reverts commit 0e269a5127.
2019-11-13 17:23:27 -08:00
Holly Borla
c0312b9c0e [ConstraintSystem] Record holes in the constraint system using a new flag in
`TypeVariableOptions` rather than using a separate data structure in the
constraint system.
2019-11-13 15:46:36 -08:00
Pavel Yaskevich
431ca98246 [Diagnostics] Port explicit closure result contextual mismatch
Detect and diagnose a problem when explicitly specified closure
result type doesn't match what is expected by the context:

Example:

```swift
func foo(_: () -> Int) {}

foo { () -> String in "" } // `Int` vs. `String`
```
2019-11-13 14:05:59 -08:00
Pavel Yaskevich
a7bc52fd9a Merge pull request #28197 from xedin/handle-single-pd-arg-mismatch
[Diagnostics] Produce a tailored diagnostic for property wrapper argu…
2019-11-11 15:13:56 -08:00
Pavel Yaskevich
08f8f4191d [Diagnostics] Produce a tailored diagnostic for property wrapper argument mismatch
Diagnose an attempt to initialize a property, which has a property
wrapper, with a value of an incorrect type.
2019-11-11 12:59:28 -08:00
Robert Widmann
1b75dbd43c Remove TypeChecker::Diags 2019-11-10 15:36:57 -08:00
Robert Widmann
1000c9d19e Remove some ancillary TypeCheckers 2019-11-10 14:29:05 -08:00
Robert Widmann
1123b1f897 Move constraint satisfiability utilities 2019-11-10 13:12:50 -08:00
Robert Widmann
63896c1fc5 Make more high-level type checking endpoints utility 2019-11-10 13:03:46 -08:00
Doug Gregor
bc926f7eb7 [Constraint system] Drop the root expression from FailureDiagnostic.
We're not using it for anything, now.
2019-11-08 22:38:49 -08:00
Doug Gregor
3fbdac5190 [Failure diagnostic] Use the constraint system's parent map. 2019-11-08 21:39:27 -08:00
Doug Gregor
a7d6deb09a [Constraint system] Use parent of anchor for trailing closure ambiguity. 2019-11-08 21:35:03 -08:00
Doug Gregor
c744066c52 [Constraint solver] Stop using the "root expression" in failure diagnostics.
We're still using the root expression to find the parent map, but we're not
falling back to it indiscriminately. Use the parent of the anchor (or
appropriate substitute) instead so we have a better handle on which
expression we're diagnosing for.
2019-11-08 21:26:04 -08:00
Doug Gregor
0e269a5127 [Constraint solver] Be more careful about NULL parent expression. 2019-11-08 21:26:04 -08:00
Robert Widmann
41ab235797 [CS] Remove some TypeChecker uses 2019-11-07 12:41:37 -08:00
Hamish Knight
b57c86dc1c fixItEncloseTrailingClosure doesn't need a TypeChecker 2019-11-07 12:41:36 -08:00
Robert Widmann
fb8b0600ad Remove some remaining TypeCheckers 2019-11-06 15:08:59 -08:00
Robert Widmann
7b9d28d7ba Make diagnoseSelfAssignment a utility 2019-11-06 15:08:59 -08:00
Pavel Yaskevich
6d02fb7815 Merge pull request #28057 from xedin/assign-diags
[Diagnostics] Port the rest of assignment diagnostics to the new framework
2019-11-06 00:11:08 -08:00
Robert Widmann
53f2974e27 [NFC] Remove unnecessary TypeCheckers from sequence folding 2019-11-05 20:30:40 -08:00
Robert Widmann
e907d3bc52 [NFC] Remove the TypeChecker from Typo Correction 2019-11-05 20:29:36 -08:00
Hamish Knight
96e5f2a145 Allow non-ephemeral diag to refer to argument labels
Use getArgDescription to improve the diagnostic
for invalid temporary pointer conversions.
2019-11-05 13:51:53 -08:00
Hamish Knight
912a7acc1e Add FunctionArgApplyInfo::getArgDescription
This commit adds a member which produces a string
describing the argument being applied. This will
either be its argument label or position in the
argument list.
2019-11-05 13:51:53 -08:00
Pavel Yaskevich
c800bde8e1 [Diagnostics] Try to find overlap between src/dst protocols in assignment mismatch 2019-11-05 12:43:32 -08:00
Pavel Yaskevich
11644b3f31 [Diagnostics] Diagnose assignment type mismatches related to unresolved members 2019-11-05 12:43:32 -08:00
Pavel Yaskevich
3586af6e8a [Diagnostics] Properly diagnose assignment type mismatches when either side is optional 2019-11-05 12:38:13 -08:00
Pavel Yaskevich
30440d8235 [Diagnostics] Properly diagnose assignment mismatch in ambiguity cases 2019-11-05 12:38:13 -08:00
Pavel Yaskevich
7cd7cd43e6 [Diagnostics] Port self assignment diagnostic to the new framework 2019-11-05 12:38:13 -08:00
Pavel Yaskevich
cb3a0fbcc8 [ConstraintSystem] Extend use of the treat r-value as l-value fix to more cases
Cover not only immutability but also type mismatch cases and clarify
behavior when one of the sides of the type conversion is optional.
2019-11-05 12:38:13 -08:00
Hamish Knight
d0dbbf9f89 [CSDiagnostics] Add ephemeralness ambiguity notes 2019-11-03 08:42:25 -08:00
Hamish Knight
7077a68b83 [Sema] Diagnose unsound pointer conversions
Diagnose ephemeral conversions that are passed to @_nonEphemeral
parameters. Currently, this defaults to a warning with a frontend flag
to upgrade to an error. Hopefully this will become an error by default
in a future language version.
2019-11-03 08:42:25 -08:00
Pavel Yaskevich
2dddfcb190 Merge pull request #28013 from xedin/trailing-closures-not-so-trailing
[Diagnostics] Port invalid trailing closure use diagnostics
2019-11-01 15:38:20 -07:00
Pavel Yaskevich
6bb659c5a3 [Diagnostics] Add a diagnostic for incorrect use of trailing closures 2019-10-31 20:58:01 -07:00
Robert Widmann
8a69f886ad Merge pull request #27955 from AnthonyLatsis/bracestmt_cleanup
NFC: Solidify and tidy up the BraceStmt interface
2019-10-31 13:48:40 -07:00
Pavel Yaskevich
82c2456295 Merge pull request #27976 from xedin/extraneous-call
[Diagnostics] Introduce extraneous call fix
2019-10-31 11:57:03 -07:00
Pavel Yaskevich
1315207a22 [Diagnostics] Introduce extraneous call fix
Detect and diagnose attempts to call variables and/or properties
which don't have a function type, so can't really support
invocation.
2019-10-30 16:53:42 -07:00
Robert Widmann
abc6db13b1 Provide AST Context Getters To Protocol Inference 2019-10-30 12:55:42 -07:00
Robert Widmann
118f68b1be Make getProtocol and getLiteralProtocol static utilities 2019-10-30 12:55:42 -07:00
Anthony Latsis
6325915b4b NFC: Solidify and tidy up the BraceStmt interface 2019-10-30 16:43:59 +03:00
Robert Widmann
b849e51768 Use operator bool to claw back some readability 2019-10-29 16:56:21 -07:00
Robert Widmann
3e1a61f425 [NFC] Fold The Tri-State In Optional<ProtocolConformanceRef>
ProtocolConformanceRef already has an invalid state.  Drop all of the
uses of Optional<ProtocolConformanceRef> and just use
ProtocolConformanceRef::forInvalid() to represent it.  Mechanically
translate all of the callers and callsites to use this new
representation.
2019-10-29 16:55:56 -07:00
Pavel Yaskevich
58329e0c27 Revert "[Diagnostics][Qol] SR-11295 Emit diagnostics for same type coercion. " 2019-10-25 01:05:07 -07:00
Luciano Almeida
5d1eeacbe4 Resolving conflicts 2019-10-23 07:25:55 -03:00
Pavel Yaskevich
d5b232c26e Merge pull request #27834 from xedin/for-in-diag
[TypeChecker] Produce a tailored diagnostic for `for-in` sequence fai…
2019-10-23 00:32:35 -07:00
Pavel Yaskevich
fb6ce64628 Merge pull request #27842 from xedin/if-ternary-diags
[Diagnostics] Improve if/ternary condition expression diagnostics
2019-10-23 00:32:06 -07:00
Pavel Yaskevich
74a7f3d8d0 [TypeChecker] Produce a tailored diagnostic for for-in sequence failures
`for-in` "sequence" expression is required to conform to `Sequence`.
2019-10-22 16:57:28 -07:00
Pavel Yaskevich
c4fee1d0c9 [ConstraintSystem] Use new condition element in constraint generation/diagnostics 2019-10-22 15:01:49 -07:00
Hamish Knight
be23ecc878 These functions don't need a TypeChecker 2019-10-22 09:23:33 -07:00
Luciano Almeida
4385dd854f Creating UnnecessaryCoercion warning fix 2019-10-21 23:03:12 -03:00
Anthony Latsis
d64d45d3d6 @lvalue exposure fixes & prevention 2019-10-22 04:30:40 +03:00