swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.3k stars 10.34k forks source link

Distributed: incorrect diagnostics for missing import #59172

Open MaxDesiatov opened 2 years ago

MaxDesiatov commented 2 years ago

Describe the bug When import Distributed is missing in a file which has distributed actor with distributed func in it, an seemingly unrelated error messages are produced:

error: type 'Greeter' does not conform to protocol 'Equatable'
...
<unknown>:0: error: cannot find '__isRemoteActor' in scope
<unknown>:0: error: cannot find 'RemoteCallTarget' in scope

To Reproduce

  1. Create a file with this content (assuming an implementation YourClusterSystem of DistributedActorSystem is in scope)
    
    typealias DefaultDistributedActorSystem = YourClusterSystem

distributed actor Greeter { distributed func hello() { print("Hello, Distributed World!") } }


2. Try to build and observe unrelated error messages that don't mention the missing import.
3. Adding `import Distributed` in such file makes the errors go away.

**Expected behavior**
If `import Distributed` is always needed in files that contain distributed actors, an error message that requires the import should be displayed. Unrelated diagnostics about missing `Equatable` conformance shouldn't be displayed as it's confusing.

**Environment:**
OS: macOS 12.4 (21F79), but most likely reproducible on any platform that supports distributed actors.
Xcode Version/Tag/Branch: 13.4 (13F17a)
Toolchain: Swift Development Snapshot 2022-05-27, also reproducible with 5.7 Development Snapshot 2022-05-18 (a)
ktoso commented 2 years ago

Thanks, I’ve known about that one but didn’t seem to have a public bug about it — thanks for reporting!

yes, the diagnosis should be about the missing import indeed :-)

ktoso commented 2 years ago

Note to self, also add a test with an extension in separate module that forgot to do the import

akbashev commented 1 year ago

Issue is still there, just saying.