mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Implement the new casting syntaxes "as" and "as?".
There's a bit of a reshuffle of the ExplicitCastExpr subclasses: - The existing ConditionalCheckedCastExpr expression node now represents "as?". - A new ForcedCheckedCastExpr node represents "as" when it is a downcast. - CoerceExpr represents "as" when it is a coercion. - A new UnresolvedCheckedCastExpr node describes "as" before it has been type-checked down to ForcedCheckedCastExpr or CoerceExpr. This wasn't a strictly necessary change, but it helps us detangle what's going on. There are a few new diagnostics to help users avoid getting bitten by as/as? mistakes: - Custom errors when a forced downcast (as) is used as the operand of postfix '!' or '?', with Fix-Its to remove the '!' or make the downcast conditional (with as?), respectively. - A warning when a forced downcast is injected into an optional, with a suggestion to use a conditional downcast. - A new error when the postfix '!' is used for a contextual downcast, with a Fix-It to replace it with "as T" with the contextual type T. Lots of test updates, none of which felt like regressions. The new tests are in test/expr/cast/optionals.swift. Addresses <rdar://problem/17000058> Swift SVN r18556
This commit is contained in:
@@ -995,7 +995,7 @@ extension String {
|
||||
/// Returns an array of NSString objects containing, in
|
||||
/// order, each path component of the `String`.
|
||||
var pathComponents: String[] {
|
||||
return (_ns.pathComponents as String[])!
|
||||
return _ns.pathComponents as String[]
|
||||
}
|
||||
|
||||
// @property NSString* pathExtension;
|
||||
@@ -1353,7 +1353,7 @@ extension String {
|
||||
/// Returns an array of strings made by separately appending
|
||||
/// to the `String` each string in in a given array.
|
||||
func stringsByAppendingPaths(paths: String[]) -> String[] {
|
||||
return (_ns.stringsByAppendingPaths(paths) as String[])!
|
||||
return _ns.stringsByAppendingPaths(paths) as String[]
|
||||
}
|
||||
|
||||
// - (NSString *)substringFromIndex:(NSUInteger)anIndex
|
||||
|
||||
Reference in New Issue
Block a user