<rdar://problem/19031957> Change failable casts from "as" to "as!"

Previously the "as" keyword could either represent coercion or or forced
downcasting. This change separates the two notions. "as" now only means
type conversion, while the new "as!" operator is used to perform forced
downcasting. If a program uses "as" where "as!" is called for, we emit a
diagnostic and fixit.

Internally, this change removes the UnresolvedCheckedCastExpr class, in
favor of directly instantiating CoerceExpr when parsing the "as"
operator, and ForcedCheckedCastExpr when parsing the "as!" operator.

Swift SVN r24253
This commit is contained in:
Chris Willmore
2015-01-08 00:33:59 +00:00
parent e056663e6f
commit 03a6190a1f
100 changed files with 695 additions and 618 deletions

View File

@@ -976,7 +976,7 @@ NSStringAPIs.test("precomposedStringWithCompatibilityMapping") {
NSStringAPIs.test("propertyList()") {
expectEqual([ "foo", "bar" ],
"(\"foo\", \"bar\")".propertyList() as [String])
"(\"foo\", \"bar\")".propertyList() as! [String])
}
NSStringAPIs.test("propertyListFromStringsFileFormat()") {