Skip to content

Instantly share code, notes, and snippets.

@valfer
Created October 14, 2014 09:03
Show Gist options
  • Save valfer/6b6066b90a78eab04d4f to your computer and use it in GitHub Desktop.
Save valfer/6b6066b90a78eab04d4f to your computer and use it in GitHub Desktop.
This class causes a compiler crash with signal 11, tested with XCode 6.0.1 (6A317) and XCode 6.1 (6A1046a)
//
// CrashCompilerClass.swift
// CompilerCrash
//
// Created by Valerio Ferrucci on 14/10/14.
// Copyright (c) 2014 Valerio Ferrucci. All rights reserved.
//
import Foundation
typealias MyObject = AnyObject
typealias MyObjectArray = [MyObject]
protocol MyObjectDecodable {
class func decode(obj: MyObject) -> Self?
}
func apply <A,B>(a : A?, f : A->B?) -> B? {
if let _a = a {
return f(_a)
} else {
return .None
}
}
class CrashCompilerClass<A:MyObjectDecodable> {
var callback : (A->())? = nil
func loopOnArray(objArray: MyObjectArray?) -> NSError? {
var error : NSError?
if let _objArray = objArray {
for obj in _objArray {
let obj1 = obj as? A
let obj2 = apply(obj,A.decode)
if let _obj2 = obj2 {
self.callback!(_obj2)
}
}
}
return error
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment