<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">But it already works without <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">where T != Self</code>. Moreover, I guess, this solution is currently considered “good enough” not to introduce additional complexity to type system.<br>Also, on <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">and</code> and <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">or</code>—the former already exists in the form of <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">&</code>, and the latter is listed in commonly proposed rejected features.</p>
<p style="margin:0px 0px 1.2em!important">2017-02-28 7:23 GMT+03:00 Robert Bennett via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>>:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important">protocol P1 {}
protocol P2 {
// Now, there's no ambiguity
static func +<T: P1 where T != Self>(lhs: Self, rhs: T) -> Self
static func +<T: P1 where T != Self>(lhs: T, rhs: Self) -> Self
static func +(lhs: Self, rhs: Self) -> Self
}
struct S: P1, P2 {
static func +<T: P1 where T != Self>(lhs: T, rhs: S) -> S {
return rhs
}
static func +<T: P1 where T != Self>(lhs: S, rhs: T) -> S {
return lhs
}
static func +(lhs: S, rhs: S) -> S {
return lhs
}
}
</code></pre><blockquote style="margin:1.2em 0px;border-left:4px solid rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<p style="margin:0px 0px 1.2em!important">Some thought would have to be given to how to handle subtype relationships — probably you would use the polymorphic type of the object at the call site.</p>
</blockquote>
<div title="MDH:QnV0IGl0IGFscmVhZHkgd29ya3Mgd2l0aG91dCBgd2hlcmUgVCAhPSBTZWxmYC4gTW9yZW92ZXIs
IEkgZ3Vlc3MsIHRoaXMgc29sdXRpb24gaXMgY3VycmVudGx5IGNvbnNpZGVyZWQgImdvb2QgZW5v
dWdoIiBub3QgdG8gaW50cm9kdWNlIGFkZGl0aW9uYWwgY29tcGxleGl0eSB0byB0eXBlIHN5c3Rl
bS48ZGl2PkFsc28sIG9uIGBhbmRgIGFuZCBgb3JgLS10aGUgZm9ybWVyIGFscmVhZHkgZXhpc3Rz
IGluIHRoZSBmb3JtIG9mIGAmYW1wO2AsIGFuZCB0aGUgbGF0dGVyIGlzIGxpc3RlZCBpbiBjb21t
b25seSBwcm9wb3NlZCByZWplY3RlZCBmZWF0dXJlcy48YnI+PGRpdiBjbGFzcz0iZ21haWxfZXh0
cmEiPjxicj48ZGl2IGNsYXNzPSJnbWFpbF9xdW90ZSI+MjAxNy0wMi0yOCA3OjIzIEdNVCswMzow
MCBSb2JlcnQgQmVubmV0dCB2aWEgc3dpZnQtZXZvbHV0aW9uIDxzcGFuIGRpcj0ibHRyIj4mbHQ7
PGEgaHJlZj0ibWFpbHRvOnN3aWZ0LWV2b2x1dGlvbkBzd2lmdC5vcmciIHRhcmdldD0iX2JsYW5r
Ij5zd2lmdC1ldm9sdXRpb25Ac3dpZnQub3JnPC9hPiZndDs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