SWFT: Implementing a Sequence causes a compiler error

Originator:colin.eberhardt
Number:rdar://17379331 Date Originated:16-Jun-2014
Status:Open Resolved:
Product:Xcode Product Version:6.0 (6A216f)
Classification: Reproducible:
 
Summary:
I am implementing the Sequence protocol on a class. It works correctly in a Playground file, but fails when added to an iOS project

Steps to Reproduce:
1. Using Xcode 6.0  (6A216f) create a new iOS project.
2. Add Swift file with the following code:

class Matrix: Sequence {
  let cells:Double[][]
  let dimension = 3
  
  init() {
    cells = Double[][]()
    
    // fill with 1's
    for column in 0..dimension {
      cells.append(Array(count: dimension, repeatedValue: 1.0))
    }
  }
  
  typealias GeneratorType = CellSequenceGenerator
  
  func generate() -> CellSequenceGenerator {
    return CellSequenceGenerator(matrix: self)
  }
  
  class CellSequenceGenerator : Generator {
    let matrix: Matrix
    var row = 0, column = 0
    
    init (matrix: Matrix) {
      self.matrix = matrix
    }
    
    typealias Element = Double
    
    func next() -> Double? {
      let nextValue = matrix.cells[row][column]
      row++
      if row >= matrix.dimension {
        row = 0
        column++
      }
      return column < 3 ? nextValue : nil;
    }
  }
}

3. Compile and run

Expected Results:
The app should compile

Actual Results:
Compiler fails reporting the following:

Command /Applications/Xcode6-Beta2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 254

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!