@@ -2869,8 +2869,8 @@ getArgumentLabels(ConstraintSystem &cs, ConstraintLocatorBuilder locator) {
2869
2869
// / particularly fast in the face of deep class hierarchies or lots of protocol
2870
2870
// / conformances, but this is fine because it doesn't get invoked in the normal
2871
2871
// / name lookup path (only when lookup is about to fail).
2872
- static bool hasDynamicMemberLookupAttribute (Type ty,
2873
- llvm::DenseMap<Type , bool > &IsDynamicMemberLookupCache) {
2872
+ static bool hasDynamicMemberLookupAttribute (CanType ty,
2873
+ llvm::DenseMap<CanType , bool > &IsDynamicMemberLookupCache) {
2874
2874
auto it = IsDynamicMemberLookupCache.find (ty);
2875
2875
if (it != IsDynamicMemberLookupCache.end ()) return it->second ;
2876
2876
@@ -2879,7 +2879,8 @@ static bool hasDynamicMemberLookupAttribute(Type ty,
2879
2879
// have the attribute on them.
2880
2880
if (auto protocolComp = ty->getAs <ProtocolCompositionType>()) {
2881
2881
for (auto p : protocolComp->getMembers ())
2882
- if (hasDynamicMemberLookupAttribute (p, IsDynamicMemberLookupCache))
2882
+ if (hasDynamicMemberLookupAttribute (p->getCanonicalType (),
2883
+ IsDynamicMemberLookupCache))
2883
2884
return true ;
2884
2885
return false ;
2885
2886
}
@@ -2917,7 +2918,13 @@ static bool hasDynamicMemberLookupAttribute(Type ty,
2917
2918
}
2918
2919
};
2919
2920
2920
- return IsDynamicMemberLookupCache[ty] = calculate ();
2921
+ auto result = calculate ();
2922
+
2923
+ // Cache this if we can.
2924
+ if (!ty->hasTypeVariable ())
2925
+ IsDynamicMemberLookupCache[ty] = result;
2926
+
2927
+ return result;
2921
2928
}
2922
2929
2923
2930
@@ -3307,7 +3314,7 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
3307
3314
constraintKind == ConstraintKind::ValueMember &&
3308
3315
memberName.isSimpleName () && !memberName.isSpecial ()) {
3309
3316
auto name = memberName.getBaseIdentifier ();
3310
- if (hasDynamicMemberLookupAttribute (instanceTy,
3317
+ if (hasDynamicMemberLookupAttribute (instanceTy-> getCanonicalType () ,
3311
3318
IsDynamicMemberLookupCache)) {
3312
3319
auto &ctx = getASTContext ();
3313
3320
// Recursively look up the subscript(dynamicMember:)'s in this type.
0 commit comments