@@ -1202,6 +1202,8 @@ bool OverrideMatcher::checkOverride(ValueDecl *baseDecl,
1202
1202
// If this is an exact type match, we're successful!
1203
1203
Type declTy = getDeclComparisonType ();
1204
1204
Type owningTy = dc->getDeclaredInterfaceType ();
1205
+ bool mismatchedOnSendability =
1206
+ attempt == OverrideCheckingAttempt::MismatchedSendability;
1205
1207
auto isClassContext = classDecl != nullptr ;
1206
1208
if (declIUOAttr == matchDeclIUOAttr && declTy->isEqual (baseTy)) {
1207
1209
// Nothing to do.
@@ -1263,17 +1265,42 @@ bool OverrideMatcher::checkOverride(ValueDecl *baseDecl,
1263
1265
CanType parentPropertyCanTy =
1264
1266
parentPropertyTy->getReducedType (
1265
1267
decl->getInnermostDeclContext ()->getGenericSignatureOfContext ());
1266
- if (!propertyTy->matches (parentPropertyCanTy,
1267
- TypeMatchFlags::AllowOverride)) {
1268
- diags.diagnose (property, diag::override_property_type_mismatch,
1269
- property->getName (), propertyTy, parentPropertyTy);
1270
- noteFixableMismatchedTypes (decl, baseDecl);
1271
- diags.diagnose (baseDecl, diag::property_override_here);
1272
- return true ;
1268
+
1269
+ auto options = TypeMatchFlags::AllowOverride;
1270
+ if (!propertyTy->matches (parentPropertyCanTy, options)) {
1271
+ // The perfect match failed
1272
+ bool failed = true ;
1273
+ if (baseDecl->preconcurrency () &&
1274
+ (attempt == OverrideCheckingAttempt::PerfectMatch ||
1275
+ attempt == OverrideCheckingAttempt::MismatchedSendability)) {
1276
+ propertyTy = propertyTy->stripConcurrency (/* recursive=*/ true ,
1277
+ /* dropGlobalActor=*/ true );
1278
+ parentPropertyCanTy =
1279
+ Type (parentPropertyCanTy)->stripConcurrency (/* recursive=*/ true ,
1280
+ /* dropGlobalActor=*/ true )->getCanonicalType ();
1281
+
1282
+ parentPropertyTy =
1283
+ parentPropertyTy->stripConcurrency (/* recursive=*/ true ,
1284
+ /* dropGlobalActor=*/ true );
1285
+
1286
+
1287
+ if (propertyTy->matches (parentPropertyCanTy, options)) {
1288
+ mismatchedOnSendability = true ;
1289
+ failed = false ;
1290
+ }
1291
+ }
1292
+
1293
+ if (failed) {
1294
+ diags.diagnose (property, diag::override_property_type_mismatch,
1295
+ property->getName (), propertyTy, parentPropertyTy);
1296
+ noteFixableMismatchedTypes (decl, baseDecl);
1297
+ diags.diagnose (baseDecl, diag::property_override_here);
1298
+ return true ;
1299
+ }
1273
1300
}
1274
1301
1275
1302
// Differing only in Optional vs. ImplicitlyUnwrappedOptional is fine.
1276
- bool IsSilentDifference = false ;
1303
+ bool IsSilentDifference = mismatchedOnSendability ;
1277
1304
if (auto propertyTyNoOptional = propertyTy->getOptionalObjectType ())
1278
1305
if (auto parentPropertyTyNoOptional =
1279
1306
parentPropertyTy->getOptionalObjectType ())
@@ -1293,7 +1320,7 @@ bool OverrideMatcher::checkOverride(ValueDecl *baseDecl,
1293
1320
if (emittedMatchError)
1294
1321
return true ;
1295
1322
1296
- if (attempt == OverrideCheckingAttempt::MismatchedSendability ) {
1323
+ if (mismatchedOnSendability ) {
1297
1324
SendableCheckContext fromContext (decl->getDeclContext (),
1298
1325
SendableCheck::Explicit);
1299
1326
auto baseDeclClass = baseDecl->getDeclContext ()->getSelfClassDecl ();
0 commit comments