Skip to content
Open
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
29 changes: 20 additions & 9 deletions test/SIL/manual_ownership.swift
Original file line number Diff line number Diff line change
Expand Up @@ -423,13 +423,24 @@ extension FixedWidthInteger {
}
}

struct CollectionOf32BitLittleEndianIntegers<BaseCollection: Collection> where BaseCollection.Element == UInt8 {
var baseCollection: BaseCollection

init(_ baseCollection: BaseCollection) {
precondition(baseCollection.count % 4 == 0)
self.baseCollection = baseCollection // expected-warning {{accessing 'baseCollection' may produce a copy}}
} // expected-warning {{accessing 'self' may produce a copy}}
// FIXME(rdar://164852821): Some of the diagnostic message tailoring for assignments
// are unstable when targeting platforms like the simulator, since we seem to emit
// slightly different SIL which then throws off the heuristics. For example,
//
// <snip>/swift/test/SIL/manual_ownership.swift:431:68: error: incorrect message found
// self.baseCollection = baseCollection
// // x-warning@-1 {{accessing 'baseCollection' may produce a copy}}
// ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// closure capture of 'baseCollection' requires independent copy of it; write [baseCollection = copy baseCollection] in the closure's capture list to acknowledge
//

// FIXME: the above initializer shouldn't have any diagnostics
}
// struct CollectionOf32BitLittleEndianIntegers<BaseCollection: Collection> where BaseCollection.Element == UInt8 {
// var baseCollection: BaseCollection
//
// init(_ baseCollection: BaseCollection) {
// precondition(baseCollection.count % 4 == 0)
// self.baseCollection = baseCollection // x-warning {{accessing 'baseCollection' may produce a copy}}
// } // x-warning {{accessing 'self' may produce a copy}}
//
// // FIXME: the above initializer shouldn't have any diagnostics
// }