ClassElement definingClass = element.getAncestor(ClassElement.class);
if (definingClass != null) {
aliasElement.shareTypeParameters(definingClass.getTypeParameters());
type.setTypeArguments(definingClass.getType().getTypeArguments());
} else {
FunctionTypeAliasElement alias = element.getAncestor(FunctionTypeAliasElement.class);
while (alias != null && alias.isSynthetic()) {
alias = alias.getAncestor(FunctionTypeAliasElement.class);
}
if (alias != null) {
aliasElement.setTypeParameters(alias.getTypeParameters());
type.setTypeArguments(alias.getType().getTypeArguments());
} else {
type.setTypeArguments(TypeImpl.EMPTY_ARRAY);
}
}
element.setType(type);