From c272688b2db06d6fb191dc2f1d189f9f6c79545b Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Tue, 20 Jun 2017 01:14:04 +0200 Subject: [PATCH] =?UTF-8?q?Fehler=20beim=20Ausrechnen=20zusammenh=C3=A4nge?= =?UTF-8?q?nder=20Constraints=20beheben?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../typedeployment/TypeInsertFactory.java | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/de/dhbwstuttgart/typedeployment/TypeInsertFactory.java b/src/de/dhbwstuttgart/typedeployment/TypeInsertFactory.java index 9d9147eb..e6ae0229 100644 --- a/src/de/dhbwstuttgart/typedeployment/TypeInsertFactory.java +++ b/src/de/dhbwstuttgart/typedeployment/TypeInsertFactory.java @@ -73,40 +73,31 @@ public class TypeInsertFactory { } } //Alle Bounds finden: - Map newGenerics = new HashMap<>(); - Set additionalBoundInserts = new HashSet<>(); + Set newGenerics = new HashSet<>(); boolean added = true; while(added){ added = false; - additionalInserts.addAll(additionalBoundInserts); - for(TypePlaceholder tph : additionalInserts){ - boolean foundPair = false; - for(Pair pair : pairs){ - if (pair.TA1.equals(tph) || pair.TA2.equals(tph)) { - newGenerics.put((TypePlaceholder) pair.TA1, (TypePlaceholder) pair.TA2); - foundPair = true; - added |= additionalBoundInserts.add((TypePlaceholder) pair.TA1); - added |= additionalBoundInserts.add((TypePlaceholder) pair.TA2); - } - } - if(foundPair == false){ - newGenerics.put(tph, null); + for(Pair pair : pairs){ + if (additionalInserts.contains(pair.TA1) || additionalInserts.contains(pair.TA2)) { + newGenerics.add(pair); + added |= additionalInserts.add((TypePlaceholder) pair.TA1); + added |= additionalInserts.add((TypePlaceholder) pair.TA2); } } } //Alle TPHs die man noch als Generics anfügen muss einsetzen: additionalInserts.clear(); - for(TypePlaceholder tph : newGenerics.values()){ - if(! newGenerics.containsKey(tph)){ - additionalInserts.add(tph); + for(Pair subtypings : newGenerics){ + if(additionalInserts.contains(subtypings.TA1)){ + additionalInserts.remove(subtypings.TA1); } } for(TypePlaceholder tph : additionalInserts){ - newGenerics.put(tph, null); + newGenerics.add(new Pair(tph, null)); } - for(TypePlaceholder tph : newGenerics.keySet()){ - ret.add(createGenericInsert(tph, newGenerics.get(tph), cl, m)); + for(Pair subtyping : newGenerics){ + ret.add(createGenericInsert((TypePlaceholder)subtyping.TA1, (TypePlaceholder)subtyping.TA2, cl, m)); } return ret;