[Swift4] protocolでweak宣言が無視されている疑惑


Swift4.0でこんな実装をしていた。

protocol HogeView: class {
    weak var delegate: HogeViewDelegate? { get set }
}

protocol HogeViewDelegate: class {
    // delegate functions
}

class HogeViewController: UIViewController, HogeView {
    weak var delegate: HogeViewDelegate?

    // 以下VC実装
}

ところが、このプロジェクトをXcode9.4.1で開いたところ

'weak' should not be applied to a property declaration in a protocol and will be disallowed in future versions

という警告が出るように

調べてみると、
[SE-0186] Remove ownership keyword support in protocols
ということでprotocolweakなプロパティが宣言できなくなる模様。

そこでちょっと気になったので

Swift4.0でこんなコードを書いてみた。
//: Playground - noun: a place where people can play

import Foundation

class A {}
extension A: CustomDebugStringConvertible {
    var debugDescription: String {
        return "A(\(Unmanaged.passUnretained(self).toOpaque()))"
    }
}

protocol P: class {
    weak var weakVar: A? { get set }
}

class B: P {
    weak var weakVar: A?
}
extension B: CustomDebugStringConvertible {
    var debugDescription: String {
        return "B(\(Unmanaged.passUnretained(self).toOpaque()))"
    }
}

var b: B = B()
print(b, b.weakVar.debugDescription)

b.weakVar = A()
print(b, b.weakVar.debugDescription)

print()

var p: P = B()
print(p, p.weakVar.debugDescription)

p.weakVar = A()
print(p, p.weakVar.debugDescription)

結果
B(0x0000600000030600) nil
B(0x0000600000030600) nil

B(0x00006000000335c0) nil
B(0x00006000000335c0) Optional(A(0x0000600000008530)) <- !?

P型で宣言した変数のweakVarweakになっていない...?

そう考えるとSwift4.1でprotocolweak宣言できなくなっても動きとしては変わらなそうだがはて...

追記

class A {
    deinit {
        print("deinit A")
    }
}

// 中略

var b: B = B()
print(b, b.weakVar.debugDescription)

b.weakVar = A()
print(b, b.weakVar.debugDescription)

print()

var obj: Any = b
if let p = obj as? P {
    print(p, p.weakVar.debugDescription)
    p.weakVar = A()
    print(p, p.weakVar.debugDescription)
}

print(b, b.weakVar.debugDescription)

結果
B(0x00006000000273e0) nil
deinit A
B(0x00006000000273e0) nil

B(0x00006000000273e0) nil
B(0x00006000000273e0) Optional(A(0x0000604000003f10))
deinit A
B(0x00006000000273e0) nil

protocolでキャストしている間だけretainされている(スコープ抜けたらreleaseされてる)ようなので、循環参照問題は大丈夫と見ていいのかなー