1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

ClassCastException creating type for instance of constructor template, bug 239586.

This commit is contained in:
Markus Schorn 2008-07-08 14:08:28 +00:00
parent a241c040a7
commit 00398ac145
4 changed files with 39 additions and 26 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2006 IBM Corporation and others.
* Copyright (c) 2005, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -9,9 +9,6 @@
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Apr 29, 2005
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
@ -20,7 +17,9 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
@ -68,9 +67,10 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization
}
public ICPPClassType getClassOwner() throws DOMException {
ICPPMethod f = (ICPPMethod) getSpecializedBinding();
if( f != null )
return f.getClassOwner();
IScope scope= getScope();
if (scope instanceof ICPPClassScope) {
return ((ICPPClassScope) scope).getClassType();
}
return null;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2006 IBM Corporation and others.
* Copyright (c) 2005, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -9,16 +9,16 @@
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Apr 29, 2005
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.parser.util.ObjectMap;
/**
@ -51,9 +51,13 @@ public class CPPMethodTemplateSpecialization extends
}
public ICPPClassType getClassOwner() throws DOMException {
IBinding m = getSpecializedBinding();
if( m instanceof ICPPMethod )
return ((ICPPMethod)m).getClassOwner();
IScope scope= getScope();
if (scope instanceof ICPPTemplateScope) {
scope= scope.getParent();
}
if( scope instanceof ICPPClassScope ){
return ((ICPPClassScope)scope).getClassType();
}
return null;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 QNX Software Systems and others.
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -12,6 +12,8 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
@ -101,9 +103,10 @@ class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization
}
public ICPPClassType getClassOwner() throws DOMException {
ICPPMethod f = (ICPPMethod) getSpecializedBinding();
if( f != null )
return f.getClassOwner();
IScope scope= getScope();
if (scope instanceof ICPPClassScope) {
return ((ICPPClassScope) scope).getClassType();
}
return null;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 QNX Software Systems and others.
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -13,9 +13,12 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@ -79,9 +82,12 @@ class PDOMCPPMethodTemplateSpecialization extends
}
public ICPPClassType getClassOwner() throws DOMException {
IBinding spec = getSpecializedBinding();
if (spec instanceof ICPPMethod) {
((ICPPMethod)spec).getClassOwner();
IScope scope= getScope();
if (scope instanceof ICPPTemplateScope) {
scope= scope.getParent();
}
if( scope instanceof ICPPClassScope ){
return ((ICPPClassScope)scope).getClassType();
}
return null;
}