Skip to content

Commit ae1298f

Browse files
committed
Don't emit a bogus diagnostic when processing an old actor declaration.
This seems to only happen when parsing swiftinterfaces, but I've written this to be more generally defensive. rdar://78233377
1 parent 3c71ada commit ae1298f

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4569,10 +4569,12 @@ void ConformanceChecker::resolveValueWitnesses() {
45694569
return;
45704570

45714571
// Ensure that Actor.unownedExecutor is implemented within the
4572-
// actor class itself.
4572+
// actor class itself. But if this somehow resolves to the
4573+
// requirement, ignore it.
45734574
if (requirement->getName().isSimpleName(C.Id_unownedExecutor) &&
45744575
Proto->isSpecificProtocol(KnownProtocolKind::Actor) &&
45754576
DC != witness->getDeclContext() &&
4577+
!isa<ProtocolDecl>(witness->getDeclContext()) &&
45764578
Adoptee->getClassOrBoundGenericClass() &&
45774579
Adoptee->getClassOrBoundGenericClass()->isActor()) {
45784580
witness->diagnose(diag::unowned_executor_outside_actor);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags: -enable-library-evolution -module-name OldActor -enable-experimental-concurrency
3+
import Swift
4+
import _Concurrency
5+
6+
#if compiler(>=5.3) && $Actors
7+
@available(SwiftStdlib 5.5, *)
8+
public actor Monk {
9+
public init()
10+
deinit
11+
public func method()
12+
// Lacks an unownedExecutor property
13+
}
14+
#endif
15+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: mkdir -p %t/OldActor.framework/Modules/OldActor.swiftmodule
3+
// RUN: %target-swift-frontend -emit-module -module-name OldActor %S/Inputs/OldActor.swiftinterface -o %t/OldActor.framework/Modules/OldActor.swiftmodule/%module-target-triple.swiftmodule
4+
// RUN: %target-swift-frontend -F %t -enable-experimental-concurrency -typecheck -verify %s
5+
6+
// RUNX: cp -r %S/Inputs/OldActor.framework %t/
7+
// RUNX: %{python} %S/../CrossImport/Inputs/rewrite-module-triples.py %t %module-target-triple
8+
9+
// REQUIRES: concurrency
10+
11+
import OldActor
12+
13+
@available(SwiftStdlib 5.5, *)
14+
extension Monk {
15+
public func test() async {
16+
method()
17+
}
18+
}

0 commit comments

Comments
 (0)