mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Runtime: Do awful things to implement "swift_conformsToProtocol" for Swift protocols.
Given our constraints for 1.0, we can actually sort-of look up protocol conformances just by dlsym'ing the symbol for their protocol witness table, since we won't be implementing runtime witness table instantiation or private conformances anytime soon. To make this work for generic types, distastefully regress our mangling for protocol conformances by assuming all generic conformances are completely general to the unbound generic type and leave the generic parameters out of the mangling. Swift SVN r13901
This commit is contained in:
@@ -1247,17 +1247,26 @@ void Mangler::mangleProtocolConformance(ProtocolConformance *conformance) {
|
||||
// protocol-conformance ::= ('U' generic-parameter+ '_')?
|
||||
// type protocol module
|
||||
// FIXME: explosion level?
|
||||
|
||||
|
||||
CanType type = conformance->getType()->getCanonicalType();
|
||||
// FIXME: Assume that all generic conformances add no additional constraints
|
||||
// to the conforming type's generic parameters and swallow them. This makes
|
||||
// it easier for our hacked-up implementation of swift_conformsToProtocol
|
||||
// to find them.
|
||||
if (conformance->getGenericParams())
|
||||
type = UnboundGenericType::get(type->getNominalOrBoundGenericNominal(),
|
||||
nullptr,
|
||||
type->getASTContext())->getCanonicalType();
|
||||
#if 0
|
||||
ContextStack context(*this);
|
||||
|
||||
// If the conformance is generic, mangle its generic parameters.
|
||||
if (auto gp = conformance->getGenericParams()) {
|
||||
Buffer << 'U';
|
||||
bindGenericParameters(gp, /*mangle*/ true);
|
||||
}
|
||||
#endif
|
||||
|
||||
mangleType(conformance->getType()->getCanonicalType(),
|
||||
ResilienceExpansion::Minimal, 0);
|
||||
mangleType(type, ResilienceExpansion::Minimal, 0);
|
||||
mangleProtocolName(conformance->getProtocol());
|
||||
mangleModule(conformance->getDeclContext()->getParentModule());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user