swiftlang/swift

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

オープン

#65,699 opened on 2023/05/05

 (9 件のコメント) (0 件のリアクション) (1 人の担当者)Swift (10,719 件のフォーク)batch import
IDE supportbugcode completionexistentialsgood first issuemetatypesswift 5.9typesunexpected behavior

Repository metrics

Stars
 (69,989 個のスター)
PR merge metrics
 (PR metrics pending)

説明

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

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