2424import java .util .ArrayList ;
2525import java .util .Collection ;
2626import java .util .Collections ;
27+ import java .util .Comparator ;
2728import java .util .HashMap ;
2829import java .util .HashSet ;
2930import java .util .List ;
@@ -188,7 +189,16 @@ public boolean isImplicitGeneralTypesEmpty() {
188189 }
189190
190191 public Collection <EClass > getImplicitGeneralTypeKinds () {
191- return implicitGeneralTypes .keySet ();
192+ // Sort keys, to ensure a deterministic ordering of implied specializations
193+ // for implicit general types.
194+ List <EClass > keyList = new ArrayList <>(implicitGeneralTypes .keySet ());
195+ Collections .sort (keyList , new Comparator <EClass >() {
196+ @ Override
197+ public int compare (EClass c1 , EClass c2 ) {
198+ return Integer .compare (c1 .getClassifierID (), c2 .getClassifierID ());
199+ }
200+ });
201+ return keyList ;
192202 }
193203
194204 public void forEachImplicitBindingConnector (Consumer <BindingConnector > consumer ) {
@@ -211,13 +221,15 @@ public void forEachImplicitBindingConnector(BiConsumer<BindingConnector, EClass>
211221
212222 public List <Type > getImplicitGeneralTypes () {
213223 computeImplicitGeneralTypes ();
214- return implicitGeneralTypes .values ().stream ().
224+
225+ return getImplicitGeneralTypeKinds ().stream ().
226+ map (implicitGeneralTypes ::get ).
215227 flatMap (Collection ::stream ).
216228 collect (Collectors .toList ());
217229 }
218230
219231 public List <Type > getImplicitGeneralTypes (EClass eClass ) {
220- return implicitGeneralTypes . keySet ().stream ().
232+ return getImplicitGeneralTypeKinds ().stream ().
221233 filter (eClass ::isSuperTypeOf ).
222234 flatMap (keyClass ->getImplicitGeneralTypesOnly (keyClass ).stream ()).
223235 collect (Collectors .toList ());
@@ -258,7 +270,7 @@ public void removeImplicitGeneralType(EClass eClass) {
258270 }
259271
260272 public void forEachImplicitGeneralType (BiConsumer <EClass , Type > action ) {
261- for (EClass eClass : implicitGeneralTypes . keySet ()) {
273+ for (EClass eClass : getImplicitGeneralTypeKinds ()) {
262274 for (Type supertype : implicitGeneralTypes .get (eClass )) {
263275 action .accept (eClass , supertype );
264276 }
0 commit comments