swiftlang/swift
View on GitHub[SR-14044] Contextual Usage of UnsafeMutablePointer<Void> In API is Mis-Diagnosed
Open
#56,435 opened on Jan 13, 2021
compilergood first issueimprovementtype checker
Repository metrics
- Stars
- (69,989 stars)
- PR merge metrics
- (Avg merge 8d 17h) (510 merged PRs in 30d)
Description
| Previous ID | SR-14044 |
| Radar | rdar://43580528 |
| Original Reporter | @CodaFi |
| Type | Improvement |
| Votes | 0 |
| Component/s | Compiler |
| Labels | Improvement, StarterBug, TypeChecker |
| Assignee | None |
| Priority | Medium |
md5: 29439788662577468de9cf1437c1e59a
Issue Description:
import Foundation
var data = Data(count:0)
try data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<Void>) throws -> Void in
}
There is a warning here because TypeCheckType only knows how to unconditionally warn about UnsafeMutablePointer<Void>. It needs to be taught that this contextual usage is okay - because the alternative is the compiler emitting a fixit that introduces a contextual mismatch by rewriting the parameter type to UnsafeMutableRawPointer.