[英]Swift compiler crashes on associatedtype in @objc protocol
此代碼示例破壞了 Swift 編譯器:
import Foundation
@objc protocol Some {
associatedtype W
}
extension Some {
func takeW(w: W) -> Void {
}
}
輸出:
0 swift 0x0000000104f583ad PrintStackTraceSignalHandler(void*) + 45
1 swift 0x0000000104f57b56 SignalHandler(int) + 790
2 libsystem_platform.dylib 0x00007fffe7eadbba _sigtramp + 26
3 libsystem_malloc.dylib 0x00007fffe7e21258 malloc + 24
4 swift 0x0000000101f8cd32 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
...
While emitting IR SIL function @_TFE4mainPS_4Some5takeWfT1wwx1W_T_ for 'takeW' at main.swift:11:5
混合@objc
和associatedtype
類型本質上是錯誤的,還是簡單的編譯器錯誤?
swiftc --version
Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9
關聯類型是 Swift 獨有的特性,對 Objective-C 不可見,所以應該有編譯器錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.