diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java index 080ebeb2c45..fc24aa2a71f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java @@ -524,7 +524,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa // class D {}; // template // class D {}; - public void _testClassPartialSpecializations() throws Exception { + public void testClassPartialSpecializations() throws Exception { IBinding b0= getBindingFromASTName("D", 8); IBinding b1= getBindingFromASTName("D", 8); IBinding b2= getBindingFromASTName("D", 8); @@ -919,7 +919,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa // class Foo {}; // // Foo b2; - public void _testClassSpecializations_180738() { + public void testClassSpecializations_180738() { IBinding b1a = getBindingFromASTName("Foo b1;", 3); IBinding b1b = getBindingFromASTName("Foo b1;", 6); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 9bc3d4d63a7..1ee91b454c2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -1563,9 +1563,8 @@ public class CPPSemantics { return null; // specialization is selected during instantiation - // mstodo why not? -// if (candidate instanceof ICPPTemplateInstance && candidate instanceof IType) -// candidate= ((ICPPTemplateInstance) candidate).getSpecializedBinding(); + if (candidate instanceof ICPPTemplateInstance && candidate instanceof IType) + candidate= ((ICPPTemplateInstance) candidate).getSpecializedBinding(); return candidate; } @@ -1720,11 +1719,6 @@ public class CPPSemantics { continue; } - // specialization is selected during instantiation - // mstodo why not? -// if (temp instanceof ICPPTemplateInstance && temp instanceof IType) -// temp= ((ICPPTemplateInstance) temp).getSpecializedBinding(); - // select among those bindings that have been created without problems. if (temp instanceof IProblemBinding) continue; @@ -1764,12 +1758,18 @@ public class CPPSemantics { } } } else if (temp instanceof IType) { + // specializations are selected during instantiation + if (temp instanceof ICPPClassTemplatePartialSpecialization) + continue; + if (temp instanceof ICPPTemplateInstance) { + temp= ((ICPPTemplateInstance) temp).getSpecializedBinding(); + if (!(temp instanceof IType)) + continue; + } + if (type == null) { type = temp; - } else if (type instanceof ICPPClassTemplate && temp instanceof ICPPSpecialization && - ((IType) type).isSameType((IType) ((ICPPSpecialization)temp).getSpecializedBinding())) { - // ok, stay with the template, the specialization, if applicable, will come out during instantiation - } else if (type != temp && !((IType)type).isSameType((IType) temp)) { + } else if (type != temp && !((IType)type).isSameType((IType) temp)) { return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name()); } } else {