Commit Graph

7 Commits

Author SHA1 Message Date
Chris Lattner
f571e64161 Enhance visitCallExpr in the face of a contextual type. Only perform the
forced conversion to "_ -> T" if it will refine the type otherwise found by
doing a non-contextual type check.  This allows us to diagnose calls to 
non-function values with more specificity, e.g. adding another case were we
recommend "do" when using bare braces.


Swift SVN r31726
2015-09-06 19:01:47 +00:00
Chris Lattner
d167dfbbfa When typechecking the callee of a CallExpr, and when we have a contextual type,
use that contextual type to guide typechecking of the callee.  This allows us to
propagate that type through generic constraints effectively, making us produce
much more useful diagnostics within closures taking methods like "map" (for 
example).

This fixes:
<rdar://problem/20491794> QoI closures: Error message does not tell me what the problem is
Specifically, running the testcase:

enum Color { case Unknown(description: String) }
let xs: (Int, Color) = [1,2].map({ ($0, .Unknown("")) })

produces: error: cannot convert call result type '[_]' to expected type '(Int, Color)'

Changing that to:
let xs: [(Int, Color)] = [1,2].map({ ($0, .Unknown("")) })

produces: error: missing argument label 'description:' in call
... with a fixit to introduce the label.

This also fixes most of 22333090, but we're only using this machinery for CallExprs
so far, not for operators yet.



Swift SVN r31484
2015-08-26 05:41:47 +00:00
Chris Lattner
1a0a0315fe wordsmith a diagnostic, NFC otherwise.
Swift SVN r30731
2015-07-28 23:35:25 +00:00
Chris Lattner
06cc05daa9 reword a diagnostic, as suggested by Jordan
Swift SVN r30712
2015-07-28 04:03:25 +00:00
Chris Lattner
8c3e62d7c5 Provide contextually sensitive conversion failure messages for situations in
which we have a contextual type that was the failure reason.  These are a bit
longer but also more explicit than the previous diagnostics.



Swift SVN r30669
2015-07-26 23:06:40 +00:00
Chris Lattner
e4b6afb9ae Start moving the testsuite to the "_ = foo()" idiom for evaluating an
expression but ignoring its value.  This is the right canonical way to do
this.  NFC, just testsuite changes.



Swift SVN r28638
2015-05-15 20:15:54 +00:00
Jordan Rose
a493410402 [ClangImporter] Map MacTypes.h's ItemCount and ByteCount to Swift.Int.
typedef unsigned long ByteCount;
  typedef unsigned long ItemCount;

Both of these are still in use by CoreMIDI, but we don't have a reason to
keep them distinct in Swift.

rdar://problem/19939552

Swift SVN r25529
2015-02-25 05:00:06 +00:00