You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
purpleblues opened this issue
Apr 6, 2018
· 7 comments
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfcrashBug: A crash, i.e., an abnormal termination of software
When the protocol used with conditional conformance for the placeholder type of generic class (T in this case) is marked @objc, the code causes Segmentation fault: 11 with error message containing call stack like below.
0 swift 0x000000010d0deffa PrintStackTraceSignalHandler(void*) + 42
1 swift 0x000000010d0de3b6 SignalHandler(int) + 966
2 libsystem_platform.dylib 0x00007fff513a1f5a _sigtramp + 26
3 libsystem_platform.dylib 0x00007fa4e556fda5 _sigtramp + 2484919909
4 swift 0x0000000109cb7016 clang::CodeGen::ConstantAggregateBuilderBase::finishStruct(llvm::StructType*) + 150
5 swift 0x00000001097e04e5 llvm::Constant* (anonymous namespace)::ClassDataBuilder::buildGlobalVariable<swift::irgen::ConstantStructBuilder>(swift::irgen::ConstantStructBuilder&, llvm::StringRef) + 597
6 swift 0x00000001097e4942 swift::irgen::emitCategoryData(swift::irgen::IRGenModule&, swift::ExtensionDecl*) + 2418
7 swift 0x00000001097eb3e7 swift::irgen::IRGenModule::emitGlobalDecl(swift::Decl*) + 887
8 swift 0x00000001097eaf95 swift::irgen::IRGenModule::emitSourceFile(swift::SourceFile&, unsigned int) + 133
9 swift 0x00000001098e353e performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**, unsigned int) + 1422
10 swift 0x000000010973edce performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 38110
11 swift 0x0000000109733e64 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7908
12 swift 0x00000001096e88b5 main + 18917
13 libdyld.dylib 0x00007fff51093015 start + 1
The issue disappears when @objc is removed from the protocol
The text was updated successfully, but these errors were encountered:
Assertion failed: (metadata && "extended objc class doesn't have constant metadata?"), function emitCategory, file /Volumes/Data/swift-public/swift/lib/IRGen/GenClass.cpp, line 1322.
I don't think conditional conformances to @objc protocols should be accepted, but even dropping that part causes the assertion failure for me. I'll clone out a separate bug for that.
By "dropping that part", I think @belkadan means removing the where T: BarProtocol since just extension FooClass: BarProtocol triggers the same assertion. @jckarter, thoughts?
I think that's a dup of another issue, where we haven't really implemented adding ObjC methods or protocol extensions for generic classes, since there's no single class object to generate a "category" for.
Ah, thanks! I think I found it. It does appear to be resolved if the (non-conditional) conformance is moved to the type declaration instead of the extension.
Actually, I changed my mind: the example in that issue gives a diagnostic "@objc is not supported within extensions of generic classes or classes that inherit from generic classes", but that's only because the protocol defines a requirement. We should have an error for this case too.
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfcrashBug: A crash, i.e., an abnormal termination of software
Environment
Xcode 9.3(9E145), Swift 4.1
Additional Detail from JIRA
md5: f39162a34c6102d121b7a4579f00b4fb
cloned to:
is duplicated by:
Issue Description:
When the protocol used with conditional conformance for the placeholder type of generic class (T in this case) is marked @objc, the code causes Segmentation fault: 11 with error message containing call stack like below.
The issue disappears when @objc is removed from the protocol
The text was updated successfully, but these errors were encountered: