<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 May 18, 2016, at 2:55 PM, Joe Groff <<a href="mailto:jgroff@apple.com" class="">jgroff@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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 May 18, 2016, at 12:54 PM, Matthew Johnson <<a href="mailto:matthew@anandabits.com" class="">matthew@anandabits.com</a>> wrote:<br class=""><br class=""><br class=""><blockquote type="cite" class="">On May 16, 2016, at 4:06 PM, Joe Groff via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class="">Currently, we parse a type after 'as[?!]' and 'is'. This is mostly what you'd expect, but does lead to problems when an 'as' expression appears as part of a comparison:<br class=""><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>20 as Int64 < y as Int64 // error, '>' expected to close generic parameter list Int64<y><br class=""><br class="">Looking to the future, many people have also expressed interest in the ability to do dynamic type checks against metatype values, not only static types, as in:<br class=""><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>class Base {}<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>class DerivedA {}<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>class DerivedB {}<br class=""><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>var x: Base.Type = DerivedA<br class=""><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>DerivedA() as? x // succeeds<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>DerivedB() as? x // fails<br class=""></blockquote><br class="">The dynamic check itself makes sense but it isn’t clear what type these expressions should return? It can’t be `DerivedA?` like it would in the equivalent static expression as the type is not known statically:<br class=""><br class="">DerivedA() as? DerivedA // succeeds with value Optional<DerivedA>.Some<br class="">DerivedB() as? DerivedA // fails with value Optional<DerivedA>.None<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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: Helvetica; font-size: 12px; font-style: normal; font-variant: 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="">Right, the static type of a cast like this would still have to be the upper bound type of the metatype value. (Unless we introduce some sort of path-dependent types to allow `x.Self` to be a type.)</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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=""></div></blockquote><div><br class=""></div><div>So `Base?` in this case? That makes sense. Thanks for clarifying.</div><br class=""><blockquote type="cite" class=""><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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: Helvetica; font-size: 12px; font-style: normal; font-variant: 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="">-Joe</span></div></blockquote></div><br class=""></body></html>