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