From 1b1a690212605cd30a6b2be2783f4bd7596e3701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pl=C3=BCmicke?= Date: Fri, 30 Jan 2015 16:12:25 +0100 Subject: [PATCH] Unify.subunify wildcards werden entfernt, wenn sie auf beiden Seiten identisch sind --- .../typeinference/unify/Unify.java | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/de/dhbwstuttgart/typeinference/unify/Unify.java b/src/de/dhbwstuttgart/typeinference/unify/Unify.java index 96feeaf3..496422ad 100755 --- a/src/de/dhbwstuttgart/typeinference/unify/Unify.java +++ b/src/de/dhbwstuttgart/typeinference/unify/Unify.java @@ -1178,7 +1178,33 @@ throws MatchException inferencelog.debug(""); inferencelog.debug("Ausgewaehltes Paar = " + P.toString() + ""); inferencelog.debug( "--------------------------------------------------"); - + + //wenn noetig extends-wildcards entfernen PL 15-01-30 + if(P.TA1 instanceof ExtendsWildcardType && P.TA2 instanceof ExtendsWildcardType) + { + ExtendsWildcardType exT1 = (ExtendsWildcardType)P.TA1; + ExtendsWildcardType exT2 = (ExtendsWildcardType)P.TA2; + + H.addElement(new Pair(exT1.get_ExtendsType(), exT2.get_ExtendsType())); + + bRegel = true; + continue; + + } + + //wenn noetig super-wildcards entfernen PL 15-01-30 + if(P.TA1 instanceof SuperWildcardType && P.TA2 instanceof SuperWildcardType) + { + SuperWildcardType suT1 = (SuperWildcardType)P.TA1; + SuperWildcardType suT2 = (SuperWildcardType)P.TA2; + + H.addElement(new Pair(suT1.get_SuperType(), suT2.get_SuperType())); + + bRegel = true; + continue; + + } + // Bei allen Erase erfolgt keine Kopie nach H, dadurch wird das Pair gelöscht. //ERASE3 if( P.isEqual() && P.OperatorEqual() ) @@ -1383,21 +1409,21 @@ throws MatchException TA1 = (RefType)P.TA1; TA2 = (RefType)P.TA2; } - else if(P.TA1 instanceof ExtendsWildcardType && P.TA2 instanceof ExtendsWildcardType) + else if(P.TA1 instanceof ExtendsWildcardType && P.TA2 instanceof ExtendsWildcardType) //nicht mehr noetig, wird bereits am Anfang der Schleife entfernt { ExtendsWildcardType exT1 = (ExtendsWildcardType)P.TA1; ExtendsWildcardType exT2 = (ExtendsWildcardType)P.TA2; - //if(exT1.get_ExtendsType() instanceof RefType && exT2.get_ExtendsType() instanceof RefType) PL 15-01-30 + if(exT1.get_ExtendsType() instanceof RefType && exT2.get_ExtendsType() instanceof RefType) { TA1 = (RefType)exT1.get_ExtendsType(); TA2 = (RefType)exT2.get_ExtendsType(); } } - else if(P.TA1 instanceof SuperWildcardType && P.TA2 instanceof SuperWildcardType) + else if(P.TA1 instanceof SuperWildcardType && P.TA2 instanceof SuperWildcardType) //nicht mehr noetig, wird bereits am Anfang der Schleife entfernt { SuperWildcardType suT1 = (SuperWildcardType)P.TA1; SuperWildcardType suT2 = (SuperWildcardType)P.TA2; - //if(suT1.get_SuperType() instanceof RefType && suT2.get_SuperType() instanceof RefType) PL 15-01-30 + if(suT1.get_SuperType() instanceof RefType && suT2.get_SuperType() instanceof RefType) { TA1 = (RefType)suT1.get_SuperType(); TA2 = (RefType)suT2.get_SuperType();