mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
@@ -2852,6 +2852,22 @@ bool ContextualFailure::diagnoseAsError() {
|
||||
break;
|
||||
}
|
||||
|
||||
case ConstraintLocator::OptionalInjection: {
|
||||
// If this is an attempt at a Double <-> CGFloat conversion
|
||||
// through optional chaining, let's produce a tailored diagnostic.
|
||||
if (isExpr<OptionalEvaluationExpr>(getAnchor())) {
|
||||
if ((fromType->isDouble() || fromType->isCGFloat()) &&
|
||||
(toType->isDouble() || toType->isCGFloat())) {
|
||||
fromType = OptionalType::get(fromType);
|
||||
toType = OptionalType::get(toType);
|
||||
diagnostic = diag::cannot_implicitly_convert_in_optional_context;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
case ConstraintLocator::EnumPatternImplicitCastMatch: {
|
||||
// In this case, the types are reversed, as we are checking whether we
|
||||
// can convert the pattern type to the context type.
|
||||
|
||||
Reference in New Issue
Block a user