blob: 6c43ed4a6d4f33c0afbb394597aac402e0d3472d [file] [log] [blame]
// RUN: %target-swift-frontend %s -emit-ir
enum SampleType: UInt8 {
case Value = 1
case Array
case Dictionary
}
protocol ByteConvertible {
init?(bytes: [UInt8], startOffset: Int)
func rawBytes() -> [UInt8]
func bytesNeeded() -> Int
}
protocol TypeRequestable {
static func containerType() -> SampleType
}
struct Sample<T, C> where T: ByteConvertible, C: TypeRequestable {
let numberOfRecords: UInt32
let sizeInBytes: UInt64
var records: [T] = [] // problem line
init(records: [T]) {
numberOfRecords = 0
sizeInBytes = 0
self.records.reserveCapacity(records.count)
self.records += records
}
}
extension Sample: ByteConvertible {
init?(bytes: [UInt8], startOffset: Int = 0) {
numberOfRecords = 0
sizeInBytes = 0
records = []
}
func rawBytes() -> [UInt8] {
return []
}
func bytesNeeded() -> Int {
return 0
}
}