Skip to content

Fix warning: overlapping access to 'self' #1337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Foundation/NSCalendar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,9 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding {
var at: CFAbsoluteTime = date.timeIntervalSinceReferenceDate

let res: Bool = withUnsafeMutablePointer(to: &at) { t in
let count = Int32(vector.count)
return vector.withUnsafeMutableBufferPointer { (vectorBuffer: inout UnsafeMutableBufferPointer<Int32>) in
return _CFCalendarAddComponentsV(_cfObject, t, CFOptionFlags(opts.rawValue), compDesc, vectorBuffer.baseAddress!, Int32(vector.count))
return _CFCalendarAddComponentsV(_cfObject, t, CFOptionFlags(opts.rawValue), compDesc, vectorBuffer.baseAddress!, count)
}
}

Expand All @@ -603,8 +604,9 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding {
return intArrayBuffer.baseAddress!.advanced(by: idx)
}

let count = Int32(vector.count)
return vector.withUnsafeMutableBufferPointer { (vecBuffer: inout UnsafeMutableBufferPointer<UnsafeMutablePointer<Int32>>) in
return _CFCalendarGetComponentDifferenceV(_cfObject, startingDate.timeIntervalSinceReferenceDate, resultDate.timeIntervalSinceReferenceDate, CFOptionFlags(opts.rawValue), compDesc, vecBuffer.baseAddress!, Int32(vector.count))
return _CFCalendarGetComponentDifferenceV(_cfObject, startingDate.timeIntervalSinceReferenceDate, resultDate.timeIntervalSinceReferenceDate, CFOptionFlags(opts.rawValue), compDesc, vecBuffer.baseAddress!, count)
}
}
if res {
Expand Down
8 changes: 4 additions & 4 deletions TestFoundation/TestNSData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -930,11 +930,11 @@ extension TestNSData {
// Mutate it
bytes.pointee = 0x67
XCTAssertEqual(bytes.pointee, 0x67, "First byte should be 0x67")
XCTAssertEqual(mutatingHello[0], 0x67, "First byte accessed via other method should still be 0x67")

// Verify that the first data is still correct
XCTAssertEqual(hello[0], 0x68, "The first byte should still be 0x68")
}
XCTAssertEqual(mutatingHello[0], 0x67, "First byte accessed via other method should still be 0x67")

// Verify that the first data is still correct
XCTAssertEqual(hello[0], 0x68, "The first byte should still be 0x68")
}


Expand Down