Skip to content

No completion when using any MyProtocol vs some MyProtocol #68269

@MahdiBM

Description

@MahdiBM

Consider this:

protocol TestProtocol { }

struct TestImpl: TestProtocol { }

extension TestProtocol where Self == TestImpl {
    static var impl: TestImpl {
        TestImpl()
    }
}

func someTestProtocol(value: some TestProtocol) { }

func anyTestProtocol(value: any TestProtocol) { }

For the some variant, you get some useful completion:

Screenshot 2023-09-01 at 5 42 36 PM

But for the any variant, you don't:

Screenshot 2023-09-01 at 5 42 46 PM

As a workaround you can use the some variant in the API and just pass it down to the any variant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.code completionArea → source tooling: code completionexistentialsFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valueslet & varFeature: constant and variable declarationssource toolingArea: IDE support, SourceKit, and other source toolingstatic declarationsFeature → declarations: Static declarationstypesFeature: typesunexpected behaviorBug: Unexpected behavior or incorrect output

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions