mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user