<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
That’s was my point.
<div class="">Two sets of rules for the same case in two different places.</div>
<div class="">These should be unified.</div>
<div class=""><br class="">
</div>
<div class="">I’ll write the proposal and create a pull request.</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Aug 17, 2016, at 11:24 PM, Slava Pestov <<a href="mailto:spestov@apple.com" class="">spestov@apple.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<blockquote type="cite" style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<br class="Apple-interchange-newline">
On Aug 17, 2016, at 10:18 AM, Vladimir.S via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class="">
</blockquote>
<br style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<blockquote type="cite" style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
But yes, strictly speaking 'make()->Circle?' conforms to protocol requirement 'make()->Shape?', it does returns 'Shape?', so I believe this should be treated as conformance to MyShapeProtocol protocol.<br class="">
</blockquote>
<br style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I
agree this should be made to work, especially since method overriding supports the exact same scenario.</span><br style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<br style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">We
have two sets of rules, implemented in two different places, for matching method overrides and protocol witnesses. We need to unify the rules and the code.</span><br style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<br style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Slava</span><br style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<br style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<blockquote type="cite" style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<br class="">
<br class="">
On 17.08.2016 10:09, Sitton, Yogev via swift-evolution wrote:<br class="">
<blockquote type="cite" class="">Hi,<br class="">
<br class="">
I raised this issue a few months back and discussion has died out since.<br class="">
I’m raising this again to see if there are any objections before I submit a<br class="">
proposal.<br class="">
<br class="">
<br class="">
<br class="">
I have a class that conforms to a protocol which declares a method with a<br class="">
specific return type.<br class="">
In case I want to return a subclass of the return type I am forced to use<br class="">
anassociatedtype.<br class="">
This feels like a hack.<br class="">
<br class="">
*Example:*<br class="">
<br class="">
// The protocol<br class="">
protocol MyShapeProtocol {<br class="">
// returns Shape<br class="">
func make() -> Shape?<br class="">
}<br class="">
<br class="">
// Circle inherits from Shape<br class="">
class Circle : Shape {}<br class="">
<br class="">
// CircleMaker conforms to the MyShapeProtocol<br class="">
class CircleMaker : MyShapeProtocol {<br class="">
// CircleMaker wants to return Circle which is a type of Shape<br class="">
func make() ->Circle? {<br class="">
return Circle()<br class="">
}<br class="">
}<br class="">
<br class="">
This will not work.<br class="">
For that to work I’ll need to use toe associatedtype “hack”:<br class="">
<br class="">
*Example:*<br class="">
protocol MyShapeProtocol {<br class="">
associatedtype ShapeReturnType : Shape<br class="">
func make() -> ShapeReturnType?<br class="">
}<br class="">
<br class="">
class Circle : Shape {}<br class="">
<br class="">
class CircleMaker : MyShapeProtocol{<br class="">
func make() ->Circle? {<br class="">
return Circle()<br class="">
}<br class="">
}<br class="">
<br class="">
What I’m suggesting is to allow to return a subclass for a protocol method<br class="">
without the need for an associatedtype.<br class="">
<br class="">
Any reason why not?<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
https://lists.swift.org/mailman/listinfo/swift-evolution<br class="">
<br class="">
</blockquote>
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></blockquote>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>