<div dir="ltr">Just to clarify: in your example, did you mean for DerivedA and DerivedB to inherit from Base?</div><br><div class="gmail_quote"><div dir="ltr">On Mon, May 16, 2016 at 4:18 PM Matthew Johnson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+1<br>
<br>
Sent from my iPhone<br>
<br>
&gt; On May 16, 2016, at 4:06 PM, Joe Groff via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt; Currently, we parse a type after &#39;as[?!]&#39; and &#39;is&#39;. This is mostly what you&#39;d expect, but does lead to problems when an &#39;as&#39; expression appears as part of a comparison:<br>
&gt;<br>
&gt;    20 as Int64 &lt; y as Int64 // error, &#39;&gt;&#39; expected to close generic parameter list Int64&lt;y&gt;<br>
&gt;<br>
&gt; 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>
&gt;<br>
&gt;    class Base {}<br>
&gt;    class DerivedA {}<br>
&gt;    class DerivedB {}<br>
&gt;<br>
&gt;    var x: Base.Type = DerivedA<br>
&gt;<br>
&gt;    DerivedA() as? x // succeeds<br>
&gt;    DerivedB() as? x // fails<br>
&gt;<br>
&gt; If we accept <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0090-remove-dot-self.md" rel="noreferrer" target="_blank">https://github.com/apple/swift-evolution/blob/master/proposals/0090-remove-dot-self.md</a>, dropping the &#39;.self&#39; requirement to refer to type objects, then I think we should also change &#39;is&#39; and &#39;as&#39; to parse the expression grammar on their right-hand side, leaving it up to the normal expression disambiguation rule to handle angle brackets. This solves the &#39;20 as Int64 &lt; x&#39; problem, and prepares us to support dynamic is/as queries in the future. (To be clear, designing dynamic queries should be its own discussion.) What do you all think?<br>
&gt;<br>
&gt; -Joe<br>
&gt; _______________________________________________<br>
&gt; swift-evolution mailing list<br>
&gt; <a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div><div dir="ltr">-- <br></div><div><div dir="ltr"><div><div>Dan Appel<br></div></div></div></div>