<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">+1<div class=""><br class=""></div><div class="">An example I ran in to today:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 16px; line-height: normal; font-family: &quot;Fira Code&quot;; color: rgb(231, 232, 235); background-color: rgb(41, 43, 54);" class=""><span style="color: #e12da0" class="">func</span> dumpKeys&lt;T&gt;(of object: <span style="color: #18b5b1" class="">T</span>, <span style="color: #e12da0" class="">_</span> keypaths: <span style="color: #29a09f" class="">PartialKeyPath</span>&lt;<span style="color: #18b5b1" class="">T</span>&gt;...) {</div><div style="margin: 0px; font-stretch: normal; font-size: 16px; line-height: normal; font-family: &quot;Fira Code&quot;; color: rgb(231, 232, 235); background-color: rgb(41, 43, 54);" class="">&nbsp; <span style="color: #e12da0" class="">for</span> kp <span style="color: #e12da0" class="">in</span> keypaths {</div><div style="margin: 0px; font-stretch: normal; font-size: 16px; line-height: normal; font-family: &quot;Fira Code&quot;; color: rgb(231, 232, 235); background-color: rgb(41, 43, 54);" class="">&nbsp; &nbsp; <span style="color: #29a09f" class="">print</span>(<span style="color: #de3a3c" class="">"-"</span>, <span style="color: #de3a3c" class="">"</span>\<span style="color: #de3a3c" class="">(</span>kp<span style="color: #de3a3c" class="">): </span>\<span style="color: #de3a3c" class="">(</span>object[keyPath: kp]<span style="color: #de3a3c" class="">)"</span>)</div><div style="margin: 0px; font-stretch: normal; font-size: 16px; line-height: normal; font-family: &quot;Fira Code&quot;; color: rgb(231, 232, 235); background-color: rgb(41, 43, 54);" class="">&nbsp; }</div><div style="margin: 0px; font-stretch: normal; font-size: 16px; line-height: normal; font-family: &quot;Fira Code&quot;; color: rgb(231, 232, 235); background-color: rgb(41, 43, 54);" class="">}</div><div><br class=""></div><div>Then in LLDB, I want to be able to write:</div><div><br class=""></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div>dumpKeys(of: context, \.invalidateEverything, \.invalidateDataSourceCounts)</div></div></blockquote><div class=""><div><br class=""></div><div>But the PartialKeyPath expressions are considered ambiguous :(</div><div><br class=""></div><div>- Karl</div><div><br class=""><blockquote type="cite" class=""><div class="">On 12. Jan 2018, at 02:20, Kenny Leung via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Filed as&nbsp;<a href="https://bugs.swift.org/browse/SR-6740" class="">https://bugs.swift.org/browse/SR-6740</a></div><div class=""><br class=""></div><div class="">-Kenny</div><div class=""><br class=""></div><br class=""><div style="" class=""><blockquote type="cite" class=""><div class="">On Jan 11, 2018, at 3:12 PM, Jordan Rose &lt;<a href="mailto:jordan_rose@apple.com" class="">jordan_rose@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I'm not sure whether it was supposed to be supported or not, but either way it's a reasonable feature request. Please file at <a href="http://bugs.swift.org/" class="">bugs.swift.org</a>.<div class=""><br class=""></div><div class="">Jordan</div><div class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Jan 11, 2018, at 14:41, Kenny Leung via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi All.<div class=""><br class=""></div><div class="">I’d like to be lazy and leave out the classname on a key path whenever possible. I thought that if PartialKeyPath was specified as the argument type, that meant the compiler should be able to figure out what the class is, but this does not seem to be the case.</div><div class=""><br class=""></div><div class="">Here’s an example that works.</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">class</span> ThePath {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; <span style="color: #ba2da2" class="">var</span> isWinding:<span style="color: #703daa" class="">Bool</span>?</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div><div style="margin: 0px; font-size: 12px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">func</span> walk&lt;T&gt;(aPath:<span style="color: #4f8187" class="">T</span>, forKey:<span style="color: #703daa" class="">PartialKeyPath</span>&lt;<span style="color: #4f8187" class="">T</span>&gt;) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div><div style="margin: 0px; font-size: 12px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">func</span> walkThePath(aPath:<span style="color: #4f8187" class="">ThePath</span>, forKey:<span style="color: #703daa" class="">PartialKeyPath</span>&lt;<span style="color: #4f8187" class="">ThePath</span>&gt;) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div><div style="margin: 0px; font-size: 12px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">func</span> test() {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; <span style="color: #ba2da2" class="">let</span> path = <span style="color: #4f8187" class="">ThePath</span>()</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; <span style="color: #31595d" class="">walkThePath</span>(aPath:path, forKey:\<span style="color: #4f8187" class="">ThePath</span>.isWinding)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; <span style="color: #31595d" class="">walk</span>(aPath:path, forKey:\<span style="color: #4f8187" class="">ThePath</span>.isWinding)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div></div><div class=""><br class=""></div><div class="">If you do this then it complains:</div><div class=""><br class=""></div><div class=""><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: rgb(186, 45, 162);" class="">func</span>&nbsp;test() {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp;&nbsp;<span style="color: rgb(186, 45, 162);" class="">let</span>&nbsp;path =&nbsp;<span style="color: rgb(79, 129, 135);" class="">ThePath</span>()</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp;&nbsp;<span style="color: rgb(49, 89, 93);" class="">walkThePath</span>(aPath:path, forKey:\.isWinding) //&nbsp;Expression type '()' is ambiguous without more context</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp;&nbsp;<span style="color: rgb(49, 89, 93);" class="">walk</span>(aPath:path, forKey:\.isWinding) &nbsp; &nbsp; &nbsp; &nbsp;//&nbsp;Type of expression is ambiguous without more context</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div></div><div class=""><br class=""></div></div><div class="">Should I be able to do this?</div><div class=""><br class=""></div><div class="">Thanks!</div><div class=""><br class=""></div><div class="">-Kenny</div><div class=""><br class=""></div></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></body></html>