Issue with Swift 2.2 generics (Xcode 7.3)

Viewed 814

I've got a frustrating situation with Swift 2.2 (Xcode 7.3). To simulate it, just create a variable in a user defined, generic class, and reference that class from someplace else. For example:

class A<T> {
    let genVar = 1
}

class MyViewController: UIViewController {
    let myVar = A<Int>() // crash is here
}

If you will run this code on a device running iOS 7 (iPhone 4, in my case), it will crash on the attempt of creating a variable of generic type. Here are the first lines of the device crash log:

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Subtype: KERN_PROTECTION_FAILURE at 0x00298910
Triggered by Thread:  0

Thread 0 Crashed:
0   libswiftCore.dylib              0x006b1d64 0x4bd000 + 2051428
1   Phone                           0x001c76ec 0xab000 + 1165036
2   libswiftCore.dylib              0x006b307c 0x4bd000 + 2056316
3   libswiftCore.dylib              0x006b2f70 0x4bd000 + 2056048
4   libswiftCore.dylib              0x006b0f24 0x4bd000 + 2047780
5   libswiftCore.dylib              0x006b107c 0x4bd000 + 2048124
6   Phone                           0x0014e730 0xab000 + 669488
7   Phone                           0x00129390 0xab000 + 517008
8   UIKit                           0x31e9d9c4 -[UIClassSwapper initWithCoder:] + 188

On iOS 8 and 9 simulators/devices, the code above works okay.

Is Swift support for iOS 7 going to be dropped in the near future?

4 Answers
Related