swiftlang/swift

`[.]Type` completion for `(any P).` shows it will produce an existential metatype

Open

#65,843 opened on May 10, 2023

View on GitHub
 (32 comments) (0 reactions) (0 assignees)Swift (10,719 forks)batch import
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

Test case:

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

(any P).#^COMPLETE?check=META^# 
// META: Keyword/CurrNominal:  Type[#(any P).Type#]; name=Type

This test will fail, because the current completion is Type[#any P.Type#]; name=Type. Notice how it thinks the completion will produce an existential metatype any P.Type, whereas the actual result is the singleton metatype (any P).Type.

Note any syntax was proposed in SE-0335.

Environment

  • Swift 5.9-dev (c1d5118c21da49a9c2194734cbf9b6970bc63056)

Contributor guide