swiftlang/swift

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

オープン

#56,435 opened on 2021/01/13

 (8 件のコメント) (0 件のリアクション) (0 人の担当者)Swift (10,719 件のフォーク)batch import
compilergood first issueimprovementtype checker

Repository metrics

Stars
 (69,989 個のスター)
PR merge metrics
 (PR metrics pending)

説明

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.

コントリビューターガイド