@@ -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,44 @@ 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
+ // one way to do this:
1277
+ // - options |= TypeMatchFlags::IgnoreSendability;
1278
+ propertyTy = propertyTy->stripConcurrency (/* recursive=*/ true ,
1279
+ /* dropGlobalActor=*/ true );
1280
+ parentPropertyCanTy =
1281
+ Type (parentPropertyCanTy)->stripConcurrency (/* recursive=*/ true ,
1282
+ /* dropGlobalActor=*/ true )->getCanonicalType ();
1283
+
1284
+ parentPropertyTy =
1285
+ parentPropertyTy->stripConcurrency (/* recursive=*/ true ,
1286
+ /* dropGlobalActor=*/ true );
1287
+
1288
+
1289
+ if (propertyTy->matches (parentPropertyCanTy, options)) {
1290
+ mismatchedOnSendability = true ;
1291
+ failed = false ;
1292
+ }
1293
+ }
1294
+
1295
+ if (failed) {
1296
+ diags.diagnose (property, diag::override_property_type_mismatch,
1297
+ property->getName (), propertyTy, parentPropertyTy);
1298
+ noteFixableMismatchedTypes (decl, baseDecl);
1299
+ diags.diagnose (baseDecl, diag::property_override_here);
1300
+ return true ;
1301
+ }
1273
1302
}
1274
1303
1275
1304
// Differing only in Optional vs. ImplicitlyUnwrappedOptional is fine.
1276
- bool IsSilentDifference = false ;
1305
+ bool IsSilentDifference = mismatchedOnSendability ;
1277
1306
if (auto propertyTyNoOptional = propertyTy->getOptionalObjectType ())
1278
1307
if (auto parentPropertyTyNoOptional =
1279
1308
parentPropertyTy->getOptionalObjectType ())
@@ -1293,7 +1322,7 @@ bool OverrideMatcher::checkOverride(ValueDecl *baseDecl,
1293
1322
if (emittedMatchError)
1294
1323
return true ;
1295
1324
1296
- if (attempt == OverrideCheckingAttempt::MismatchedSendability ) {
1325
+ if (mismatchedOnSendability ) {
1297
1326
SendableCheckContext fromContext (decl->getDeclContext (),
1298
1327
SendableCheck::Explicit);
1299
1328
auto baseDeclClass = baseDecl->getDeclContext ()->getSelfClassDecl ();
0 commit comments