swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.57k stars 10.35k forks source link

[SR-4845] Irrelevant elements when autocompleting enum cases #47422

Open NachoSoto opened 7 years ago

NachoSoto commented 7 years ago
Previous ID SR-4845
Radar None
Original Reporter @NachoSoto
Type Bug

Attachment: Download

Environment Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42) Swift version 4.0.2 (swiftlang-900.0.69.1 clang-900.0.38)
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | CodeCompletion, Compiler | |Labels | Bug, TypeChecker | |Assignee | @nkcsgexi | |Priority | Medium | md5: 3f5617c817e3a5ad98b2f2fe12db4c38

Issue Description:

Write the following code on Xcode:

enum E {
    case a
    case b
    case c
}

struct S {
    let e: E = .a
}

var s = S()
s.e = .

Expected results:

Only a, b, and c are displayed.

Actual result:

NachoSoto commented 7 years ago

This is not a regression btw, I've seen this for as long as I can remember, I just never bothered to file it...

NachoSoto commented 7 years ago

This seems fixed in Swift 4.0. Given that this bug wasn't screened though I wonder if there are regression tests for this though?

slavapestov commented 7 years ago

@nkcsgexi Can you check if there's a regression test and add one if there isn't?

NachoSoto commented 7 years ago

This is broken again

nkcsgexi commented 7 years ago

@slavapestov We do have test on this case: https://github.com/apple/swift/blob/master/test/IDE/complete_enum_elements.swift

Could you attach the source file for reproducing? I cannot reproduce locally with a toy example.

AnthonyLatsis commented 4 years ago

@NachoSoto Can you verify whether the issue is still present in the latest Xcode release? We do indeed have quite some test cases for this in the file mentioned by Xi