mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Remove "illegal" UnsafePointer casts from the stdlib.
Update for SE-0107: UnsafeRawPointer This adds a "mutating" initialize to UnsafePointer to make Immutable -> Mutable conversions explicit. These are quick fixes to stdlib, overlays, and test cases that are necessary in order to remove arbitrary UnsafePointer conversions. Many cases can be expressed better up by reworking the surrounding code, but we first need a working starting point.
This commit is contained in:
@@ -387,12 +387,10 @@ extension String {
|
||||
outputArray in
|
||||
// FIXME: completePath(...) is incorrectly annotated as requiring
|
||||
// non-optional output parameters. rdar://problem/25494184
|
||||
let outputNonOptionalName = AutoreleasingUnsafeMutablePointer<NSString?>(
|
||||
UnsafeMutablePointer<NSString>(outputName)
|
||||
)
|
||||
let outputNonOptionalArray = AutoreleasingUnsafeMutablePointer<NSArray?>(
|
||||
UnsafeMutablePointer<NSArray>(outputArray)
|
||||
)
|
||||
let outputNonOptionalName = unsafeBitCast(
|
||||
outputName, to: AutoreleasingUnsafeMutablePointer<NSString?>.self)
|
||||
let outputNonOptionalArray = unsafeBitCast(
|
||||
outputArray, to: AutoreleasingUnsafeMutablePointer<NSArray?>.self)
|
||||
return self._ns.completePath(
|
||||
into: outputNonOptionalName,
|
||||
caseSensitive: caseSensitive,
|
||||
@@ -505,7 +503,7 @@ extension String {
|
||||
var stop_ = false
|
||||
body(line: line, stop: &stop_)
|
||||
if stop_ {
|
||||
UnsafeMutablePointer<ObjCBool>(stop).pointee = true
|
||||
stop.pointee = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -541,7 +539,7 @@ extension String {
|
||||
var stop_ = false
|
||||
body($0, self._range($1), self._range($2), &stop_)
|
||||
if stop_ {
|
||||
UnsafeMutablePointer($3).pointee = true
|
||||
$3.pointee = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -823,7 +821,7 @@ extension String {
|
||||
freeWhenDone flag: Bool
|
||||
) {
|
||||
self = NSString(
|
||||
charactersNoCopy: UnsafeMutablePointer(utf16CodeUnitsNoCopy),
|
||||
charactersNoCopy: UnsafeMutablePointer(mutating: utf16CodeUnitsNoCopy),
|
||||
length: count,
|
||||
freeWhenDone: flag) as String
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user