DynamicTypeImpl dynamicType = DynamicTypeImpl.getInstance();
SimpleIdentifier nameIdentifier = new SimpleIdentifier(new StringToken(
TokenType.IDENTIFIER,
name,
0));
ExecutableElementImpl executable;
if (elementArrayToMerge[0] instanceof MethodElement) {
MultiplyInheritedMethodElementImpl unionedMethod = new MultiplyInheritedMethodElementImpl(
nameIdentifier);
unionedMethod.setInheritedElements(elementArrayToMerge);
executable = unionedMethod;
} else {
MultiplyInheritedPropertyAccessorElementImpl unionedPropertyAccessor = new MultiplyInheritedPropertyAccessorElementImpl(
nameIdentifier);
unionedPropertyAccessor.setGetter(((PropertyAccessorElement) elementArrayToMerge[0]).isGetter());
unionedPropertyAccessor.setSetter(((PropertyAccessorElement) elementArrayToMerge[0]).isSetter());
unionedPropertyAccessor.setInheritedElements(elementArrayToMerge);
executable = unionedPropertyAccessor;
}
int numOfParameters = numOfRequiredParameters + numOfPositionalParameters
+ namedParameters.length;
ParameterElement[] parameters = new ParameterElement[numOfParameters];
int i = 0;
for (int j = 0; j < numOfRequiredParameters; j++, i++) {
ParameterElementImpl parameter = new ParameterElementImpl("", 0);
parameter.setType(dynamicType);
parameter.setParameterKind(ParameterKind.REQUIRED);
parameters[i] = parameter;
}
for (int k = 0; k < numOfPositionalParameters; k++, i++) {
ParameterElementImpl parameter = new ParameterElementImpl("", 0);
parameter.setType(dynamicType);
parameter.setParameterKind(ParameterKind.POSITIONAL);
parameters[i] = parameter;
}
for (int m = 0; m < namedParameters.length; m++, i++) {
ParameterElementImpl parameter = new ParameterElementImpl(namedParameters[m], 0);
parameter.setType(dynamicType);
parameter.setParameterKind(ParameterKind.NAMED);
parameters[i] = parameter;
}
executable.setReturnType(dynamicType);
executable.setParameters(parameters);
FunctionTypeImpl methodType = new FunctionTypeImpl(executable);
executable.setType(methodType);
return executable;
}