Commit Graph

13 Commits

Author SHA1 Message Date
Max Moiseev
9a018bd77d Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-20 14:38:22 -08:00
Chris Lattner
2f5af054bf Don't complain about unreachable catch blocks that are due to platform
specific #if code.  This has no known ticket filed for them, Dmitri
mentioned this on swift-dev.
2016-01-18 23:05:06 -08:00
Dmitri Gribenko
feacbc4433 Rename ErrorType to ErrorProtocol 2015-12-09 17:12:19 -08:00
John McCall
a20bfb0ada Correct 'throw' to 'throws' in function signatures and types.
rdar://21328447

Swift SVN r30514
2015-07-22 23:30:13 +00:00
John McCall
bc3b47b98a Infer the return type of a closure to be () if it contains no
return statements, or a return statement with no operand.

Also, fix a special-case diagnostic about converting a return
expression to (1) only apply to converting the actual return
expression, not an arbitrary sub-expression, and (2) use the
actual operand and return types, not the drilled-down types
that caused the failure.

Swift SVN r30420
2015-07-20 21:52:18 +00:00
Chris Lattner
4b4f909d1a Several tangled up changes:
- Enable 'catch is NSError' and 'catch let e as NSError {' patterns to
   a) work, and b) be considered to be exhaustive catches.  This enables
   people to catch an error and *use* it as an NSError directly, instead
   of having to do boiler-platey cases.  This is particularly important
   for the migrator.

 - Do not warn about non-noop coersion casts (like "_ as NSError" when
   matching an ErrorType), since they provide useful type adjustment to
   the subpattern.  Still warn on noop ones.

 - Simplify CatchStmt::isSyntacticallyExhaustive to use 
   Pattern::isRefutablePattern.  Add a FIXME, because the parser is guiding
   closure "throws" inference before the pattern is type checked, which means
   that it is incorrect (but only in subtle cases).

 - When diagnosing pointless 'as' patterns like:

  switch 4 {
  case _ as Int: break 

say "'as' test is always true" instead of "'is' test is always true".




Swift SVN r28774
2015-05-19 17:32:32 +00:00
Chris Lattner
678b99f347 Fix <rdar://problem/20985280> QoI: improve diagnostic on improper pattern match on type
Where before we would diagnose something like "catch MyType {" with two errors (one of
which complaining about a ~= the user didn't write) and two notes, we now produce:

 error: 'is' keyword required to pattern match against type name

with a fixit hint to insert the 'is'.



Swift SVN r28761
2015-05-19 06:25:50 +00:00
Chris Willmore
6951e460f0 If 'throws' is written after the result type in a function decl, suggest
moving it to before the arrow.

<rdar://problem/20857518> QoI for "throws" in the wrong place

Swift SVN r28492
2015-05-12 22:50:42 +00:00
Ted Kremenek
9f9bb725cf Rename '_ErrorType' to 'ErrorType'.
Swift SVN r28293
2015-05-07 21:59:29 +00:00
John McCall
71198a2869 Test error-coverage diagnostics more completely.
Fix an assert-on-valid caused by a broken getSourceRange()
implementation and a missing diagnostic caused by a broken
walker implementation.

Swift SVN r28142
2015-05-05 00:30:51 +00:00
John McCall
fdcecfcfb7 Move error-handling diagnostics to Sema and check try coverage.
Needs better test-case coverage.

Swift SVN r27898
2015-04-29 00:49:40 +00:00
Chris Lattner
2f15b53fe8 Add support for 'catch {' as a synonym for "catch let error {".
Swift SVN r27702
2015-04-24 18:54:45 +00:00
John McCall
2560e62b66 Only allow 'throw' expressions at statement positions.
rdar://20385676

Swift SVN r26833
2015-04-01 22:30:53 +00:00