I'm writing some Swift code where I have an array containing a generic type:
let _data: Array<T> = T[]()
Later in my code I need to determine the type stored in the array. I tried using the type casting technique described in the documentation (although it was not used for generics).
switch self._data {
case let doubleData as Array<Double>:
// Do something with doubleData
case let floatData as Array<Float>:
// Do something with floatData
default:
return nil // If the data type is unknown return nil
}
The above switch statement results in the following error upon compilation:
- While emitting IR SIL function @_TFC19Adder_Example___Mac6Matrix9transposeUS_7Element__fGS0_Q__FT_GSqGS0_Q___ for 'transpose' at /code.viperscience/Adder/src/Adder Library/Matrix.swift:45:3 :0: error: unable to execute command: Segmentation fault: 11 :0: error: swift frontend command failed due to signal (use -v to see invocation) Command /Applications/Xcode6-Beta2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 254
Anybody know how I can cast my generic data to its actual type in order to take specific action?
as?
but I think in your case its a compiler bug...report it! – Claudy