Skip to content

Commit

Permalink
Issue #254: Constructors of inner classes not resolved properly
Browse files Browse the repository at this point in the history
- add test case to reproduce #254
- add special case to detect constructors which were declared in the
index file set of the tu
  • Loading branch information
ddscharfe authored and jonahgraham committed Jan 28, 2023
1 parent 34f1736 commit 22ee440
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1397,4 +1397,21 @@ public void testTemplateArgumentResolution_450888() throws Exception {
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2125,7 +2125,14 @@ public static boolean declaredBefore(Object obj, IASTNode node, boolean indexBas
}
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;
Expand Down

0 comments on commit 22ee440

Please sign in to comment.