'_specialize属性'中的未知参数UInt8:Xcode 9

Sah*_*oor 5 xcode9-beta swift3.2

用于从位数组构建位模式的代码在Xcode 9中给出了错误(在8.3.3中工作)

@_specialize(UInt8)
func integerFrom<T: UnsignedInteger>(_ bits: Array<Bit>) -> T {
    var bitPattern: T = 0
    for idx in bits.indices {
        if bits[idx] == Bit.one {
            let bit = T(UIntMax(1) << UIntMax(idx))
            bitPattern = bitPattern | bit
        }
    }
    return bitPattern
}
Run Code Online (Sandbox Code Playgroud)

错误

'_specialize属性'中的未知参数UInt8

对此有任何线索/建议吗?

Fra*_*tin 10

您只需要在specialize定义中包含where子句,就像这样

@_specialize(where T == UInt8)
Run Code Online (Sandbox Code Playgroud)