mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Produce specialized conformances to AnyObject for bound generic types.
Fixes rdar://31910351 (SR-4750)
This commit is contained in:
@@ -159,7 +159,13 @@ ProtocolConformanceRef::subst(Type origType,
|
||||
SmallVector<ProtocolConformance *, 1> lookupResults;
|
||||
classDecl->lookupConformance(classDecl->getParentModule(), proto,
|
||||
lookupResults);
|
||||
return ProtocolConformanceRef(lookupResults.front());
|
||||
auto *conf = lookupResults.front();
|
||||
auto subMap = substType->getContextSubstitutionMap(
|
||||
conf->getDeclContext()->getParentModule(), conf->getDeclContext());
|
||||
if (!subMap.empty())
|
||||
conf = substType->getASTContext().getSpecializedConformance(substType,
|
||||
conf, subMap);
|
||||
return ProtocolConformanceRef(conf);
|
||||
}
|
||||
|
||||
llvm_unreachable("Invalid conformance substitution");
|
||||
|
||||
@@ -116,7 +116,9 @@ Type SubstitutionMap::lookupSubstitution(CanSubstitutableType type) const {
|
||||
auto genericParam = cast<GenericTypeParamType>(type);
|
||||
auto mutableThis = const_cast<SubstitutionMap *>(this);
|
||||
auto replacementTypes = mutableThis->getReplacementTypes();
|
||||
auto genericParams = getGenericSignature()->getGenericParams();
|
||||
auto genericSig = getGenericSignature();
|
||||
assert(genericSig);
|
||||
auto genericParams = genericSig->getGenericParams();
|
||||
auto replacementIndex =
|
||||
GenericParamKey(genericParam).findIndexIn(genericParams);
|
||||
|
||||
@@ -133,7 +135,6 @@ Type SubstitutionMap::lookupSubstitution(CanSubstitutableType type) const {
|
||||
// The generic parameter may have been made concrete by the generic signature,
|
||||
// substitute into the concrete type.
|
||||
ModuleDecl &anyModule = *genericParam->getASTContext().getStdlibModule();
|
||||
auto genericSig = getGenericSignature();
|
||||
if (auto concreteType = genericSig->getConcreteType(genericParam, anyModule)){
|
||||
// Set the replacement type to an error, to block infinite recursion.
|
||||
replacementType = ErrorType::get(concreteType);
|
||||
|
||||
Reference in New Issue
Block a user