Details
-
Type:
Bug
-
Status: Resolved
-
Priority:
Medium
-
Resolution: Done
-
Component/s: Compiler
-
Labels:
-
Environment:
macOS 10.12.3, Xcode 8.3 beta
-
Radar URL:
Description
Let's say you have a framework which defines a subclass of a UIKit view, like so:
public class ImageView: UIImageView { }
Now you're writing tests for your framework. You add a test utils extension to UIView:
extension UIView {
convenience init(foo: String) {
fatalError()
}
}
Now, if you try to use the class from your framework in the tests, perhaps like this:
func foo(imageView: ImageView) { }
You'll receive a segfault when compiling your tests:
0 swift 0x0000000104af3677 PrintStackTraceSignalHandler(void*) + 39 1 swift 0x0000000104af2b26 SignalHandler(int) + 646 2 libsystem_platform.dylib 0x00007fffd110ebba _sigtramp + 26 3 libsystem_platform.dylib 0x0000000000000012 _sigtramp + 787420274 4 swift 0x000000010246cbf6 swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, swift::NLOptions, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 3670 5 swift 0x0000000102137633 (anonymous namespace)::SwiftDeclConverter::recordObjCOverride(swift::AbstractFunctionDecl*) + 387 6 swift 0x0000000102136911 (anonymous namespace)::SwiftDeclConverter::importConstructor(clang::ObjCMethodDecl const*, swift::DeclContext*, bool, llvm::Optional<swift::CtorInitializerKind>, bool, swift::ObjCSelector, swift::importer::ImportedName, llvm::ArrayRef<clang::ParmVarDecl const*>, bool, bool&) + 8929 7 swift 0x00000001021308df (anonymous namespace)::SwiftDeclConverter::importConstructor(clang::ObjCMethodDecl const*, swift::DeclContext*, bool, llvm::Optional<swift::CtorInitializerKind>, bool) + 767 8 swift 0x000000010211adf9 (anonymous namespace)::SwiftDeclConverter::importObjCMethodDecl(clang::ObjCMethodDecl const*, swift::DeclContext*, bool) + 361 9 swift 0x0000000102110fd9 clang::declvisitor::Base<clang::declvisitor::make_const_ptr, (anonymous namespace)::SwiftDeclConverter, swift::Decl*>::Visit(clang::Decl const*) + 1481 10 swift 0x0000000102110234 swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, swift::importer::ImportNameVersion, bool) + 532 11 swift 0x000000010213be63 (anonymous namespace)::SwiftDeclConverter::importObjCMembers(clang::ObjCContainerDecl const*, swift::DeclContext*, llvm::SmallPtrSet<swift::Decl*, 4u>&, llvm::SmallVectorImpl<swift::Decl*>&) + 243 12 swift 0x000000010213a80f swift::ClangImporter::Implementation::loadAllMembers(swift::Decl*, unsigned long long) + 447 13 swift 0x0000000102427bfd swift::NominalTypeDecl::getMembers() const + 125 14 swift 0x000000010246e00b swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 491 15 swift 0x0000000102045485 swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 31781 16 swift 0x0000000102046ac7 swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 37479 17 swift 0x0000000102053168 swift::ModuleFile::loadAllMembers(swift::Decl*, unsigned long long) + 600 18 swift 0x0000000102427bfd swift::NominalTypeDecl::getMembers() const + 125 19 swift 0x000000010246e00b swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 491 20 swift 0x0000000101ce1159 swift::BottomUpFunctionOrder::DFS(swift::SILFunction*) + 1961 21 swift 0x0000000101d8ebab swift::SILPassManager::runOneIteration() + 1243 22 swift 0x0000000101b7656d swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 381 23 swift 0x0000000101d94107 swift::runSILDiagnosticPasses(swift::SILModule&) + 1591 24 swift 0x0000000101a14e28 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 42856 25 swift 0x00000001019c44bc main + 9052 26 libdyld.dylib 0x00007fffd0f01255 start + 1 Stack dump: 1. While loading members for 'ImageView' in module 'Baz' 2. While deserializing 'init' (ConstructorDecl #3)in 'Baz' 3. While deserializing decl #31 (XREF)in 'Baz' 4. Cross-reference to module 'UIKit' ... UIImageView ... init ... with type (UIImageView.Type) -> (Optional<UIImage>) -> UIImageView 5. /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIImageView.h:16:40: loading members for 'UIImageView' 6. /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIImageView.h:18:1: importing 'UIImageView::initWithImage:'
This is a regression in Xcode 8.3 beta, this code compiles under Xcode 8.2. I've attached an example project to repro; just open the Baz project and attempt to test the Baz target by running BazTests.
Attachments
Issue Links
- is duplicated by
-
SR-3889 Swift compiler crashes with -O option
-
- Resolved
-