Skip to content

Commit

Permalink
[Features] Rename the BuiltinBuildTaskExecutor feature guard.
Browse files Browse the repository at this point in the history
The name of the `TaskExecutor` protocol was recently changed to remove
underscores after the feature was accepted in Swift Evolution. An implication
of that rename is that the `buildOrdinaryTaskExecutorRef` builtin changed
the type that it expected as the argument. However, the original change
landed in the standard library which as since produced swiftinterfaces
that contain the following inlinable code:

```
@inlinable public init<E>(ordinary executor: __shared E) where E : _Concurrency._TaskExecutor {
  #if $BuiltinBuildTaskExecutor
  self.executor = Builtin.buildOrdinaryTaskExecutorRef(executor)
  #else
  fatalError("Swift compiler is incompatible with this SDK version")
  #endif
}
```

When a compiler containing the protocol rename attempts to type check the
above inlinable code, it crashes because the builtin is expecting an argument
conforming to `TaskExecutor`, which doesn't exist in this version of the
standard library. The issue is that the current compiler still supports
the `$BuiltinBuildTaskExecutor` feature guard, but the builtin supported
has since changed.

To resolve this issue, we need to stop supporting the `$BuiltinBuildTaskExecutor`
feature guard and introduce a new one that is only supported by compiler versions
that contain the rename. This approach relies on nothing having adopted the
API, otherwise we would need to stage in the rename as a parallel set of APIs,
and only remove the old APIs once nothing is relying on the old _Concurrency
swiftinterfaces.
  • Loading branch information
hborla committed Feb 14, 2024
1 parent 6a3bacd commit 56c2b34
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/swift/Basic/Features.def
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ LANGUAGE_FEATURE(BuiltinHopToActor, 0, "Builtin.HopToActor")
LANGUAGE_FEATURE(BuiltinTaskGroupWithArgument, 0, "TaskGroup builtins")
LANGUAGE_FEATURE(InheritActorContext, 0, "@_inheritActorContext attribute")
LANGUAGE_FEATURE(ImplicitSelfCapture, 0, "@_implicitSelfCapture attribute")
LANGUAGE_FEATURE(BuiltinBuildTaskExecutor, 0, "TaskExecutor-building builtins")
LANGUAGE_FEATURE(BuiltinBuildTaskExecutorRef, 0, "TaskExecutor-building builtins")
LANGUAGE_FEATURE(BuiltinBuildExecutor, 0, "Executor-building builtins")
LANGUAGE_FEATURE(BuiltinBuildComplexEqualityExecutor, 0, "Executor-building for 'complexEquality executor' builtins")
LANGUAGE_FEATURE(BuiltinBuildMainExecutor, 0, "MainActor executor building builtin")
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3230,7 +3230,7 @@ static bool usesFeatureBuiltinExecutor(Decl *decl) {
return usesBuiltinType(decl, BuiltinTypeKind::BuiltinExecutor);
}

static bool usesFeatureBuiltinBuildTaskExecutor(Decl *decl) { return false; }
static bool usesFeatureBuiltinBuildTaskExecutorRef(Decl *decl) { return false; }

static bool usesFeatureBuiltinBuildExecutor(Decl *decl) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/Concurrency/Executor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public struct UnownedTaskExecutor: Sendable {

@inlinable
public init<E: TaskExecutor>(ordinary executor: __shared E) {
#if $BuiltinBuildTaskExecutor
#if $BuiltinBuildTaskExecutorRef
self.executor = Builtin.buildOrdinaryTaskExecutorRef(executor)
#else
fatalError("Swift compiler is incompatible with this SDK version")
Expand Down

0 comments on commit 56c2b34

Please sign in to comment.