@@ -1764,13 +1764,64 @@ bool TypeSystemSwiftTypeRef::IsFunctionPointerType(
17641764 VALIDATE_AND_RETURN (impl, IsFunctionPointerType, type,
17651765 (ReconstructType (type)));
17661766}
1767+
17671768bool TypeSystemSwiftTypeRef::IsPossibleDynamicType (opaque_compiler_type_t type,
17681769 CompilerType *target_type,
17691770 bool check_cplusplus,
17701771 bool check_objc) {
1771- return m_swift_ast_context->IsPossibleDynamicType (
1772- ReconstructType (type), target_type, check_cplusplus, check_objc);
1772+ if (target_type)
1773+ target_type->Clear ();
1774+
1775+ if (!type)
1776+ return false ;
1777+
1778+ // This is a discrepancy with `SwiftASTContext`. The `impl` below correctly
1779+ // returns true, but `VALIDATE_AND_RETURN` will assert. This hardcoded
1780+ // handling of `__C.NSNotificationName` can be removed when the
1781+ // `VALIDATE_AND_RETURN` is removed.
1782+ if (GetMangledTypeName (type) == " $sSo18NSNotificationNameaD" )
1783+ return true ;
1784+
1785+ auto impl = [&]() {
1786+ using namespace swift ::Demangle;
1787+ Demangler dem;
1788+ auto *node = DemangleCanonicalType (dem, type);
1789+ if (!node)
1790+ return false ;
1791+
1792+ if (node->getKind () == Node::Kind::TypeAlias) {
1793+ auto resolved = ResolveTypeAlias (m_swift_ast_context, dem, node);
1794+ if (auto *n = std::get<swift::Demangle::NodePointer>(resolved))
1795+ node = n;
1796+ }
1797+
1798+ switch (node->getKind ()) {
1799+ case Node::Kind::Class:
1800+ case Node::Kind::BoundGenericClass:
1801+ case Node::Kind::Protocol:
1802+ case Node::Kind::ProtocolList:
1803+ case Node::Kind::ProtocolListWithClass:
1804+ case Node::Kind::ProtocolListWithAnyObject:
1805+ case Node::Kind::ExistentialMetatype:
1806+ case Node::Kind::DynamicSelf:
1807+ return true ;
1808+ case Node::Kind::BuiltinTypeName: {
1809+ if (!node->hasText ())
1810+ return false ;
1811+ StringRef name = node->getText ();
1812+ return name == swift::BUILTIN_TYPE_NAME_RAWPOINTER ||
1813+ name == swift::BUILTIN_TYPE_NAME_NATIVEOBJECT ||
1814+ name == swift::BUILTIN_TYPE_NAME_BRIDGEOBJECT;
1815+ }
1816+ default :
1817+ return ContainsGenericTypeParameter (node);
1818+ }
1819+ };
1820+ VALIDATE_AND_RETURN (
1821+ impl, IsPossibleDynamicType, type,
1822+ (ReconstructType (type), nullptr , check_cplusplus, check_objc));
17731823}
1824+
17741825bool TypeSystemSwiftTypeRef::IsPointerType (opaque_compiler_type_t type,
17751826 CompilerType *pointee_type) {
17761827 auto impl = [&]() {
0 commit comments