Why can't I change variables in a protocol extension where self is a class? : <p>I am curious why this doesn't work:</p>

<pre><code>public protocol MyProtocol {
    var i: Int { get set }
}

public protocol MyProtocol2: class, MyProtocol {}

public extension MyProtocol2 where Self: AnyObject {
    func a() {
        i = 0 &lt;-- error
    }
}
</code></pre>

<p>Error:</p>

<blockquote>
  <p>Cannot assign to property: 'self' is immutable</p>
</blockquote>

<p>Why? Only classes can adopt MyProtocol2. If I add <code>: class</code> declaration behind MyProtocol it works. I do not understand why it doesn't work on a subprotocol.</p>
