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