mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
subscript is on the destination side of an assignment and restricting matching overload candidates to only the set-able members. Also, if we are left with a single candidate, we can recheck unresolved index expressions with better parameter info.
27 lines
660 B
Swift
27 lines
660 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
enum Key: Int {
|
|
case aKey
|
|
case anotherKey // expected-note {{did you mean 'anotherKey'?}}
|
|
}
|
|
|
|
class sr6175 {
|
|
var dict: [Key: String] = [:]
|
|
func what() -> Void {
|
|
dict[.notAKey] = "something" // expected-error {{type 'Key' has no member 'notAKey'}}
|
|
}
|
|
|
|
subscript(i: Int) -> Int {
|
|
return i*i
|
|
}
|
|
subscript(j: Double) -> Double {
|
|
get { return j*j }
|
|
set {}
|
|
}
|
|
}
|
|
|
|
let s = sr6175()
|
|
let one: Int = 1
|
|
// Should choose the settable subscript to find a problem with, not the get-only subscript
|
|
s[one] = 2.5 // expected-error {{cannot convert value of type 'Int' to expected argument type 'Double'}}
|