Avatar
おや・・・ protocol Foo {} extension Int: Foo {} protocol P { associatedtype F: Foo func foo1() -> F func foo2() -> F } struct S { func foo1() -> __opaque Foo { return 2 } func foo2() -> __opaque Foo { return 3 } } let s = S() var a = s.foo1() let b = s.foo2() a = b /path/to/opaque-result.swift:17:5: error: cannot assign value of type '(__opaque main.(file).S.foo2()@/path/to/opaque-result.swift:11:10)' to type '(__opaque main.(file).S.foo1()@/path/to/opaque-result.swift:10:10)' a = b ^ as! (__opaque main.(file).S.foo1()@/path/to/opaque-result.swift:10:10) (edited)
4:03 PM
↓こちらをビルドして試した結果。 https://github.com/jckarter/swift/tree/opaque-type-ast
The Swift Programming Language. Contribute to jckarter/swift development by creating an account on GitHub.
4:03 PM
↓こっちの方がいいのかな? Proposal からリンクされてた PR のブランチは↑だけど。 https://github.com/jckarter/swift/tree/opaque-type-runtime (edited)
The Swift Programming Language. Contribute to jckarter/swift development by creating an account on GitHub.
4:08 PM
↓こっちはそもそも -> (some Foo, some Foo) が現時点で許されてなかった。 protocol Foo {} extension Int: Foo {} protocol P { associatedtype F: Foo func foos() -> (F, F) } struct S { func foos() -> (__opaque Foo, __opaque Foo) { return (2, 3) } } let s = S() var (a, b) = s.foos() a = b /path/to/opaque-result-2.swift:9:21: error: 'opaque' types are only implemented for the declared type of properties and subscripts and the return type of functions func foos() -> (__opaque Foo, __opaque Foo) { return (2, 3) } ^ (edited)