Этот код не выполняется:
protocol A {
associatedtype E : Decodable
func u()
}
extension A {
func u() {}
}
class E<T : Decodable> : A {
typealias E = T
}
С ошибкой:
1. While emitting IR SIL function "@$s12sddssddsdsds1ECyqd__GAA1AA2aEP1uyyFTW".
for 'u()' (at /Users/semyontykhonenko/Library/Autosave Information/sddssddsdsds/sddssddsdsds/ViewController.swift:108:5)
0 swift 0x0000000106dc0eb3 PrintStackTraceSignalHandler(void*) + 51
1 swift 0x0000000106dc0686 SignalHandler(int) + 358
2 libsystem_platform.dylib 0x00007fff67514b5d _sigtramp + 29
3 libsystem_platform.dylib 000000000000000000 _sigtramp + 2561586368
4 swift 0x0000000102a855b1 swift::irgen::FulfillmentMap::searchWitnessTable(swift::irgen::IRGenModule&, swift::CanType, swift::ProtocolDecl*, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&, llvm::SmallPtrSetImpl<swift::ProtocolDecl*>*) + 65
5 swift 0x0000000102a85522 swift::irgen::FulfillmentMap::searchWitnessTable(swift::irgen::IRGenModule&, swift::CanType, swift::ProtocolDecl*, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&) + 450
6 swift 0x0000000102a85328 void llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>::callback_fn<swift::irgen::FulfillmentMap::searchNominalTypeMetadata(swift::irgen::IRGenModule&, swift::CanType, swift::MetadataState, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&)::$_1>(long, unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>) + 1656
7 swift 0x0000000102be644f swift::irgen::GenericTypeRequirements::enumerateFulfillments(swift::irgen::IRGenModule&, swift::SubstitutionMap, llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>) + 335
8 swift 0x0000000102a844ee swift::irgen::FulfillmentMap::searchNominalTypeMetadata(swift::irgen::IRGenModule&, swift::CanType, swift::MetadataState, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&) + 478
9 swift 0x0000000102a842d0 swift::irgen::FulfillmentMap::searchTypeMetadata(swift::irgen::IRGenModule&, swift::CanType, swift::irgen::IsExact_t, swift::MetadataState, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&) + 912
10 swift 0x0000000102c9738d swift::irgen::IRGenFunction::bindLocalTypeDataFromTypeMetadata(swift::CanType, swift::irgen::IsExact_t, llvm::Value*, swift::MetadataState) + 317
11 swift 0x0000000102be43a4 swift::irgen::emitPolymorphicParameters(swift::irgen::IRGenFunction&, swift::SILFunction&, swift::irgen::Explosion&, swift::irgen::WitnessMetadata*, llvm::function_ref<llvm::Value* (unsigned int)> const&) + 596
12 swift 0x0000000102c4e355 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 6325
13 swift 0x0000000102afe517 swift::irgen::IRGenerator::emitLazyDefinitions() + 9303
14 swift 0x0000000102c2bf20 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**) + 1344
15 swift 0x0000000102a185aa performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 36682
16 swift 0x0000000102a0be54 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6820
17 swift 0x00000001029993c3 main + 1219
18 libdyld.dylib 0x00007fff6732f3d5 start + 1
19 libdyld.dylib 0x0000000000000049 start + 2563574901
error: Segmentation fault: 11 (in target 'sddssddsdsds' from project 'sddssddsdsds')
Если я удаляю Decodable из требования протокола или добавляю реализацию u
к Eон успешно компилируется. Итак, эти варианты успешно скомпилированы:
protocol A {
associatedtype E
func u()
}
extension A {
func u() {}
}
class E<T> : A {
typealias E = T
}
А вот этот:
protocol A {
associatedtype E : Decodable
func u()
}
extension A {
func u() {}
}
class E<T : Decodable> : A {
typealias E = T
func u() {}
}
Версия XCode, которую я использую: Версия 11.1 (11A1027) Я пробовал Swift 5 и Swift 4.2. Это терпит неудачу с обоими