swiftlang/swift

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

Open

#65,699 opened on 2023年5月5日

GitHub で見る
 (9 comments) (0 reactions) (1 assignee)Swift (10,719 forks)batch import
bugcode completionexistentialsgood first issuemetatypessource toolingswift 5.9typesunexpected behavior

Repository metrics

Stars
 (69,989 stars)
PR merge metrics
 (平均マージ 8d 17h) (30d で 510 merged PRs)

説明

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

  • Swift 5.9-dev (c1d5118c21d)

Footnotes

  1. [x] means x is optional 2

コントリビューターガイド