Swift 编译器 2.1.1 永远挂在字典上

Swift compiler 2.1.1 hang forever on dictionary

我正在为 sqlite library 构建 class,突然编译器永远挂起。

终于拿到了一个测试用例,发现是跟一个字典解析有关。这是最少的代码:

导入基金会 导入 GRDB

class DeudaCliente : Record {
    var id: Int64
    var codigo: String
    var nombre: String
    var cobro: String
    var direccion: String
    var telefono: String
    var orden: Int32
    var calificacion: String
    var fechaIngreso: NSDate
    var fecha: NSDate
    var capital: NSDecimalNumber
    var interes: NSDecimalNumber
    var cuota: NSDecimalNumber
    var valor: NSDecimalNumber
    var valorPagar: NSDecimalNumber
    var saldo: NSDecimalNumber
    var atrasados: Int32


    /// Initialize from a database row
    required init(_ row: Row) {
        id = row.value(named: "id")
        codigo = row.value(named: "codigo")
        nombre = row.value(named: "nombre")
        cobro = row.value(named: "cobro")
        direccion = row.value(named: "direccion")
        telefono = row.value(named: "telefono")
        orden = row.value(named: "orden")
        calificacion = row.value(named: "calificacion")
        fechaIngreso = row.value(named: "fechaIngreso")
        fecha = row.value(named: "fecha")
        interes = row.value(named: "interes")
        cuota = row.value(named: "cuota")
        valor = row.value(named: "valor")
        valorPagar = row.value(named: "valorPagar")
        saldo = row.value(named: "saldo")
        capital = row.value(named: "capital")
        atrasados = row.value(named: "atrasados")

        super.init(row)
    }

    /// The values persisted in the database
    override var persistentDictionary: [String: DatabaseValueConvertible?]
    {
        return  [
            "id": id,
            "nombre": nombre,
            "codigo": codigo,
            "cobro": cobro,
            "direccion": direccion,
            "telefono": telefono,
            "orden": orden,
            "calificacion": calificacion,
            "fechaIngreso": fechaIngreso,
            "fecha": fecha, //THE COMPILER SLOWDOWN HERE
            "interes": interes,
            "cuota": cuota, //THE COMPILER HANG HERE
            "valor": valor,
            "valorPagar": valorPagar,
            "saldo": saldo,
            "capital": capital,
            "atrasados": atrasados
        ]
    }
}

奇怪的是,我更改了标量 "fecha" 之后的值,例如 1、"a" 等编译器工作。

此外:在 "cuota" 和服务 SourceKitService 开始报告 +300% CPU 之后,索引也将永远占用,增加内存(我有数最多 6GB)

这在 El capitan 上,xcode 版本 7.2.1 (7C1002)

我是 GRDB 的作者。阅读我在 https://github.com/groue/GRDB.swift/issues/21

上的回答

我猜字典对于 Swift 编译器来说太长了。你可以尝试破坏它,或者像这样在键之后构建它:

var dic: [String: DatabaseValueConvertible?] = [:]
dic["id"] = id
dic["nombre"] = nombre
// etc.
return dic