Skip to content

Instantly share code, notes, and snippets.

@protocool
Created July 29, 2015 17:03
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 protocool/ecbd9016bf37c5b6f080 to your computer and use it in GitHub Desktop.
Save protocool/ecbd9016bf37c5b6f080 to your computer and use it in GitHub Desktop.
import Foundation
protocol P {
typealias PT: NSObject = Self
static func vendSpecific() -> PT?
}
extension P where Self: NSObject, PT == Self {
static func vendSpecific() -> PT? {
return nil
}
}
class A: NSObject, P {
}
class B: A {
typealias PT = B
}
func compilerSIGILL() {
B.vendSpecific()
}
@protocool
Copy link
Author

Without the typealias in Class B, you can't call B.vendSpecific() b/c B doesn't conform to the P extension's constraints.

With the typealias, the compiler SIGILLs because SIL verification failed.

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