Skip to content

Instantly share code, notes, and snippets.

@jqsilver
Created January 4, 2016 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jqsilver/d363af99656ec34ce9a8 to your computer and use it in GitHub Desktop.
Save jqsilver/d363af99656ec34ce9a8 to your computer and use it in GitHub Desktop.
// MyClass.swift
// MinimalCrashExample
//
// Created by Andy Bartholomew on 1/4/16.
import Foundation
class MyStruct {
var someValue: Int
init(someValue: Int) {
self.someValue = someValue
}
}
protocol SomeProtocol {
var someValue: Int { get }
func doSomethingWithValue() -> Int
}
extension SomeProtocol {
// This method causes a compiler seg fault
func doSomethingWithValue(secretArg: Int? = nil) -> Int {
return self.someValue + 1
}
}
extension MyStruct : SomeProtocol {
}
func test() {
let myStruct = MyStruct(someValue: 5)
print(myStruct)
print(myStruct.doSomethingWithValue())
}
@jqsilver
Copy link
Author

jqsilver commented Jan 4, 2016

Default arguments in a protocol extension cause the compiler to seg fault in XCode 7.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment