4

Maybe I'm going crazy here, but extension Array where Element == String in Swift 4.1.2 is exposing its properties in Swift's autocomplete on types when it should not be there.

For example, this extension:

extension Array where Element == String {
    public var test: [String] {
        return ["test"]
    }
}

Then start typing:

[123].te ...

and Swift suggests that the test property is also available on [Int] which is impossible. Then the syntax checker pops up the error:

Type of expression is ambiguous without more context

Is there something I'm missing? Perhaps some other/additional conformance restrictions that need to be used? Or is this a Swift bug?

enter image description here

stef
  • 952
  • 10
  • 15

1 Answers1

2

It appears to be a bug.

This Swift.org bug report demonstrates the same behavior:

https://bugs.swift.org/browse/SR-5388

stef
  • 952
  • 10
  • 15