mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 19:35:36 +02:00
Fixed "UnsupportedOperationException: addMember method should be called
instead" error.
This commit is contained in:
parent
fab1e9757c
commit
17bf8f55f1
1 changed files with 15 additions and 3 deletions
|
@ -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.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
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.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.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||||
|
@ -114,16 +115,27 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
||||||
|
|
||||||
IBinding[] bindings= classScope.getBindings(lookup);
|
IBinding[] bindings= classScope.getBindings(lookup);
|
||||||
IBinding[] result= IBinding.EMPTY_BINDING_ARRAY;
|
IBinding[] result= IBinding.EMPTY_BINDING_ARRAY;
|
||||||
|
int n = 0;
|
||||||
for (IBinding binding : bindings) {
|
for (IBinding binding : bindings) {
|
||||||
if (binding == specialized ||
|
if (binding == specialized ||
|
||||||
(binding instanceof ICPPClassType && specialized.isSameType((IType) binding))) {
|
(binding instanceof ICPPClassType && areSameTypesModuloPartialSpecialization(specialized, (IType) binding))) {
|
||||||
binding= specialClass;
|
binding= specialClass;
|
||||||
} else {
|
} else {
|
||||||
binding= specialClass.specializeMember(binding, lookup.getLookupPoint());
|
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
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue