Created
June 23, 2016 18:35
-
-
Save rileytestut/3f6a1384798a2984260c2e088fe84a06 to your computer and use it in GitHub Desktop.
Type Inference Crash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
// If defined here in the same module, no issue | |
// However, if defined in a separate module + used, will cause compiler crash | |
// public typealias GenericResult<T> = Result<T, NSError> | |
func testFunction<T>(withCompletion completion: (Result<T, NSError>) -> Void) | |
{ | |
// Do Stuff | |
} | |
// This works | |
testFunction { (result: Result<Data, NSError>) in } | |
// This crashes the compiler if GenericResult<T> is defined in another module :( | |
testFunction { (result: GenericResult<Data>) in } | |
print("Hello World") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOTE: This must be compiled in a separate module for the crash to manifest | |
import Foundation | |
public enum Result<T, U: ErrorProtocol> | |
{ | |
case success(T) | |
case failure(U) | |
} | |
public typealias GenericResult<T> = Result<T, NSError> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment