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

Bug 511427 - ClassCastException in CompositeCPPClassType.wrapBindings()

Change-Id: Id02d59a67b98131aaa4afc8936f89d0985ef93cf
This commit is contained in:
Nathan Ridge 2017-01-31 19:56:59 -05:00
parent 27775e3393
commit 0d35254d82
2 changed files with 20 additions and 2 deletions

View file

@ -12,11 +12,14 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.core.runtime.CoreException;
/**
@ -130,4 +133,19 @@ public abstract class CompositeIndexBinding implements IIndexBinding {
public IIndexBinding getRawBinding() {
return rbinding;
}
protected IIndexFragmentBinding adaptBinding(IBinding binding) {
if (binding instanceof IIndexFragmentBinding) {
return (IIndexFragmentBinding) binding;
}
ILinkage linkage = rbinding.getLinkage();
if (linkage instanceof PDOMLinkage) {
try {
return ((PDOMLinkage) linkage).adaptBinding(binding);
} catch(CoreException e) {
CCorePlugin.log(e);
}
}
return null;
}
}

View file

@ -30,7 +30,6 @@ 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.ICPPUsingDeclaration;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
@ -213,7 +212,8 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
protected <T extends IBinding> T[] wrapBindings(T[] bindings) {
T[] result = Arrays.copyOf(bindings, bindings.length);
for (int i= 0; i < bindings.length; i++) {
result[i] = (T) cf.getCompositeBinding((IIndexFragmentBinding) bindings[i]);
// Cannot assume the incoming binding is an index binding in all cases.
result[i] = (T) cf.getCompositeBinding(adaptBinding(bindings[i]));
}
return result;
}