swiftlang/swift

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

Aberta

#56.435 aberto em 13 de jan. de 2021

 (8 comentários) (0 reação) (0 responsável)Swift (10.719 forks)batch import
compilergood first issueimprovementtype checker

Métricas do repositório

Stars
 (69.989 estrelas)
Métricas de merge de PR
 (Métricas PR pendentes)

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.

Guia do colaborador