diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index 414ffe90f10..e1458248263 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -1630,4 +1630,31 @@ public class AST2TemplateTests extends AST2BaseTest { assertSame( foo, col.getName(39).resolveBinding() ); assertSame( foo, col.getName(41).resolveBinding() ); } + + public void testBug98961() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append("class B { int i; }; \n"); //$NON-NLS-1$ + buffer.append("template class A { \n"); //$NON-NLS-1$ + buffer.append(" typedef T* _T; \n"); //$NON-NLS-1$ + buffer.append("}; \n"); //$NON-NLS-1$ + buffer.append("void f(){ \n"); //$NON-NLS-1$ + buffer.append(" A::_T t; \n"); //$NON-NLS-1$ + buffer.append(" (*t).i; \n"); //$NON-NLS-1$ + buffer.append("} \n"); //$NON-NLS-1$ + + IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP ); + CPPNameCollector col = new CPPNameCollector(); + tu.accept( col ); + + ICPPClassType B = (ICPPClassType) col.getName(0).resolveBinding(); + ICPPField i = (ICPPField) col.getName(1).resolveBinding(); + ITypedef _T = (ITypedef) col.getName(5).resolveBinding(); + ICPPVariable t = (ICPPVariable) col.getName(12).resolveBinding(); + + IType type = t.getType(); + assertTrue( type instanceof ICPPSpecialization ); + assertSame( ((ICPPSpecialization)type).getSpecializedBinding(), _T ); + + assertSame( i, col.getName(14).resolveBinding() ); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedefSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedefSpecialization.java index cc863a7125b..40ecbbf5d2d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedefSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedefSpecialization.java @@ -22,13 +22,14 @@ import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.parser.util.ObjectMap; +import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTypedef.CPPTypedefDelegate; /** * @author aniefer */ public class CPPTypedefSpecialization extends CPPSpecialization implements - ITypedef { + ITypedef, ITypeContainer { private IType type = null; /** @@ -58,13 +59,13 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements * @see java.lang.Object#clone() */ public Object clone() { -// IType t = null; -// try { -// t = (IType) super.clone(); -// } catch ( CloneNotSupportedException e ) { -// //not going to happen -// } - return this; + IType t = null; + try { + t = (IType) super.clone(); + } catch ( CloneNotSupportedException e ) { + //not going to happen + } + return t; } /* (non-Javadoc) @@ -100,4 +101,8 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements return new CPPTypedefDelegate( name, this ); } + public void setType(IType type) { + this.type = type; + } + }