mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Emit a different diagnostic for Swift 3/4 for 'as T!'.
We ended up supporting these coercions for Swift 3/4 via disjunctions, so change our warning to one saying that it's deprecated rather than erroneously telling the user that we're treating '!' as if it were '?'. Fixes rdar://problem/37121121.
This commit is contained in:
@@ -2525,6 +2525,9 @@ namespace {
|
||||
// Validate the resulting type.
|
||||
TypeResolutionOptions options = TypeResolutionFlags::AllowUnboundGenerics;
|
||||
options |= TypeResolutionFlags::InExpression;
|
||||
// Prior to Swift 5, we allow 'as T!' and turn it into a disjunction.
|
||||
if (!CS.getASTContext().isSwiftVersionAtLeast(5))
|
||||
options |= TypeResolutionFlags::AllowIUODeprecated;
|
||||
if (tc.validateType(expr->getCastTypeLoc(), CS.DC, options))
|
||||
return nullptr;
|
||||
|
||||
@@ -2554,6 +2557,9 @@ namespace {
|
||||
// Validate the resulting type.
|
||||
TypeResolutionOptions options = TypeResolutionFlags::AllowUnboundGenerics;
|
||||
options |= TypeResolutionFlags::InExpression;
|
||||
// Prior to Swift 5, we allow 'as T!' and turn it into a disjunction.
|
||||
if (!CS.getASTContext().isSwiftVersionAtLeast(5))
|
||||
options |= TypeResolutionFlags::AllowIUODeprecated;
|
||||
if (tc.validateType(expr->getCastTypeLoc(), CS.DC, options))
|
||||
return nullptr;
|
||||
|
||||
@@ -2588,6 +2594,9 @@ namespace {
|
||||
// Validate the resulting type.
|
||||
TypeResolutionOptions options = TypeResolutionFlags::AllowUnboundGenerics;
|
||||
options |= TypeResolutionFlags::InExpression;
|
||||
// Prior to Swift 5, we allow 'as T!' and turn it into a disjunction.
|
||||
if (!CS.getASTContext().isSwiftVersionAtLeast(5))
|
||||
options |= TypeResolutionFlags::AllowIUODeprecated;
|
||||
if (tc.validateType(expr->getCastTypeLoc(), CS.DC, options))
|
||||
return nullptr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user