The Swift Make-It-Compile Challenge #4 This is a challenge for the people using Swift 2.0 beta 6, it's not code golf, but it's a programming puzzle so I'm pretty sure this belongs here. The basic idea is: Make it compile. There are more details and a very nicely formatted playground at the Github project. Previous challenges are there as well, all set up to tinker. Solutions are included for the previous challenges, as they all have been solved.

Rules


You can't modify the given lines
You can't insert anything between the given lines
You can't provide custom functions for ones that are in the standard library, according to the syntax-hightlighed picture. This applies to the inverse as well.
The given lines are not allowed to produce a warning (on default warning settings). However the code you append is allowed to produce warnings.
The code may or may not crash at runtime, it only has to compile


The Code

func doIt(inout s: D) {
    if case self = isUniquelyReferenced(&amp;s),
        self.`self` = true where self {
        self.`self` = { [unowned x = [self, 7] as Self] n in
            print(x + n)
        } as () -&gt; ()
    }
}


The Picture



Winner

The first one posting an answer that compiles and conforms to all the rules above wins and gets an entry in the projects Hall of Fame.

EDIT: Hint

Upon submission of Chris Goldsby's 99% solution, he received the following hint:


  The syntax highlighting of


protocol P {
    typealias P
    var p : P { get }
}
I'm posting this answer on behalf of Chris Goldsby who managed to submit a
99% Solution (Gist):
typealias D = NonObjectiveCBase

func ~=(left: Any, right: Bool) -&gt; BooleanType {
    return true
}

func +(left: Any, right: Any) -&gt; String {
    return &quot;&quot;
}

protocol &amp;#128034;: class, BooleanType, ArrayLiteralConvertible {
    
    var `self` : () -&gt; () { get set }
}

extension &amp;#128034; {
    
    typealias Element = Any
    
    internal init(arrayLiteral elements: Any...) {
        self.init()
    }
    
    //
    
    func doIt(inout s: D) {
        if case self = isUniquelyReferenced(&amp;s),
            self.`self` = true where self {
            self.`self` = { [unowned x = [self, 7] as Self] n in
                print(x + n)
            } as () -&gt; ()
        }
    }
    
    //
    
}

Only the snytax highlighting of D doesn't match. That's remarkable as it is!
100% Solution
EDIT: Two days later he submitted the following full solution, congrats!:
private func ~=(left: Any, right: Bool) -&gt; BooleanType {
    return true
}

private func +(left: Any, right: Any) -&gt; String {
    return &quot;&quot;
}

protocol Challenge4: class, BooleanType, ArrayLiteralConvertible {
    
    typealias D
    
    var `self` : () -&gt; () { get set }
    
    func doIt(inout s: D)
}

private extension Challenge4 where D == NonObjectiveCBase {
    
    typealias Element = Any
    
    init(arrayLiteral elements: Any...) {
        self.init()
    }
    
    //
    
    func doIt(inout s: D) {
        if case self = isUniquelyReferenced(&amp;s),
            self.`self` = true where self {
            self.`self` = { [unowned x = [self, 7] as Self] n in
                print(x + n)
            } as () -&gt; ()
        }
    }
    
    //
    
}