Skip to content

Commit 1557ddf

Browse files
authored
Merge pull request #37846 from rjmccall/tolerate-old-actors
Don't emit a bogus diagnostic when processing an old actor declaration
2 parents 107780c + b182bbc commit 1557ddf

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
@@ -4642,10 +4642,12 @@ void ConformanceChecker::resolveValueWitnesses() {
46424642
return;
46434643

46444644
// Ensure that Actor.unownedExecutor is implemented within the
4645-
// actor class itself.
4645+
// actor class itself. But if this somehow resolves to the
4646+
// requirement, ignore it.
46464647
if (requirement->getName().isSimpleName(C.Id_unownedExecutor) &&
46474648
Proto->isSpecificProtocol(KnownProtocolKind::Actor) &&
46484649
DC != witness->getDeclContext() &&
4650+
!isa<ProtocolDecl>(witness->getDeclContext()) &&
46494651
Adoptee->getClassOrBoundGenericClass() &&
46504652
Adoptee->getClassOrBoundGenericClass()->isActor()) {
46514653
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)