Avatar
typealias した型に対して extension や conditional conformance するのって公式にはサポートされてないんでしたっけ?以下の書き方でコンパイルも通るし,こう書いて良いのなら書きたいんですが. protocol X { static func hello() } typealias IntArray = [Int] extension IntArray: X { // typealias した型に対して extension static func hello() { print("hello") } } [Int].hello() // OK [String].hello() // ちゃんとエラーになる: Referencing static method 'hello()' on 'Array' requires the types 'String' and 'Int' be equivalent (edited)
5:04 AM
typealias してる元の型が複雑な場合,そう書けた方が読みやすいので. typealias GridChainComplex = ChainComplex1<FreeModule<TensorGenerator<MonomialGenerator<_Un>, GridDiagram.Generator>, 𝐙₂>> extension GridChainComplex { // こう書きたい }