swiftlang/swift
View on GitHubCode completion: Stop suggesting old-style protocol metatype syntax in Swift 6 mode
Open
#65,699 opened on May 5, 2023
bugcode completionexistentialsgood first issuemetatypessource toolingswift 5.9typesunexpected behavior
Repository metrics
- Stars
- (69,989 stars)
- PR merge metrics
- (Avg merge 8d 17h) (510 merged PRs in 30d)
Description
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)