[AST] Enable commented-out optimization for associated-type access.

A while ago, we commented-out an obvious optimization when accessing the
associated types of a protocol conformance to get better coverage of the
general substitution path. Bring that code back, avoiding the creation of
substitution maps in a few cases.
This commit is contained in:
Doug Gregor
2017-11-19 22:44:56 -08:00
parent a2c05130ef
commit af083791e8

View File

@@ -609,20 +609,19 @@ Type ProtocolConformanceRef::getAssociatedType(Type conformingType,
auto type = assocType->getCanonicalType();
auto proto = getRequirement();
#if false
// Fast path for generic parameters.
if (isa<GenericTypeParamType>(type)) {
assert(type->isEqual(proto->getSelfInterfaceType()) &&
"type parameter in protocol was not Self");
return getType();
return conformingType;
}
// Fast path for dependent member types on 'Self' of our associated types.
auto memberType = cast<DependentMemberType>(type);
if (memberType.getBase()->isEqual(proto->getProtocolSelfType()) &&
memberType->getAssocType()->getProtocol() == proto)
return getTypeWitness(memberType->getAssocType(), nullptr);
#endif
memberType->getAssocType()->getProtocol() == proto &&
isConcrete())
return getConcrete()->getTypeWitness(memberType->getAssocType(), resolver);
// General case: consult the substitution map.
auto substMap =