Skip to content

Commit

Permalink
solved issue 48 - problem with mix of any and abstract types
Browse files Browse the repository at this point in the history
  • Loading branch information
willemdj committed Dec 9, 2015
1 parent 6c27fa5 commit 4472cd4
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/erlsom_write.erl
Original file line number Diff line number Diff line change
Expand Up @@ -352,17 +352,17 @@ findAlternative(RecordType, Alternatives, #model{th = TypeHierarchy} = Model, Ab
case lists:keysearch(RecordType, #alt.tp, Alternatives) of
{value, Alternative} -> {Alternative, Abstract};
_ ->
%% see whether an ancestor in the type hierarchy is among the alternatives
case erlsom_lib:getAncestor(RecordType, TypeHierarchy) of
{value, Ancestor} ->
findAlternative(Ancestor, Alternatives, Model, true);
_ ->
%% see whether this is an '#any' type
case Alternatives of
[#alt{tag='#any', anyInfo = #anyInfo{ns = AltNs}}] when AltNs /= "##other" ->
AnyAlternatives = Alternatives ++ erlsom_lib:documentAlternatives(Model),
findAlternative(RecordType, AnyAlternatives, Model, Abstract);
_ ->
%% see whether this is an '#any' type
case Alternatives of
[#alt{tag='#any', anyInfo = #anyInfo{ns = AltNs}}] when AltNs /= "##other" ->
AnyAlternatives = Alternatives ++ erlsom_lib:documentAlternatives(Model),
findAlternative(RecordType, AnyAlternatives, Model, Abstract);
_ ->
%% see whether an ancestor in the type hierarchy is among the alternatives
case erlsom_lib:getAncestor(RecordType, TypeHierarchy) of
{value, Ancestor} ->
findAlternative(Ancestor, Alternatives, Model, true);
_ ->
throw({error, "Struct doesn't match model: recordtype not expected: " ++ atom_to_list(RecordType)})
end
end
Expand Down

0 comments on commit 4472cd4

Please sign in to comment.