Issue #254: Constructors of inner classes not resolved properly

- add test case to reproduce #254
- add special case to detect constructors which were declared in the
index file set of the tu
This commit is contained in:
Dominic Scharfe 2023-01-19 14:57:27 +01:00 committed by Jonah Graham
parent 34f1736317
commit 22ee440b88
2 changed files with 25 additions and 1 deletions

View file

@ -1397,4 +1397,21 @@ public abstract class IndexCPPBindingResolutionBugsTest extends IndexBindingReso
ast = workingCopy.getAST(strategy.getIndex(), ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
checkBindings(ast);
}
// struct MyClass {
// MyClass();
// struct MyInnerClass;
// };
// struct MyClass::MyInnerClass {
// MyInnerClass(bool a, bool b) {
// }
// };
//
// MyClass::MyClass() {
// new MyInnerClass(true, true);
// }
public void testIssue_254() throws Exception {
checkBindings();
}
}

View file

@ -2125,7 +2125,14 @@ public class CPPSemantics {
}
IASTTranslationUnit tu = node.getTranslationUnit();
IIndexFileSet indexFileSet = tu.getIndexFileSet();
return (indexFileSet != null && indexFileSet.containsDeclaration(indexBinding));
if (indexFileSet != null && indexFileSet.containsDeclaration(indexBinding)) {
return true;
} else if (indexBinding instanceof ICPPConstructor) {
IIndexFileSet astFileSet = tu.getASTFileSet();
return astFileSet != null && astFileSet.containsDeclaration(indexBinding);
} else {
return false;
}
}
}
return pointOfDecl < pointOfRef;