Skip to content

Commit 979cd16

Browse files
authored
Merge pull request #74045 from apple/revert-73158-any-to-any-sendable-override
Revert "[Sema] Warn about 'Any' to 'any Sendable' override"
2 parents ba773d5 + 789a31f commit 979cd16

File tree

3 files changed

+19
-45
lines changed

3 files changed

+19
-45
lines changed

lib/AST/Type.cpp

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -898,26 +898,6 @@ unsigned int TypeBase::getOptionalityDepth() {
898898
}
899899

900900
Type TypeBase::stripConcurrency(bool recurse, bool dropGlobalActor) {
901-
902-
if (auto *arrayTy = dyn_cast<ArraySliceType>(this)) {
903-
auto newBaseTy =
904-
arrayTy->getBaseType()->stripConcurrency(recurse, dropGlobalActor);
905-
return newBaseTy->isEqual(arrayTy->getBaseType())
906-
? Type(this)
907-
: ArraySliceType::get(newBaseTy);
908-
}
909-
910-
if (auto *dictTy = dyn_cast<DictionaryType>(this)) {
911-
auto keyTy = dictTy->getKeyType();
912-
auto strippedKeyTy = keyTy->stripConcurrency(recurse, dropGlobalActor);
913-
auto valueTy = dictTy->getValueType();
914-
auto strippedValueTy = valueTy->stripConcurrency(recurse, dropGlobalActor);
915-
916-
return keyTy->isEqual(strippedKeyTy) && valueTy->isEqual(strippedValueTy)
917-
? Type(this)
918-
: DictionaryType::get(strippedKeyTy, strippedValueTy);
919-
}
920-
921901
// Look through optionals.
922902
if (Type optionalObject = getOptionalObjectType()) {
923903
Type newOptionalObject =
@@ -1103,6 +1083,25 @@ Type TypeBase::stripConcurrency(bool recurse, bool dropGlobalActor) {
11031083
return anyChanged ? TupleType::get(elts, getASTContext()) : Type(this);
11041084
}
11051085

1086+
if (auto *arrayTy = dyn_cast<ArraySliceType>(this)) {
1087+
auto newBaseTy =
1088+
arrayTy->getBaseType()->stripConcurrency(recurse, dropGlobalActor);
1089+
return newBaseTy->isEqual(arrayTy->getBaseType())
1090+
? Type(this)
1091+
: ArraySliceType::get(newBaseTy);
1092+
}
1093+
1094+
if (auto *dictTy = dyn_cast<DictionaryType>(this)) {
1095+
auto keyTy = dictTy->getKeyType();
1096+
auto strippedKeyTy = keyTy->stripConcurrency(recurse, dropGlobalActor);
1097+
auto valueTy = dictTy->getValueType();
1098+
auto strippedValueTy = valueTy->stripConcurrency(recurse, dropGlobalActor);
1099+
1100+
return keyTy->isEqual(strippedKeyTy) && valueTy->isEqual(strippedValueTy)
1101+
? Type(this)
1102+
: DictionaryType::get(strippedKeyTy, strippedValueTy);
1103+
}
1104+
11061105
return Type(this);
11071106
}
11081107

lib/Sema/TypeCheckDeclOverride.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,16 +1260,9 @@ bool OverrideMatcher::checkOverride(ValueDecl *baseDecl,
12601260
auto propertyTy = property->getInterfaceType();
12611261
auto parentPropertyTy = getSuperMemberDeclType(baseDecl);
12621262

1263-
// If @preconcurrency, strip concurrency from decl before matching
1264-
if (baseDecl->preconcurrency() && !baseDecl->isObjC()){
1265-
attempt = OverrideCheckingAttempt::MismatchedSendability;
1266-
propertyTy = propertyTy->stripConcurrency(true, true);
1267-
parentPropertyTy = parentPropertyTy->stripConcurrency(true, true);
1268-
}
12691263
CanType parentPropertyCanTy =
12701264
parentPropertyTy->getReducedType(
12711265
decl->getInnermostDeclContext()->getGenericSignatureOfContext());
1272-
12731266
if (!propertyTy->matches(parentPropertyCanTy,
12741267
TypeMatchFlags::AllowOverride)) {
12751268
diags.diagnose(property, diag::override_property_type_mismatch,
@@ -1289,7 +1282,6 @@ bool OverrideMatcher::checkOverride(ValueDecl *baseDecl,
12891282

12901283
// The overridden property must not be mutable.
12911284
if (cast<AbstractStorageDecl>(baseDecl)->supportsMutation() &&
1292-
attempt != OverrideCheckingAttempt::MismatchedSendability &&
12931285
!IsSilentDifference) {
12941286
diags.diagnose(property, diag::override_mutable_covariant_property,
12951287
property->getName(), parentPropertyTy, propertyTy);

test/Concurrency/predates_concurrency.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -252,20 +252,3 @@ extension MainActorPreconcurrency: NotIsolated {
252252
}
253253
}
254254
}
255-
256-
open class Parent {
257-
init(userInfo: [String : Any]) {
258-
self.userInfo = userInfo
259-
}
260-
261-
@preconcurrency open var userInfo : [String : any Sendable] // expected-note {{overridden declaration is here}}
262-
}
263-
264-
class Child : Parent {
265-
override var userInfo: [String : Any] { // expected-warning {{declaration 'userInfo' has a type with different sendability from any potential overrides; this is an error in the Swift 6 language mode}}
266-
get {
267-
[:]
268-
}
269-
set {}
270-
}
271-
}

0 commit comments

Comments
 (0)