<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="">Looking at that proposal on Austin’s Github, would its complete implementation require/allow for <i class="">any</i> type that’s known at runtime to be used like a type at compile time? So that these two blocks would both work? It seems like the runtime would be using the same technology, but it’s hard to tell.<div class=""><pre class="" style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 0.94em; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(248, 248, 248); border: 1px solid rgb(204, 204, 204); white-space: pre-wrap; word-wrap: break-word; padding: 5px;"><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> a : </span><span style="font-variant-ligatures: no-common-ligatures; color: #aa2eb8" class="">Collection</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">where</span><span style="font-variant-ligatures: no-common-ligatures" class=""> .Element == Int = </span><span style="font-variant-ligatures: no-common-ligatures; color: #929292" class="">// ...</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> b : </span><span style="font-variant-ligatures: no-common-ligatures; color: #aa2eb8" class="">Collection</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">where</span><span style="font-variant-ligatures: no-common-ligatures" class=""> .Element == Int = </span><span style="font-variant-ligatures: no-common-ligatures; color: #929292" class="">// ...</span></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> someGenericFunc<C : </span><span style="font-variant-ligatures: no-common-ligatures; color: #aa2eb8" class="">Collection</span><span style="font-variant-ligatures: no-common-ligatures" class="">>(x: </span><span style="font-variant-ligatures: no-common-ligatures; color: #498672" class="">C</span><span style="font-variant-ligatures: no-common-ligatures" class="">, y: </span><span style="font-variant-ligatures: no-common-ligatures; color: #498672" class="">C</span><span style="font-variant-ligatures: no-common-ligatures" class="">) </span><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">where</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #498672" class="">C</span><span style="font-variant-ligatures: no-common-ligatures" class="">.Element == </span><span style="font-variant-ligatures: no-common-ligatures; color: #5b2699" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class=""> {</span></div><div style="margin: 0px; line-height: normal; color: rgb(146, 146, 146);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// ...</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">if</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> openedA = </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">a</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">as</span><span style="font-variant-ligatures: no-common-ligatures" class="">? </span><span style="font-variant-ligatures: no-common-ligatures; color: #aa2eb8" class="">a</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #aa2eb8" class="">Self</span><span style="font-variant-ligatures: no-common-ligatures" class="">, let openedB = </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">b</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">as</span><span style="font-variant-ligatures: no-common-ligatures" class="">? </span><span style="font-variant-ligatures: no-common-ligatures; color: #aa2eb8" class="">a</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #aa2eb8" class="">Self</span><span style="font-variant-ligatures: no-common-ligatures" class=""> {</span></div><div style="margin: 0px; line-height: normal; color: rgb(146, 146, 146);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// openedA is type a.Self; openedB is type a.Self</span></div><div style="margin: 0px; line-height: normal; color: rgb(146, 146, 146);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// We now know that openedA and openedB are the same concrete type, which</span></div><div style="margin: 0px; line-height: normal; color: rgb(146, 146, 146);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// conforms to Collection with Elements that are Ints</span></div><div style="margin: 0px; line-height: normal; color: rgb(146, 146, 146);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// This is okay</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">someGenericFunc</span><span style="font-variant-ligatures: no-common-ligatures" class="">(x: openedA, y: openedB)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div></pre><div class=""><pre class="" style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 0.94em; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(248, 248, 248); border: 1px solid rgb(204, 204, 204); white-space: pre-wrap; word-wrap: break-word; padding: 5px;"><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> a : </span><span style="font-variant-ligatures: no-common-ligatures; color: #aa2eb8" class="">Collection</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">where</span><span style="font-variant-ligatures: no-common-ligatures" class=""> .Element == Int = </span><span style="font-variant-ligatures: no-common-ligatures; color: #929292" class="">// ...</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> b : </span><span style="font-variant-ligatures: no-common-ligatures; color: #aa2eb8" class="">Collection</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">where</span><span style="font-variant-ligatures: no-common-ligatures" class=""> .Element == Int = </span><span style="font-variant-ligatures: no-common-ligatures; color: #929292" class="">// ...</span></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> someGenericFunc<C : </span><span style="font-variant-ligatures: no-common-ligatures; color: #aa2eb8" class="">Collection</span><span style="font-variant-ligatures: no-common-ligatures" class="">>(x: </span><span style="font-variant-ligatures: no-common-ligatures; color: #498672" class="">C</span><span style="font-variant-ligatures: no-common-ligatures" class="">, y: </span><span style="font-variant-ligatures: no-common-ligatures; color: #498672" class="">C</span><span style="font-variant-ligatures: no-common-ligatures" class="">) </span><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">where</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #498672" class="">C</span><span style="font-variant-ligatures: no-common-ligatures" class="">.Element == </span><span style="font-variant-ligatures: no-common-ligatures; color: #5b2699" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class=""> {</span></div><div style="margin: 0px; line-height: normal; color: rgb(146, 146, 146);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// ...</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><span style="font-size: 0.94em; font-variant-ligatures: no-common-ligatures; color: rgb(0, 143, 1);" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><span style="font-size: 0.94em; font-variant-ligatures: no-common-ligatures; color: rgb(0, 143, 1);" class="">let</span><span style="font-size: 0.94em; font-variant-ligatures: no-common-ligatures;" class=""> desiredType = type(of: </span><span style="font-size: 0.94em; font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">a</span><span style="font-size: 0.94em; font-variant-ligatures: no-common-ligatures;" class="">)</span><span style="font-variant-ligatures: no-common-ligatures" class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">if</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> openedA = </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">a</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">as</span><span style="font-variant-ligatures: no-common-ligatures" class="">? </span>desiredType<span style="font-variant-ligatures: no-common-ligatures" class="">, let openedB = </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">b</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">as</span><span style="font-variant-ligatures: no-common-ligatures" class="">? </span>desiredType<span style="font-variant-ligatures: no-common-ligatures" class=""> {</span></div><div style="margin: 0px; line-height: normal; color: rgb(146, 146, 146);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// openedA is type a.Self; openedB is type a.Self</span></div><div style="margin: 0px; line-height: normal; color: rgb(146, 146, 146);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// We now know that openedA and openedB are the same concrete type, which</span></div><div style="margin: 0px; line-height: normal; color: rgb(146, 146, 146);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// conforms to Collection with Elements that are Ints</span></div><div style="margin: 0px; line-height: normal; color: rgb(146, 146, 146);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// This is okay</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">someGenericFunc</span><span style="font-variant-ligatures: no-common-ligatures" class="">(x: openedA, y: openedB)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div>
</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">assert</span><span style="font-variant-ligatures: no-common-ligatures" class="">(type(of: </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">a</span><span style="font-variant-ligatures: no-common-ligatures" class="">) === </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">a</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">Self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #008f01" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div></div></pre><div class=""><br class=""></div></div></div></body></html>