Open
Description
Describe the bug
swift gives a compile error about incompatible array types whereas the type should be inferred from the context.
Steps To Reproduce
Try to compile this:
extension Array where Element == Int {
static let foo: [String] = Array(["foo"])
}
It complains with Cannot assign value of type 'Array<Int>' to type '[String]'
It compiles fine when adding an explicit type:
extension Array where Element == Int {
static let foo: [String] = Array<String>(["foo"])
}
Expected behavior
It compiles fine without an error. The type [String] should be inferred but instead the compiler thinks we're talking about [Int] since we're in an extension of [Int].
Environment (please fill out the following information)
- OS: macOS 12.6
- Xcode 14.1
- swift: swift-driver version: 1.62.15 Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)