Skip to content

Commit 3eb73a5

Browse files
authored
Merge pull request swiftlang#36305 from DougGregor/remove-actor-enqueue-partial-task
2 parents 48ef52f + 47b0abf commit 3eb73a5

18 files changed

+7
-397
lines changed

include/swift/ABI/MetadataValues.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,9 +1173,6 @@ namespace SpecialPointerAuthDiscriminators {
11731173
/// Resilient class stub initializer callback
11741174
const uint16_t ResilientClassStubInitCallback = 0xC671;
11751175

1176-
/// Actor enqueue(partialTask:).
1177-
const uint16_t ActorEnqueuePartialTask = 0x8f3d;
1178-
11791176
/// Jobs, tasks, and continuations.
11801177
const uint16_t JobInvokeFunction = 0xcc64; // = 52324
11811178
const uint16_t TaskResumeFunction = 0x2c42; // = 11330

include/swift/AST/Decl.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3940,7 +3940,6 @@ enum class KnownDerivableProtocolKind : uint8_t {
39403940
Decodable,
39413941
AdditiveArithmetic,
39423942
Differentiable,
3943-
Actor,
39443943
};
39453944

39463945
/// ProtocolDecl - A declaration of a protocol, for example:
@@ -6159,14 +6158,6 @@ class FuncDecl : public AbstractFunctionDecl {
61596158

61606159
bool isMainTypeMainMethod() const;
61616160

6162-
/// Whether the given name is enqueue(partialTask:), which is used for
6163-
/// actors.
6164-
static bool isEnqueuePartialTaskName(ASTContext &ctx, DeclName name);
6165-
6166-
/// Determine whether this function is the witness to the Actor protocol's
6167-
/// enqueue(partialTask:) operation within an actor.
6168-
bool isActorEnqueuePartialTaskWitness() const;
6169-
61706161
SelfAccessKind getSelfAccessKind() const;
61716162

61726163
void setSelfAccessKind(SelfAccessKind mod) {

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4412,10 +4412,6 @@ ERROR(concurrency_lib_missing,none,
44124412
ERROR(async_main_no_concurrency,none,
44134413
"'_Concurrency' module not imported, required for async main", ())
44144414

4415-
ERROR(enqueue_partial_task_not_in_context,none,
4416-
"'enqueue(partialTask:)' can only be implemented in the definition of "
4417-
"actor class %0", (Type))
4418-
44194415
ERROR(global_actor_missing_shared,none,
44204416
"global actor %0 requires a static property 'shared' that produces an "
44214417
"actor instance", (Identifier))

include/swift/AST/KnownIdentifiers.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ IDENTIFIER(oldValue)
117117
IDENTIFIER(Optional)
118118
IDENTIFIER_(OptionalNilComparisonType)
119119
IDENTIFIER(parameter)
120-
IDENTIFIER(partialTask)
121-
IDENTIFIER(PartialAsyncTask)
122120
IDENTIFIER(projected)
123121
IDENTIFIER(projectedValue)
124122
IDENTIFIER(Protocol)
@@ -220,7 +218,6 @@ IDENTIFIER(className)
220218

221219
IDENTIFIER(_defaultActorInitialize)
222220
IDENTIFIER(_defaultActorDestroy)
223-
IDENTIFIER(_defaultActorEnqueue)
224221

225222
IDENTIFIER_(ErrorType)
226223
IDENTIFIER(Code)

lib/AST/Decl.cpp

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -5083,8 +5083,6 @@ Optional<KnownDerivableProtocolKind>
50835083
return KnownDerivableProtocolKind::AdditiveArithmetic;
50845084
case KnownProtocolKind::Differentiable:
50855085
return KnownDerivableProtocolKind::Differentiable;
5086-
case KnownProtocolKind::Actor:
5087-
return KnownDerivableProtocolKind::Actor;
50885086
default: return None;
50895087
}
50905088
}
@@ -7559,56 +7557,6 @@ bool FuncDecl::isMainTypeMainMethod() const {
75597557
getParameters()->size() == 0;
75607558
}
75617559

7562-
bool FuncDecl::isEnqueuePartialTaskName(ASTContext &ctx, DeclName name) {
7563-
if (name.isCompoundName() && name.getBaseName() == ctx.Id_enqueue) {
7564-
auto argumentNames = name.getArgumentNames();
7565-
return argumentNames.size() == 1 && argumentNames[0] == ctx.Id_partialTask;
7566-
}
7567-
7568-
return false;
7569-
}
7570-
7571-
bool FuncDecl::isActorEnqueuePartialTaskWitness() const {
7572-
if (!isEnqueuePartialTaskName(getASTContext(), getName()))
7573-
return false;
7574-
7575-
auto classDecl = getDeclContext()->getSelfClassDecl();
7576-
if (!classDecl)
7577-
return false;
7578-
7579-
if (!classDecl->isActor())
7580-
return false;
7581-
7582-
ASTContext &ctx = getASTContext();
7583-
auto actorProto = ctx.getProtocol(KnownProtocolKind::Actor);
7584-
if (!actorProto)
7585-
return false;
7586-
7587-
FuncDecl *requirement = nullptr;
7588-
for (auto protoMember : actorProto->getParsedMembers()) {
7589-
if (auto protoFunc = dyn_cast<FuncDecl>(protoMember)) {
7590-
if (isEnqueuePartialTaskName(ctx, protoFunc->getName())) {
7591-
requirement = protoFunc;
7592-
break;
7593-
}
7594-
}
7595-
}
7596-
7597-
if (!requirement)
7598-
return false;
7599-
7600-
SmallVector<ProtocolConformance *, 1> conformances;
7601-
classDecl->lookupConformance(
7602-
classDecl->getModuleContext(), actorProto, conformances);
7603-
for (auto conformance : conformances) {
7604-
auto witness = conformance->getWitnessDecl(requirement);
7605-
if (witness == this)
7606-
return true;
7607-
}
7608-
7609-
return false;
7610-
}
7611-
76127560
ConstructorDecl::ConstructorDecl(DeclName Name, SourceLoc ConstructorLoc,
76137561
bool Failable, SourceLoc FailabilityLoc,
76147562
bool Throws,
@@ -8003,17 +7951,6 @@ Type TypeBase::getSwiftNewtypeUnderlyingType() {
80037951
}
80047952

80057953
bool ClassDecl::hasExplicitCustomActorMethods() const {
8006-
auto &ctx = getASTContext();
8007-
for (auto member: getMembers()) {
8008-
if (member->isImplicit()) continue;
8009-
8010-
// Methods called enqueue(partialTask:)
8011-
if (auto func = dyn_cast<FuncDecl>(member)) {
8012-
if (FuncDecl::isEnqueuePartialTaskName(ctx, func->getName()))
8013-
return true;
8014-
}
8015-
}
8016-
80177954
return false;
80187955
}
80197956

lib/IRGen/GenPointerAuth.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -400,17 +400,6 @@ PointerAuthEntity::getDeclDiscriminator(IRGenModule &IGM) const {
400400
assert(!constant.isForeign &&
401401
"discriminator for foreign declaration not supported yet!");
402402

403-
// Special case: methods that are witnesses to Actor.enqueue(partialTask:)
404-
// have their own discriminator, which is shared across all actor classes.
405-
if (constant.hasFuncDecl()) {
406-
auto func = dyn_cast<FuncDecl>(constant.getFuncDecl());
407-
if (func->isActorEnqueuePartialTaskWitness()) {
408-
cache = IGM.getSize(
409-
Size(SpecialPointerAuthDiscriminators::ActorEnqueuePartialTask));
410-
return cache;
411-
}
412-
}
413-
414403
auto mangling = constant.mangle();
415404
cache = getDiscriminatorForString(IGM, mangling);
416405
return cache;

lib/Sema/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ add_swift_host_library(swiftSema STATIC
1818
ConstraintLocator.cpp
1919
ConstraintSystem.cpp
2020
DebuggerTestingTransform.cpp
21-
DerivedConformanceActor.cpp
2221
DerivedConformanceAdditiveArithmetic.cpp
2322
DerivedConformanceCaseIterable.cpp
2423
DerivedConformanceCodable.cpp

lib/Sema/DerivedConformanceActor.cpp

Lines changed: 0 additions & 175 deletions
This file was deleted.

lib/Sema/DerivedConformances.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ bool DerivedConformance::derivesProtocolConformance(DeclContext *DC,
7575
return canDeriveHashable(Nominal);
7676
}
7777

78-
if (*derivableKind == KnownDerivableProtocolKind::Actor) {
79-
return canDeriveActor(Nominal, DC);
80-
}
81-
8278
if (*derivableKind == KnownDerivableProtocolKind::AdditiveArithmetic)
8379
return canDeriveAdditiveArithmetic(Nominal, DC);
8480

@@ -350,11 +346,6 @@ ValueDecl *DerivedConformance::getDerivableRequirement(NominalTypeDecl *nominal,
350346
return getRequirement(KnownProtocolKind::Hashable);
351347
}
352348

353-
// Actor.enqueue(partialTask: PartialTask)
354-
if (FuncDecl::isEnqueuePartialTaskName(ctx, name)) {
355-
return getRequirement(KnownProtocolKind::Actor);
356-
}
357-
358349
return nullptr;
359350
}
360351

lib/Sema/DerivedConformances.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,6 @@ class DerivedConformance {
298298
/// \returns the derived member, which will also be added to the type.
299299
ValueDecl *deriveDecodable(ValueDecl *requirement);
300300

301-
/// Whether we can derive the given Actor requirement in the given context.
302-
static bool canDeriveActor(NominalTypeDecl *nominal, DeclContext *dc);
303-
304-
/// Derive an Actor requirement for an actor class.
305-
///
306-
/// \returns the derived member, which will also be added to the type.
307-
ValueDecl *deriveActor(ValueDecl *requirement);
308-
309301
/// Declare a read-only property.
310302
std::pair<VarDecl *, PatternBindingDecl *>
311303
declareDerivedProperty(Identifier name, Type propertyInterfaceType,

0 commit comments

Comments
 (0)