Skip to content

Commit

Permalink
change the parents of an EolUnionType
Browse files Browse the repository at this point in the history
  • Loading branch information
pkourouklidis committed Dec 3, 2024
1 parent a17459d commit e598e37
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,17 @@ public boolean isAbstract() {
}

@Override
public List<EolType> getParentTypes(){
return new ArrayList<EolType>(containedTypes);
public List<EolType> getParentTypes() {
Set<EolType> parentsOfContained = containedTypes.stream().flatMap(t -> t.getParentTypes().stream())
.collect(Collectors.toSet());
if (parentsOfContained.size() == 1) {
return new ArrayList<EolType>(parentsOfContained);
} else {
EolUnionType t = new EolUnionType(parentsOfContained);
List<EolType> r = new ArrayList<EolType>();
r.add(t);
return r;
}
}

@Override
Expand Down

0 comments on commit e598e37

Please sign in to comment.