1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Fixed "UnsupportedOperationException: addMember method should be called

instead" error.
This commit is contained in:
Sergey Prigogin 2014-05-07 16:23:49 -07:00
parent fab1e9757c
commit 17bf8f55f1

View file

@ -28,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
@ -114,16 +115,27 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
IBinding[] bindings= classScope.getBindings(lookup);
IBinding[] result= IBinding.EMPTY_BINDING_ARRAY;
int n = 0;
for (IBinding binding : bindings) {
if (binding == specialized ||
(binding instanceof ICPPClassType && specialized.isSameType((IType) binding))) {
(binding instanceof ICPPClassType && areSameTypesModuloPartialSpecialization(specialized, (IType) binding))) {
binding= specialClass;
} else {
binding= specialClass.specializeMember(binding, lookup.getLookupPoint());
}
result = ArrayUtil.append(result, binding);
result = ArrayUtil.appendAt(result, n++, binding);
}
return ArrayUtil.trim(result);
return ArrayUtil.trim(result, n);
}
private static boolean areSameTypesModuloPartialSpecialization(IType type1, IType type2) {
while (type1 instanceof ICPPClassTemplatePartialSpecialization) {
type1 = ((ICPPClassTemplatePartialSpecialization) type1).getPrimaryClassTemplate();
}
while (type2 instanceof ICPPClassTemplatePartialSpecialization) {
type2 = ((ICPPClassTemplatePartialSpecialization) type2).getPrimaryClassTemplate();
}
return type1.isSameType(type2);
}
@Override