[Clang importer] Infer get-only properties and static properties.

Expands support for inference of computed properties, whether instance
or static, to include get-only. Adds test cases for both inference and
manual annotation for static computed properties.
This commit is contained in:
Michael Ilseman
2016-03-07 16:51:34 -08:00
parent c39aebce24
commit 73f7fd2eb6
6 changed files with 34 additions and 8 deletions

View File

@@ -407,10 +407,16 @@ IAMResult IAMInference::infer(const clang::NamedDecl *clangDecl) {
// See if it's a property
for (auto propSpec : PropertySpecifiers) {
NameBuffer propName;
if (match(remainingName, propSpec, propName))
if (auto pair = findPairedAccessor(workingName, propSpec))
if (match(remainingName, propSpec, propName)) {
if (auto pair = findPairedAccessor(workingName, propSpec)) {
return importAsInstanceProperty(propName, propSpec, selfIdx,
nonSelfParams, pair, effectiveDC);
} else if (propSpec == "Get") {
return importAsInstanceProperty(propName, propSpec, selfIdx,
nonSelfParams, nullptr,
effectiveDC);
}
}
}
return importAsInstanceMethod(remainingName, selfIdx, nonSelfParams,
@@ -433,10 +439,16 @@ IAMResult IAMInference::infer(const clang::NamedDecl *clangDecl) {
// See if it's a property
for (auto propSpec : PropertySpecifiers) {
NameBuffer propName;
if (match(remainingName, propSpec, propName))
if (auto pair = findPairedAccessor(workingName, propSpec))
if (match(remainingName, propSpec, propName)) {
if (auto pair = findPairedAccessor(workingName, propSpec)) {
return importAsStaticProperty(propName, propSpec, nonSelfParams, pair,
effectiveDC);
} else if (propSpec == "Get") {
return importAsStaticProperty(propName, propSpec, nonSelfParams,
nullptr, effectiveDC);
}
}
}
return importAsStaticMethod(remainingName, nonSelfParams, effectiveDC);