Commits

Doug Gregor committed bfe7ff21688
Extend the AST walker that performs type coercion to have two modes: one that performs the coercion on the AST and produces diagnostics for any problems, and one that simply determines whether the coercion would succeed. The former already existed (as TypeChecker::convertToType), while an approximation of the latter was already implemented as Expr::getRankOfConversionTo(). Unifying these code paths addresses several issues: - Lots of redundancy in the code for computing these two properties, which causes bugs. For example, Expr::getRankOfConversionTo() wasn't able to handle literals (!). - Determining whether a conversion is possible will need the full power of the type checker, e.g., to deal with closures in cases like: func f(g : (int, int) -> int); func h() { f({$1 + 0}); } Although this is not handled correctly now. I have opted not to adopt Clang's ImplicitConversionSequence (or InitializationSequence) design, which computes a record of the steps needed to perform the conversion/coercion and later applies those steps, because we don't need that complexity yet. If we start introducing more implicit conversions into the language, we'll revisit this decision. Swift SVN r1308