Swift Swift 3 / Xcode 8 端口后的编译器分段错误

Swift compiler segmentation fault after Swift 3 / Xcode 8 port

我已经在 SO 中检查了多个答案,但似乎没有适合我的解决方案。编译我的 iOS (≥9.3) 应用程序时,出现以下编译器错误,因为我将我的项目转换为 Swift 3 / Xcode 8.

我尝试清理、删除 DerivedData、重建 Carthage 框架等 - 但没有任何效果 -

也许以前有过这种经历的人可以立即发现问题所在。

控制台输出/堆栈跟踪:

0  swift                    0x000000010bc8cb6d PrintStackTraceSignalHandler(void*) + 45
1  swift                    0x000000010bc8c5b6 SignalHandler(int) + 470
2  libsystem_platform.dylib 0x00007fffd300dbba _sigtramp + 26
3  libsystem_platform.dylib 000000000000000000 _sigtramp + 754918496
4  swift                    0x00000001090c98d2 llvm::Value* llvm::function_ref<llvm::Value* (unsigned int)>::callback_fn<swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*)::$_0>(long, unsigned int) + 530
5  swift                    0x00000001091a7600 swift::irgen::emitImpliedWitnessTableRef(swift::irgen::IRGenFunction&, llvm::ArrayRef<swift::irgen::ProtocolEntry>, swift::ProtocolDecl*, llvm::function_ref<llvm::Value* (unsigned int)> const&) + 240
6  swift                    0x00000001090c96a7 swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*) + 247
7  swift                    0x00000001091a39cd swift::SILWitnessVisitor<(anonymous namespace)::WitnessTableBuilder>::visitProtocolDecl(swift::ProtocolDecl*) + 5997
8  swift                    0x00000001091a14d7 swift::irgen::IRGenModule::emitSILWitnessTable(swift::SILWitnessTable*) + 503
9  swift                    0x00000001091138ed swift::irgen::IRGenerator::emitGlobalTopLevel() + 2077
10 swift                    0x00000001091d4fcb performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1259
11 swift                    0x00000001090a31c7 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 23687
12 swift                    0x000000010909b265 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17029
13 swift                    0x000000010905882d main + 8685
14 libdyld.dylib            0x00007fffd2e01255 start + 1
15 libdyld.dylib            0x0000000000000067 start + 757067283

有问题的文件/class如下:

class JSONDataProvider<Input, Output, APIInformation>: DataProvider
    where APIInformation: APIAccessInformation, APIInformation.Input == Input,
    Output: JSONDataType, Input: Equatable, Input:     SignificanceComparable
{
    static var updateCallbacksWithoutInputChange: Bool { return false }

    // MARK: - Protocol Variables
    var callbackId: Int = 0
    var callbacks: [Int : (Result<(Output, Input)>) -> ()]

    var inputCache: Input?
    var outputCache: Result<(Output, Input)>?

    // MARK: - Private Properties
    fileprivate let apiInformation: APIInformation
    fileprivate let requestHandler: URLRequestHandler

    // MARK: - Init
    init(apiInformation: APIInformation, requestHandler: URLRequestHandler)
    {
        self.apiInformation = apiInformation
        self.requestHandler = requestHandler
        self.callbacks = [:]
    }
}

对于上下文:(省略扩展名)

protocol DataProvider
{
    associatedtype Input: Equatable, SignificanceComparable
    associatedtype Output

    static var updateCallbacksWithoutInputChange: Bool { get }

    var inputCache: Input? { get set }
    var outputCache: Result<(Output, Input)>? { get set }

    var callbackId: Int { get set }
    var callbacks: [Int : (Result<(Output, Input)>) -> Void] { get set }

    func fetchData(from input: Input)

    mutating func registerCallback(_ callback: @escaping (Result<(Output, Input)>) -> Void) -> Int
    mutating func unregisterCallback(with id: Int)
}

和:

protocol APIAccessInformation
{
    associatedtype Input: Equatable, SignificanceComparable

    var requestMethod: Alamofire.HTTPMethod { get }
    var baseURL: String { get }

    func apiParameters(for input: Input) -> [String : Any]
}

有什么想法吗?谢谢!

原来泛型是问题所在。由于似乎没有人确切地知道为什么,我已经调整了我的架构,所以我不需要这个泛型。

我把这个问题留在这里,以防其他人 运行 遇到类似问题,或者知道确切原因和解决方法的人找到这个帖子。