swiftlang/swift

[SR-14044] Contextual Usage of UnsafeMutablePointer<Void> In API is Mis-Diagnosed

Open

#56.435 aperta il 13 gen 2021

Vedi su GitHub
 (8 commenti) (0 reazioni) (0 assegnatari)Swift (10.719 fork)batch import
compilergood first issueimprovementtype checker

Metriche repository

Star
 (69.989 star)
Metriche merge PR
 (Merge medio 8g 17h) (510 PR mergiate in 30 g)

Descrizione

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.

Guida contributor