This code sample breaks Swift compiler:
import Foundation
@objc protocol Some {
associatedtype W
}
extension Some {
func takeW(w: W) -> Void {
}
}
Output:
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
Is mixing @objc
and associatedtype
is inherently wrong, or is it plain compiler bug?
swiftc --version
Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9
Associated types are Swift-only feature, not visible to Objective-C, so there should be compiler error.
Filed a bug https://bugs.swift.org/browse/SR-3850
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.