Skip to content

Don't emit a bogus diagnostic when processing an old actor declaration #37846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2021
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
4 changes: 3 additions & 1 deletion lib/Sema/TypeCheckProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4642,10 +4642,12 @@ void ConformanceChecker::resolveValueWitnesses() {
return;

// Ensure that Actor.unownedExecutor is implemented within the
// actor class itself.
// actor class itself. But if this somehow resolves to the
// requirement, ignore it.
if (requirement->getName().isSimpleName(C.Id_unownedExecutor) &&
Proto->isSpecificProtocol(KnownProtocolKind::Actor) &&
DC != witness->getDeclContext() &&
!isa<ProtocolDecl>(witness->getDeclContext()) &&
Adoptee->getClassOrBoundGenericClass() &&
Adoptee->getClassOrBoundGenericClass()->isActor()) {
witness->diagnose(diag::unowned_executor_outside_actor);
Expand Down
15 changes: 15 additions & 0 deletions test/ModuleInterface/Inputs/OldActor.swiftinterface
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// swift-interface-format-version: 1.0
// swift-module-flags: -enable-library-evolution -module-name OldActor -enable-experimental-concurrency
import Swift
import _Concurrency

#if compiler(>=5.3) && $Actors
@available(SwiftStdlib 5.5, *)
public actor Monk {
public init()
deinit
public func method()
// Lacks an unownedExecutor property
}
#endif

18 changes: 18 additions & 0 deletions test/ModuleInterface/actor_old_compat.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RUN: %empty-directory(%t)
// RUN: mkdir -p %t/OldActor.framework/Modules/OldActor.swiftmodule
// RUN: %target-swift-frontend -emit-module -module-name OldActor %S/Inputs/OldActor.swiftinterface -o %t/OldActor.framework/Modules/OldActor.swiftmodule/%module-target-triple.swiftmodule
// RUN: %target-swift-frontend -F %t -enable-experimental-concurrency -typecheck -verify %s

// RUNX: cp -r %S/Inputs/OldActor.framework %t/
// RUNX: %{python} %S/../CrossImport/Inputs/rewrite-module-triples.py %t %module-target-triple

// REQUIRES: concurrency

import OldActor

@available(SwiftStdlib 5.5, *)
extension Monk {
public func test() async {
method()
}
}