Skip to content

Code completion: Stop suggesting old-style protocol metatype syntax in Swift 6 mode #65699

@AnthonyLatsis

Description

@AnthonyLatsis

In Swift 6 mode, [.]Protocol1 is no longer a valid suggestion. Per SE-0335, we should suggest two distinct [.]Type1 completions for a plain protocol/composition — one aiming at any P.Type and another aiming at (any P).Type — that also insert a missing any prefix, and parenthesize the acted-upon existential in the second case.

Test case (should not succeed):

// RUN: %empty-directory(%t)
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t -swift-version 6

protocol P {}

let _: P#^COMPLETE1?check=META^#
let _: any P#^COMPLETE2?check=META^#
let _: (any P)#^COMPLETE3?check=META^#

// META: Keyword/None: .Protocol[#(any P).Type#]; name=Protocol

Environment

Footnotes

  1. [x] means x is optional 2

Metadata

Metadata

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 valuesgood first issueGood for newcomersmetatypesFeature → types: Metatypessource toolingArea: IDE support, SourceKit, and other source toolingswift 5.9typesFeature: 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