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

Unknown parameter UInt8 in '_specialize attribute': Xcode 9

这段用于从位数组构建位模式的代码在 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
}

错误

Unknown parameter UInt8 in '_specialize attribute'

关于这个的leads/suggestion吗?

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

@_specialize(where T == UInt8)