IDE: Fire
Version: 8.4.96.2041
Target (If relevant): Java
Description:
Collections.addAll()
will not be able to correctly infer the generic type and thus compilation will fail.
When the signature is clearly stating:
public static func addAll<T>(_ c: Collection<T>!, _ a: T![]) -> Boolean
the following code will result in compiler complaining with:
error E486: Parameter 2 is "SByteStaticArray", should be "Byte!", in call to static Collections!.addAll<T>(_ c: Collection<? super T>!, _ a: T[]!) -> Boolean
He seems to be expecting non-array type, while the array type is stated in the definition.
Reference code:
typealias SByteStaticArray = SByte[]
public typealias Data = java.nio.ByteBuffer
extension Data {
#if COOPER
public var plainBytes: SByteStaticArray {
//apple swift doesn't allow Type[] syntax
var bytes: SByteStaticArray
if self.hasArray() {
bytes = self.array()
} else {
bytes = java.lang.reflect.Array.newInstance(SByte.Type, self.remaining()) as! SByteStaticArray
self.`get`(bytes as! SByteStaticArray)
}
return bytes as! SByteStaticArray
}
#endif
public var bytes: [Int8] {
#if COOPER
/*
let targetArrayList = ArrayList<SByte>()
for index in 0 ..< self.plainBytes.length {
targetArrayList.add(self.plainBytes[index])
}
return [Int8](targetArrayList)
*/
let targetArrayList = ArrayList<SByte>()
Collections.addAll(targetArrayList, self.plainBytes)
return [Int8](targetArrayList)
#else
return self.withUnsafeBytes {
[Int8](UnsafeBufferPointer(start: $0, count: self.count))
}
#endif
}
}