diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/HeuristicResolver.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/HeuristicResolver.java index b5d48fcfbb2..ba3dc410815 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/HeuristicResolver.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/HeuristicResolver.java @@ -512,7 +512,7 @@ public class HeuristicResolver { */ public static IBinding[] resolveUnknownBinding(ICPPUnknownBinding binding) { if (binding instanceof ICPPDeferredClassInstance) { - return new IBinding[] { ((ICPPDeferredClassInstance) binding).getClassTemplate() }; + return new IBinding[] { chooseTemplateForDeferredInstance((ICPPDeferredClassInstance) binding) }; } else if (binding instanceof ICPPUnknownMember) { Set lookupSet = new HashSet<>(); return lookInside(((ICPPUnknownMember) binding).getOwnerType(), false, diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java index e26473f76d4..6425171d0cb 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java @@ -45,6 +45,7 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.FileManager; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase; import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction; @@ -1353,15 +1354,41 @@ public class CPPSelectionTestsNoIndexer extends BaseSelectionTests { public void testDependentAutoType_520913() throws Exception { String code = getAboveComment(); IFile file = importFile("testBug520913a.cpp", code); - + int offset = code.indexOf("auto test = ") + 2; IASTNode target = testF3(file, offset); assertInstance(target, IASTName.class); assertEquals("AA", ((IASTName) target).toString()); - + offset = code.indexOf("auto test()") + 2; target = testF3(file, offset); assertInstance(target, IASTName.class); assertEquals("AA", ((IASTName) target).toString()); } + + // template + // struct A {}; + // + // template<> + // struct A<0> {}; + // + // void test(){ + // A<0> a0; + // A<1> a1; + // } + public void testPartialSpecializationResolution_525288() throws Exception { + CPPASTNameBase.sAllowNameComputation = true; + String code = getAboveComment(); + IFile file = importFile("testBug525288.cpp", code); + + int offset = code.indexOf("a0") - 5; + IASTNode target = testF3(file, offset); + assertInstance(target, IASTName.class); + assertEquals("A<0>", ((IASTName) target).toString()); + + offset = code.indexOf("a1") - 5; + target = testF3(file, offset); + assertInstance(target, IASTName.class); + assertEquals("A", ((IASTName) target).toString()); + } }