Xcode 7.1b1: [Swift] Compiler crash involving a protocol extension and a generic type

Originator:janoschhildebrand
Number:rdar://22720220 Date Originated:16-Sep-2015
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 7.1b1
Classification:Serious Bug Reproducible:Always
 
Summary:
Sorry for the vague title, I'm simply not sure what the ultimate culprit is in this case.


The following code snippet causes the Swift compiler to crash. An example project and crash report are attached.

struct Test : TestType {
    var storage: [Int] = []

    mutating func pop() -> Int? {
        return storage.popLast()
    }
}

public protocol TestType : SequenceType {
    mutating func pop() -> Int?
}

extension TestType {
    func generate() -> TestGenerator<Self> {
        return TestGenerator(self)
    }
}

struct TestGenerator<T : TestType> : GeneratorType {
    private var content: T
    
    init(_ content: T) {
        self.content = content
    }
    
    mutating func next() -> Int? {
        return content.pop()
    }
}

Steps to Reproduce:
1) Download the attached project
2) Build

Expected Results:
The compiler should not crash and instead compile the given code successfully.

Actual Results:
The compiler crashes.

Stacktrace:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   swift                         	0x000000010a8dadfd emitNominalMetadataRef(swift::irgen::IRGenFunction&, swift::NominalTypeDecl*, swift::CanType) + 29
1   swift                         	0x000000010a8d4770 getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t) + 912
2   swift                         	0x000000010a8ce929 emitCallToTypeMetadataAccessFunction(swift::irgen::IRGenFunction&, swift::CanType, swift::ForDefinition_t) + 73
3   swift                         	0x000000010a8db0d3 emitNominalMetadataRef(swift::irgen::IRGenFunction&, swift::NominalTypeDecl*, swift::CanType) + 755
4   swift                         	0x000000010a8d4770 getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t) + 912
5   swift                         	0x000000010a8ce929 emitCallToTypeMetadataAccessFunction(swift::irgen::IRGenFunction&, swift::CanType, swift::ForDefinition_t) + 73
6   swift                         	0x000000010a90aa0b swift::irgen::emitPolymorphicArguments(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, llvm::ArrayRef<swift::Substitution>, swift::irgen::WitnessMetadata*, swift::irgen::Explosion&) + 587
7   swift                         	0x000000010a956c96 (anonymous namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 2230
8   swift                         	0x000000010a94877d swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 10973
9   swift                         	0x000000010a8b0498 swift::irgen::IRGenModuleDispatcher::emitGlobalTopLevel() + 376
10  swift                         	0x000000010a92fa99 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 793
11  swift                         	0x000000010a92ff10 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, unsigned int) + 64
12  swift                         	0x000000010a8372e8 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 13704
13  swift                         	0x000000010a833b4a frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2682
14  swift                         	0x000000010a8301d7 main + 2247
15  libdyld.dylib                 	0x00007fff8bb8c5ad start + 1

Version:
OS X 10.11 (15A282b)
Version 7.1 beta (7B60)
Apple Swift version 2.0 (swiftlang_PONDEROSA-700.1.100.2 clang-700.1.74)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!