[SR-3840] Closure picks up static type not dynamic #46425
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
type checker
Area → compiler: Semantic analysis
Attachment: Download
Environment
MacOS 10.12.3
Additional Detail from JIRA
md5: 22af35df83a7d03ffb5d5b5d0205cdc0
Issue Description:
Hi,
I am seeing a problem were a closure that reads and writes to a computed parameter picks up the static type and not the dynamic type. Whereas a closure that just reads correctly picks up the dynamic type. In:
The above fails when `er` is called because `er` calls `MutableReference.value.get` not `DefaultMutableReference.value.get`, which you would expect since `dm` is a `DefaultMutableReference`.
Note:
if `er` changed to: `let er: (DefaultMutableReference<[Int]>, Int) -> Void = { $0.value.append($1) }` then no problem
`ok` works fine. This is interesting because `er` fails on the read part but `ok` does the same read and it doesn't fail.
The text was updated successfully, but these errors were encountered: