Skip to content

Commit 7cfe707

Browse files
DougGregorlorentey
authored andcommitted
Cope with the possibility of overloaded "pointee" members
This can happen if we end up introducing separate ABI vs. always-emit-into-client versions. (cherry picked from commit 62f201f)
1 parent 88a93a5 commit 7cfe707

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

lib/AST/ASTContext.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,16 +1109,24 @@ static VarDecl *getPointeeProperty(VarDecl *&cache,
11091109
// There must be a property named "pointee".
11101110
auto identifier = ctx.getIdentifier("pointee");
11111111
auto results = nominal->lookupDirect(identifier);
1112-
if (results.size() != 1) return nullptr;
1112+
for (auto result : results) {
1113+
// The property must have type T.
1114+
auto *property = dyn_cast<VarDecl>(result);
1115+
if (!property)
1116+
continue;
11131117

1114-
// The property must have type T.
1115-
auto *property = dyn_cast<VarDecl>(results[0]);
1116-
if (!property) return nullptr;
1117-
if (!property->getInterfaceType()->isEqual(sig.getGenericParams()[0]))
1118-
return nullptr;
1118+
if (!property->getInterfaceType()->isEqual(sig.getGenericParams()[0]))
1119+
continue;
11191120

1120-
cache = property;
1121-
return property;
1121+
if (property->getFormalAccess() != AccessLevel::Public)
1122+
continue;
1123+
1124+
cache = property;
1125+
return property;
1126+
}
1127+
1128+
llvm_unreachable("Could not find pointee property");
1129+
return nullptr;
11221130
}
11231131

11241132
VarDecl *

0 commit comments

Comments
 (0)