<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On 27 Jan 2017, at 01:30, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">Cool, thanks--that makes sense.<br class=""><br class="">Personally, although DWIM is appealing, I think if we are to go all-out on your stance that "adding a default to an existing type parameter should be a strict source-breaking change," then "prefer user" is the one rule that maximally clarifies the scenario. With that rule, in the evolution scenarios that I brought up, either the user-specified default and the inferred literal type line up perfectly or it is guaranteed to be source-breaking. IMO, that consistency would bring more clarity than DWIM, which might prompt a user to be confused why sometimes the compiler "gets it" and other times it doesn’t.</div></blockquote><br class=""></div><div>I’m not sure, I think it will be easy enough for users to figure out where the problem is because it will create a type-mismatch.</div><div>When type mismatches occur, the only place to look is the variable definition, because that is where the type is defined.</div><div><br class=""></div><div>This is such a narrow case that I’m sure we can provide good diagnostics for it. The pattern could be:</div><div><br class=""></div><div>- A generic parameter mismatch (i.e. trying to use a value of type MyType&lt;X&gt; where type MyType&lt;Y&gt; is expected), and</div><div>- X and Y are both {Whatever}LiteralConvertible, and</div><div>- X is the default type bound to that parameter, and&nbsp;</div><div>- the value was initialised using a {Whatever} literal, where an instance of the parameter was expected</div><div><br class=""></div><div>In that case, we could introduce a simple fix-it: replacing one of the literal values with "(literal as Y)”</div><div><br class=""></div><div>for example:</div><div><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div><font face="Courier" class="">struct Something&lt;T=Int64&gt; { let value: T }</font></div><div><font face="Courier" class="">func action(_: Something&lt;Int&gt;) { … } // Expects a specific kind of Something&lt;T&gt;</font></div><div><br class=""></div><div><font face="Courier" class="">let myThing = Something(value: 42) // Fix-it: Did you mean&nbsp;‘Something(value: 42 as Int)’?</font></div><div><font face="Courier" class="">action(myThing) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Error: No overload for ‘action’ which takes a Something&lt;Int64&gt;.</font></div></blockquote><div><br class=""></div><div><br class=""></div></body></html>