Looking into this a bit further, I see that this use case is specifically mentioned in the generics manifesto under the ‘unlikely' section.
<https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md#conditional-conformances-via-protocol-extensions> <https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md#conditional-conformances-via-protocol-extensions>https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md#conditional-conformances-via-protocol-extensions > On Dec 6, 2017, at 07:35, Matt Whiteside <mwhiteside....@gmail.com> wrote: > > Thanks Jens. Your example does work for me. The use case I have been trying > to accomplish is conditional conformance of a protocol, not a struct. After > re-reading, it looks like this is not covered by SE-0143. > > import CoreGraphics > > protocol Drawable { > func draw() > } > > protocol Point2D{ > associatedtype T:FloatingPoint & ExpressibleByFloatLiteral > var x:T{ > get > } > var y:T{ > get > } > } > > extension Collection: Drawable where Element:Point2D {//error: Extension of > protocol ‘Collection’ cannot have an inheritance clause > func draw(){ > print("drawing something here") > } > } > > Matt > > >> On Dec 6, 2017, at 00:25, Jens Persson <j...@bitcycle.com >> <mailto:j...@bitcycle.com>> wrote: >> >> Oh I forgot to include the step where I select the newly installed toolchain >> ... >> >> On Wed, Dec 6, 2017 at 9:24 AM, Jens Persson via swift-users >> <swift-users@swift.org <mailto:swift-users@swift.org>> wrote: >> I've now installed 2017-12-05 snapshot and can confirm that it too works for >> me. >> In more detail: >> >> 1. Install swift-DEVELOPMENT-SNAPSHOT-2017-12-05-a-osx.pkg >> >> 2. Restart Xcode (I'm using Xcode 9.2 (9C40b)) >> (I guess it shouldn't be necessary to restart, but I think it might be >> ...) >> >> 3. Create a new command line project. >> >> 4. Put -enable-experimental-conditional-conformances in Other Swift Flags in >> the project's Build Settings. >> >> 5. Enter the following code in main.swift and Build (which works without >> errors): >> >> protocol P {} >> struct S<T> {} >> extension S: P where T: P {} >> >> >> Regarding step 2. I'm not 100% sure, but I think that it might be necessary >> to restart Xcode after installing a new snapshot, because even if the new >> snapshot can be selected from the toolchains menu, it doesn't take affect >> until after restarting Xcode. I'm always restarting Xcode after installing >> and selecting a new toolchain. Someone please correct me if you can prove >> that this isn't necessary. >> >> /Jens >> >> On Wed, Dec 6, 2017 at 7:48 AM, Jens Persson via swift-users >> <swift-users@swift.org <mailto:swift-users@swift.org>> wrote: >> It works for me with Xcode 9.1 and 9.2 using latest dev snapshot (from >> 2017-11-28 and 2017-12-03), I added >> -enable-experimental-conditional-conformances in Other Swift Flags as you >> show in the screenshot. >> /Jens >> >> On Wed, Dec 6, 2017 at 4:32 AM, Matt Whiteside via swift-users >> <swift-users@swift.org <mailto:swift-users@swift.org>> wrote: >> Hello Swift Users, >> >> [This is a resend with smaller attachment] Has anyone had luck passing the >> new '-enable-experimental-conditional-conformances' flag to Xcode? It works >> when I run swift from the command line, with the Dec. 5th snapshot >> toolchain, but not Xcode. I have tried whats in the screenshot below as >> well as adding -Xfrontend, but I’m still getting the usual ‘extension of >> protocol cannot have an inheritance clause’ error: >> >> Thanks for any suggestions on this, >> >> Matt >> >> >> <Screen Shot 2017-12-05 at 19.19.06.png> >> >> >> >> _______________________________________________ >> swift-users mailing list >> swift-users@swift.org <mailto:swift-users@swift.org> >> https://lists.swift.org/mailman/listinfo/swift-users >> <https://lists.swift.org/mailman/listinfo/swift-users> >> >> >> >> _______________________________________________ >> swift-users mailing list >> swift-users@swift.org <mailto:swift-users@swift.org> >> https://lists.swift.org/mailman/listinfo/swift-users >> <https://lists.swift.org/mailman/listinfo/swift-users> >> >> >> >> _______________________________________________ >> swift-users mailing list >> swift-users@swift.org <mailto:swift-users@swift.org> >> https://lists.swift.org/mailman/listinfo/swift-users >> <https://lists.swift.org/mailman/listinfo/swift-users> >> >> >
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users