<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 Aug 23, 2017, at 11:00 PM, David Zarzycki via swift-dev &lt;<a href="mailto:swift-dev@swift.org" class="">swift-dev@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; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hello,<div class=""><br class=""></div><div class="">I’d like to propose improving the quality, consistency, and future preparedness of diagnostics through simplification. Right now, a lot of diagnostics output tends to look like this (for example):</div><div class=""><br class=""></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>type ‘Foo’ cannot subclass type ‘Bar’</font></div><div class=""><br class=""></div><div class="">Instead of hard coding the word “type” into the message, I’d like to change the diagnostics engine to dynamically introspect the types and print out the type kind instead. Therefore, after this change, the message output would look like this:</div><div class=""><br class=""></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>class ‘Foo’ cannot subclass struct ‘Bar’<br class=""></font><br class=""></div><div class="">Which is clearly more better. And it requires less work and specialization on behalf of diagnostics clients because the messages within the compiler “defs” files would change from:</div><div class=""><br class=""></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>“type %0 cannot subclass type %1”<br class=""></font><br class=""></div><div class="">To:</div><div class=""><br class=""></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>“%0 cannot subclass %1”<br class=""></font></div><div class=""><br class=""></div><div class="">Which is obviously simpler, better, and more future proof. In particular, clients of the diagnostics engine would no longer need to haphazardly customize messages to acknowledge optionals, metatypes, etc as they do today. The engine itself would deal with that.</div></div></div></div></div></div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">What do people think? The meat of the change is tiny and below. The vast majority of the work is the long and painful fallout in the test suite, which I’m cautiously (and perhaps foolishly) stepping up to doing.</div></div></div></div></div></div></div></div></blockquote><div><br class=""></div>I think that's an interesting improvement in this specific message, but it's not obvious that it would be an improvement to all messages. &nbsp;Generally the way we did things like this in Clang was to add a modifier to the diagnostic string, so that it would look something like "%type1", which would be understood to expand to a noun appropriate for the type. &nbsp;That way, it was easy to take advantage of it for a specific diagnostic, but you weren't forced into it by default. &nbsp;I think that's still the right approach here.</div><div><br class=""></div><div>A few comments on the nouns you've picked:</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><span style="font-family: Courier;" class="">+&nbsp;&nbsp;case TypeKind::Function:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return "function ";</span></div><div class=""><font face="Courier" class="">+&nbsp;&nbsp;case TypeKind::GenericFunction:&nbsp; &nbsp; &nbsp;&nbsp;return "function ";<br class=""></font></div></div></div></div></div></div></div></div></blockquote><div><br class=""></div><div>'function' would be misleading here, since it's actually referring to a function *type*. &nbsp;Consider your example above: "class 'A' cannot subclass function '(Int) -&gt; ()'".</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><font face="Courier" class="">+&nbsp;&nbsp;case TypeKind::ProtocolComposition:&nbsp;&nbsp;return "protocol ";<br class=""></font></div></div></div></div></div></div></div></div></blockquote><div><br class=""></div><div>"cannot convert from protocol 'A &amp; B' to ..."? &nbsp;Hmm. &nbsp;Not sure about this one.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><span style="font-family: Courier;" class="">+&nbsp;&nbsp;case TypeKind::Module:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return "module ";</span></div></div></div></div></div></div></div></div></blockquote><div><br class=""></div>This has a lot of the same problems as "function", I think.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><font face="Courier" class="">+&nbsp;&nbsp;case TypeKind::DynamicSelf:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return "dynamic type ";<br class=""></font></div></div></div></div></div></div></div></div></blockquote><div><br class=""></div><div>This is almost certainly a situation where you're not going to do better than "type".</div><div><br class=""></div><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div class=""><font face="Courier" class="">+&nbsp;&nbsp;case TypeKind::Unresolved:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return "unresolved type ";</font></div></div></div></div></div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><font face="Courier" class="">+&nbsp;&nbsp;case TypeKind::TypeVariable:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return "type-variable ";<br class="">+&nbsp;&nbsp;case TypeKind::SILFunction:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return "SIL function ";<br class="">+&nbsp;&nbsp;case TypeKind::SILBlockStorage:&nbsp; &nbsp; &nbsp;&nbsp;return "SIL block storage ";<br class="">+&nbsp;&nbsp;case TypeKind::SILBox:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return "SIL box ";<br class=""></font></div></div></div></div></div></div></div></div></blockquote><div><br class=""></div>If these ever do show up in diagnostics, I'm not sure a good noun will help.</div><div><br class=""></div><div><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div class=""><span class="" style="font-family: Courier;">+</span><span class="" style="font-family: Courier;">&nbsp;&nbsp;</span><span class="" style="font-family: Courier;">case TypeKind::WeakStorage:</span><br class="" style="font-family: Courier;"><span class="" style="font-family: Courier;">+</span><span class="" style="font-family: Courier;">&nbsp;&nbsp;</span><span class="" style="font-family: Courier;">case TypeKind::UnownedStorage:</span><br class="" style="font-family: Courier;"><span class="" style="font-family: Courier;">+</span><span class="" style="font-family: Courier;">&nbsp;&nbsp;</span><span class="" style="font-family: Courier;">case TypeKind::UnmanagedStorage:</span><br class="" style="font-family: Courier;"><span class="" style="font-family: Courier;">+</span><span class="" style="font-family: Courier;">&nbsp; &nbsp;&nbsp;</span><span class="" style="font-family: Courier;">llvm_unreachable("Not a part of the user facing type system");</span><br class="" style="font-family: Courier;"></div></div></div></div></div></div></div></blockquote><br class=""></div><div>This seems inconsistent given the treatment for SILFunctionType.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><font face="Courier" class="">+&nbsp;&nbsp;case TypeKind::GenericTypeParam:&nbsp;&nbsp; &nbsp;&nbsp;return "generic parameter ";<br class="">+&nbsp;&nbsp;case TypeKind::Archetype: {<br class="">+&nbsp; &nbsp;&nbsp;auto archetypeTy = dyn_cast&lt;ArchetypeType&gt;(type.getPointer());<br class="">+&nbsp; &nbsp;&nbsp;if (auto openedTy = archetypeTy-&gt;getOpenedExistentialType()) {<br class="">+&nbsp; &nbsp; &nbsp;&nbsp;type = openedTy;<br class="">+&nbsp; &nbsp; &nbsp;&nbsp;return computeDiagnosticTypeKindString(type);<br class="">+&nbsp; &nbsp;&nbsp;}<br class="">+&nbsp; &nbsp;&nbsp;if (archetypeTy-&gt;getAssocType())<br class="">+&nbsp; &nbsp; &nbsp;&nbsp;return "associated type ";<br class="">+&nbsp; &nbsp;&nbsp;return "generic parameter ";<br class="">+&nbsp;&nbsp;}<br class=""></font></div></div></div></div></div></div></div></div></blockquote><div><br class=""></div>I'm not sure that being more specific about archetypes is actually helpful to users.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><font face="Courier" class="">+&nbsp;&nbsp;case TypeKind::DependentMember: {<br class="">+&nbsp; &nbsp;&nbsp;while (auto depTy = dyn_cast&lt;DependentMemberType&gt;(type.getPointer()))<br class="">+&nbsp; &nbsp; &nbsp;&nbsp;type = depTy-&gt;getBase();<br class="">+&nbsp; &nbsp;&nbsp;return "dependent " + computeDiagnosticTypeKindString(type);<br class="">+&nbsp;&nbsp;}<br class=""></font></div></div></div></div></div></div></div></div></blockquote><div><br class=""></div><div>This is definitely going to be more confusing than not.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><font face="Courier" class="">+&nbsp;&nbsp;case TypeKind::Metatype: {<br class="">+&nbsp; &nbsp;&nbsp;auto metaTy = cast&lt;MetatypeType&gt;(type.getPointer());<br class="">+&nbsp; &nbsp;&nbsp;type = metaTy-&gt;getInstanceType();<br class="">+&nbsp; &nbsp;&nbsp;if (!type-&gt;isExistentialType())<br class="">+&nbsp; &nbsp; &nbsp;&nbsp;return "metatype of " + computeDiagnosticTypeKindString(type);<br class="">+&nbsp; &nbsp;&nbsp;return "concrete metatype of " + computeDiagnosticTypeKindString(type);<br class="">+&nbsp;&nbsp;}<br class="">+&nbsp;&nbsp;case TypeKind::ExistentialMetatype: {<br class="">+&nbsp; &nbsp;&nbsp;auto metaTy = cast&lt;ExistentialMetatypeType&gt;(type.getPointer());<br class="">+&nbsp; &nbsp;&nbsp;type = metaTy-&gt;getInstanceType();<br class="">+&nbsp; &nbsp;&nbsp;return "metatype of " + computeDiagnosticTypeKindString(type);<br class="">+&nbsp;&nbsp;}<br class=""></font></div></div></div></div></div></div></div></div></blockquote><div><br class=""></div><div>Interesting. &nbsp;"metatype of optional struct" for Array?.Type.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><font face="Courier" class="">+&nbsp;&nbsp;case TypeKind::ArraySlice:<br class="">+&nbsp; &nbsp;&nbsp;// we could in dig further, but then diag messages might become unwieldy<br class="">+&nbsp; &nbsp;&nbsp;return "array slice ";<br class="">+&nbsp;&nbsp;case TypeKind::Dictionary:<br class="">+&nbsp; &nbsp;&nbsp;// we could in dig further, but then diag messages would become unwieldy<br class="">+&nbsp; &nbsp;&nbsp;return "dictionary ";<br class=""></font></div></div></div></div></div></div></div></div></blockquote><div><br class=""></div>Same problem as "function".</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><font face="Courier" class="">+&nbsp;&nbsp;case TypeKind::Optional:<br class="">+&nbsp; &nbsp;&nbsp;type = type-&gt;getAnyOptionalObjectType();<br class="">+&nbsp; &nbsp;&nbsp;return "optional " + computeDiagnosticTypeKindString(type);<br class=""></font></div></div></div></div></div></div></div></div></blockquote><div><br class=""></div><div>This is interesting but could get pretty verbose.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><font face="Courier" class="">+&nbsp;&nbsp;case TypeKind::ImplicitlyUnwrappedOptional:<br class="">+&nbsp; &nbsp;&nbsp;type = type-&gt;getAnyOptionalObjectType();<br class="">+&nbsp; &nbsp;&nbsp;return "implicitly unwrapped optional "<br class="">+&nbsp; &nbsp; &nbsp;&nbsp;+ computeDiagnosticTypeKindString(type);</font></div></div></div></div></div></div></div></div></blockquote><div><br class=""></div>This is *already* pretty verbose to throw into random diagnostics.</div><div><br class=""></div><div>John.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><font face="Courier" class="">+&nbsp;&nbsp;case TypeKind::Paren:<br class="">+&nbsp; &nbsp;&nbsp;type = type-&gt;getWithoutParens();<br class="">+&nbsp; &nbsp;&nbsp;return computeDiagnosticTypeKindString(type);<br class="">+&nbsp;&nbsp;case TypeKind::Tuple: {<br class="">+&nbsp; &nbsp;&nbsp;auto tempTy = type-&gt;getWithoutImmediateLabel();<br class="">+&nbsp; &nbsp;&nbsp;if (tempTy-&gt;isEqual(type))<br class="">+&nbsp; &nbsp; &nbsp;&nbsp;return "tuple ";<br class="">+&nbsp; &nbsp;&nbsp;type = tempTy;<br class="">+&nbsp; &nbsp;&nbsp;return computeDiagnosticTypeKindString(type);<br class="">+&nbsp;&nbsp;}</font></div></div></div></div></div></div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><font face="Courier" class="">+&nbsp;&nbsp;case TypeKind::NameAlias: {<br class="">+&nbsp; &nbsp;&nbsp;// We need to stop updating our caller's 'type' at this point.<br class="">+&nbsp; &nbsp;&nbsp;auto aliasTy = cast&lt;NameAliasType&gt;(type.getPointer());<br class="">+&nbsp; &nbsp;&nbsp;Type discardTy = aliasTy-&gt;getSinglyDesugaredType();<br class="">+&nbsp; &nbsp;&nbsp;return computeDiagnosticTypeKindString(discardTy);<br class="">+&nbsp;&nbsp;}<br class="">+&nbsp;&nbsp;case TypeKind::Error: {<br class="">+&nbsp; &nbsp;&nbsp;auto errorTy = cast&lt;ErrorType&gt;(type.getPointer());<br class="">+&nbsp; &nbsp;&nbsp;if (auto origTy = errorTy-&gt;getOriginalType()) {<br class="">+&nbsp; &nbsp; &nbsp;&nbsp;type = origTy;<br class="">+&nbsp; &nbsp; &nbsp;&nbsp;return "invalid " + computeDiagnosticTypeKindString(type);<br class="">+&nbsp; &nbsp;&nbsp;}<br class="">+&nbsp; &nbsp;&nbsp;return "invalid type ";<br class="">+&nbsp;&nbsp;}</font></div><div class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp;&nbsp;</span><span style="font-family: Courier;" class="">case TypeKind::UnboundGeneric:</span><br style="font-family: Courier;" class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">switch (type-&gt;castTo&lt;UnboundGenericType&gt;()-&gt;getDecl()-&gt;getKind()) {</span><br style="font-family: Courier;" class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">case DeclKind::TypeAlias: return "typealias ";</span><br style="font-family: Courier;" class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">case DeclKind::Protocol:</span><span style="font-family: Courier;" class="">&nbsp;&nbsp;</span><span style="font-family: Courier;" class="">return "protocol ";</span><br style="font-family: Courier;" class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">case DeclKind::Struct:</span><span style="font-family: Courier;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">return "struct ";</span><br style="font-family: Courier;" class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">case DeclKind::Class:&nbsp;</span><span style="font-family: Courier;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">return "class ";</span><br style="font-family: Courier;" class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">case DeclKind::Enum:</span><span style="font-family: Courier;" class="">&nbsp; &nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">return "enum ";</span><br style="font-family: Courier;" class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">default:</span><span style="font-family: Courier;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">break;</span><br style="font-family: Courier;" class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">}</span><br style="font-family: Courier;" class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">llvm_unreachable("Unknown unbound generic");</span><br style="font-family: Courier;" class=""><font face="Courier" class="">+&nbsp;&nbsp;}</font></div><div class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp;&nbsp;</span><span style="font-family: Courier;" class="">case TypeKind::LValue: {</span><br style="font-family: Courier;" class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">// While LValues are not a part of the user visible type system, they do</span><br style="font-family: Courier;" class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">// sometimes appear inside of tuple expressions. Just ignore them.</span><br style="font-family: Courier;" class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">auto lvTy = cast&lt;LValueType&gt;(type.getPointer());</span><br style="font-family: Courier;" class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">type = lvTy-&gt;getObjectType();</span><br style="font-family: Courier;" class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">return computeDiagnosticTypeKindString(type);</span><br style="font-family: Courier;" class=""><span style="font-family: Courier;" class="">+</span><span style="font-family: Courier;" class="">&nbsp;&nbsp;</span><span style="font-family: Courier;" class="">}</span><br style="font-family: Courier;" class=""><font face="Courier" class="">+}<br class="">+<br class="">&nbsp;/// \brief Format a single diagnostic argument and write it to the given<br class="">&nbsp;/// stream.<br class="">&nbsp;static void formatDiagnosticArgument(StringRef Modifier,&nbsp;<br class="">@@ -439,16 +554,18 @@ static void formatDiagnosticArgument(StringRef Modifier,<br class="">&nbsp; &nbsp; &nbsp;<br class="">&nbsp; &nbsp; &nbsp;// Strip extraneous parentheses; they add no value.<br class="">&nbsp; &nbsp; &nbsp;auto type = Arg.getAsType()-&gt;getWithoutParens();<br class="">+&nbsp; &nbsp;&nbsp;auto origType = type-&gt;getInOutObjectType();<br class="">+&nbsp; &nbsp;&nbsp;std::string declKind = computeDiagnosticTypeKindString(type);<br class="">&nbsp; &nbsp; &nbsp;std::string typeName = type-&gt;getString();<br class="">&nbsp;<br class="">&nbsp; &nbsp; &nbsp;if (shouldShowAKA(type, typeName)) {<br class="">&nbsp; &nbsp; &nbsp; &nbsp;llvm::SmallString&lt;256&gt; AkaText;<br class="">&nbsp; &nbsp; &nbsp; &nbsp;llvm::raw_svector_ostream OutAka(AkaText);<br class="">-&nbsp; &nbsp; &nbsp;&nbsp;OutAka &lt;&lt; type-&gt;getCanonicalType();<br class="">-&nbsp; &nbsp; &nbsp;&nbsp;Out &lt;&lt; llvm::format(FormatOpts.AKAFormatString.c_str(), typeName.c_str(),<br class="">-&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;AkaText.c_str());<br class="">+&nbsp; &nbsp; &nbsp;&nbsp;OutAka &lt;&lt; origType-&gt;getCanonicalType();<br class="">+&nbsp; &nbsp; &nbsp;&nbsp;Out &lt;&lt; declKind &lt;&lt; llvm::format(FormatOpts.AKAFormatString.c_str(),<br class="">+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;typeName.c_str(), AkaText.c_str());<br class="">&nbsp; &nbsp; &nbsp;} else {<br class="">-&nbsp; &nbsp; &nbsp;&nbsp;Out &lt;&lt; FormatOpts.OpeningQuotationMark &lt;&lt; typeName<br class="">+&nbsp; &nbsp; &nbsp;&nbsp;Out &lt;&lt; declKind &lt;&lt; FormatOpts.OpeningQuotationMark &lt;&lt; typeName<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;&lt; FormatOpts.ClosingQuotationMark;<br class="">&nbsp; &nbsp; &nbsp;}<br class="">&nbsp; &nbsp; &nbsp;break;</font><br class=""></div></div></div></div></div></div></div>_______________________________________________<br class="">swift-dev mailing list<br class=""><a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-dev<br class=""></div></blockquote></div><br class=""></body></html>