Avatar
norio_nomura 7/12/2019 6:43 AM
someassociatedTypeの型を制限する @swift-5.1.5 protocol P1 { associatedtype A var a: A { get } } protocol AisInt: P1 where A == Int {} struct S<A>: P1 { var a: A } extension S: AisInt where A == Int {} func f1() -> some P1 { S(a: 1) } func f2() -> some AisInt { S(a: 1) } print(f1().a is Int) print(f2().a is Int)