Cet exemple de code rompt le compilateur Swift:
import Foundation
@objc protocol Some {
associatedtype W
}
extension Some {
func takeW(w: W) -> Void {
}
}
Sortie:
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
Est en train de se mélanger @objc
et associatedtype
est fondamentalement faux, ou s'agit-il d'un simple bogue du compilateur?
swiftc --version
Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9
Réponses:
2 pour la réponse № 1Les types associés sont des fonctionnalités Swift uniquement, non visibles pour Objective-C, il devrait donc y avoir une erreur du compilateur.
A déposé un bug https://bugs.swift.org/browse/SR-3850