Files
swift-mirror/test/Constraints/anyhashable-collection-cast.swift
John McCall 4f4d64b93e Various improvements to the variable-is-never-mutated diagnostic.
The main fixes here are:
- we weren't looking through open-existentials in the l-value
- we weren't handling mutating gets correctly unless CSApply wrapped
  the base in an InOutExpr, which seems to be multifile-sensitive
- we were missing diagnostics in some cases involving subscripts

A better fix would be to re-introduce LValueAccessKind, but I wanted
a workable short-term fix that I could try to get into 5.1.

Fixes rdar://49482742, which is specific to the lazy-getter problem.
2019-04-08 18:43:24 -04:00

24 lines
419 B
Swift

// RUN: %target-typecheck-verify-swift
func dict() -> [AnyHashable: Any] {
return ["x": "y"]
}
func set() -> Set<AnyHashable> {
return ["x"]
}
func test() {
if let d = dict() as? [String: String] {
print(d)
}
if let s = set() as? Set<String> {
print(s)
}
}
func testLValueCoerce() {
var lvalue = "lvalue"
let map: [AnyHashable : Any] = [lvalue: lvalue]
lvalue = map[lvalue] as! String
}