Avatar
ジュニア 4/7/2024 3:03 AM
@swift-5.10 // @_typeEraser(AnyP) protocol P {} struct ConcreteP1: P {} struct ConcreteP2: P {} struct AnyP: P { init(erasing base: some P) {} } struct Foo { dynamic var p: some P { ConcreteP1() } } extension Foo { @_dynamicReplacement(for: p) var replacedP: some P { ConcreteP2() } } print(Foo().p)