Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,26 +898,6 @@ unsigned int TypeBase::getOptionalityDepth() {
}

Type TypeBase::stripConcurrency(bool recurse, bool dropGlobalActor) {

if (auto *arrayTy = dyn_cast<ArraySliceType>(this)) {
auto newBaseTy =
arrayTy->getBaseType()->stripConcurrency(recurse, dropGlobalActor);
return newBaseTy->isEqual(arrayTy->getBaseType())
? Type(this)
: ArraySliceType::get(newBaseTy);
}

if (auto *dictTy = dyn_cast<DictionaryType>(this)) {
auto keyTy = dictTy->getKeyType();
auto strippedKeyTy = keyTy->stripConcurrency(recurse, dropGlobalActor);
auto valueTy = dictTy->getValueType();
auto strippedValueTy = valueTy->stripConcurrency(recurse, dropGlobalActor);

return keyTy->isEqual(strippedKeyTy) && valueTy->isEqual(strippedValueTy)
? Type(this)
: DictionaryType::get(strippedKeyTy, strippedValueTy);
}

// Look through optionals.
if (Type optionalObject = getOptionalObjectType()) {
Type newOptionalObject =
Expand Down Expand Up @@ -1103,6 +1083,25 @@ Type TypeBase::stripConcurrency(bool recurse, bool dropGlobalActor) {
return anyChanged ? TupleType::get(elts, getASTContext()) : Type(this);
}

if (auto *arrayTy = dyn_cast<ArraySliceType>(this)) {
auto newBaseTy =
arrayTy->getBaseType()->stripConcurrency(recurse, dropGlobalActor);
return newBaseTy->isEqual(arrayTy->getBaseType())
? Type(this)
: ArraySliceType::get(newBaseTy);
}

if (auto *dictTy = dyn_cast<DictionaryType>(this)) {
auto keyTy = dictTy->getKeyType();
auto strippedKeyTy = keyTy->stripConcurrency(recurse, dropGlobalActor);
auto valueTy = dictTy->getValueType();
auto strippedValueTy = valueTy->stripConcurrency(recurse, dropGlobalActor);

return keyTy->isEqual(strippedKeyTy) && valueTy->isEqual(strippedValueTy)
? Type(this)
: DictionaryType::get(strippedKeyTy, strippedValueTy);
}

return Type(this);
}

Expand Down
8 changes: 0 additions & 8 deletions lib/Sema/TypeCheckDeclOverride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1260,16 +1260,9 @@ bool OverrideMatcher::checkOverride(ValueDecl *baseDecl,
auto propertyTy = property->getInterfaceType();
auto parentPropertyTy = getSuperMemberDeclType(baseDecl);

// If @preconcurrency, strip concurrency from decl before matching
if (baseDecl->preconcurrency() && !baseDecl->isObjC()){
attempt = OverrideCheckingAttempt::MismatchedSendability;
propertyTy = propertyTy->stripConcurrency(true, true);
parentPropertyTy = parentPropertyTy->stripConcurrency(true, true);
}
CanType parentPropertyCanTy =
parentPropertyTy->getReducedType(
decl->getInnermostDeclContext()->getGenericSignatureOfContext());

if (!propertyTy->matches(parentPropertyCanTy,
TypeMatchFlags::AllowOverride)) {
diags.diagnose(property, diag::override_property_type_mismatch,
Expand All @@ -1289,7 +1282,6 @@ bool OverrideMatcher::checkOverride(ValueDecl *baseDecl,

// The overridden property must not be mutable.
if (cast<AbstractStorageDecl>(baseDecl)->supportsMutation() &&
attempt != OverrideCheckingAttempt::MismatchedSendability &&
!IsSilentDifference) {
diags.diagnose(property, diag::override_mutable_covariant_property,
property->getName(), parentPropertyTy, propertyTy);
Expand Down
17 changes: 0 additions & 17 deletions test/Concurrency/predates_concurrency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -252,20 +252,3 @@ extension MainActorPreconcurrency: NotIsolated {
}
}
}

open class Parent {
init(userInfo: [String : Any]) {
self.userInfo = userInfo
}

@preconcurrency open var userInfo : [String : any Sendable] // expected-note {{overridden declaration is here}}
}

class Child : Parent {
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}}
get {
[:]
}
set {}
}
}