From 8cc1c79c671d2c25a3c1073be759164da1d1885f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pl=C3=BCmicke?= Date: Wed, 11 Mar 2015 16:36:05 +0100 Subject: [PATCH] ? ext Ty <. TPH in Unify eingefuegt --- .../typeinference/unify/Unify.java | 72 +++++++++++++------ 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/src/de/dhbwstuttgart/typeinference/unify/Unify.java b/src/de/dhbwstuttgart/typeinference/unify/Unify.java index 3b6d00c1..69b15d40 100755 --- a/src/de/dhbwstuttgart/typeinference/unify/Unify.java +++ b/src/de/dhbwstuttgart/typeinference/unify/Unify.java @@ -445,10 +445,25 @@ public class Unify { if(p.OperatorSmaller()) { - //5. Menge - //Greater auf den Typen bilden, und mit den Ergebnissen neue Paare bilden. - Vector grErg = greater((ObjectType)p.TA1,fc_tto); - cartProduktSets.add(generateSetOfSetOfPair(p.TA2,grErg)); + if (p.TA1 instanceof ObjectType) { + //5. Menge + //Greater auf den Typen bilden, und mit den Ergebnissen neue Paare bilden. + Vector grErg = greater((ObjectType)p.TA1,fc_tto); + cartProduktSets.add(generateSetOfSetOfPair(p.TA2,grErg)); + } + else if (p.TA1 instanceof ExtendsWildcardType) { // eingefuegt 15-3-11 PL + Vector grErg1 = greater(((ExtendsWildcardType)p.TA1).getContainedType(),fc_tto); + Vector grErg2 = grErg1.stream().map(ty -> new SuperWildcardType(ty.getOffset(), ty.clone())).collect(Vector::new, Vector::add, Vector::addAll); + Vector grErg = new Vector<>(); + grErg.addAll(grErg1); + grErg.addAll(grErg2); + cartProduktSets.add(generateSetOfSetOfPair(p.TA2,grErg)); + } + else if (p.TA1 instanceof SuperWildcardType) {// eingefuegt 15-3-11 PL + Vector erg = new Vector<> (); + erg.addElement(p.TA1); + cartProduktSets.add(generateSetOfSetOfPair(p.TA2,erg)); + } } else if(p.OperatorSmallerExtends()) { @@ -1055,25 +1070,38 @@ throws MatchException // ERASE1 luar 15-04-07 if(P.OperatorSmaller()) { - if((P.TA1 instanceof RefType) == false || ((RefType)P.TA1).get_ParaList() == null) - { - if((P.TA2 instanceof RefType) == false || ((RefType)P.TA2).get_ParaList() == null) - { - Vector greaters = greater((ObjectType)P.TA1,fc_tto); - //Ist ObjectType weil P.OperatorSmaller, kann kein Wildcard sein - - //System.out.println(P.TA2.toString()); - // "P.TA2.toString() != null" angefügt von Andreas Stadelmeier a10023 - if(P.TA2.toString() != null && greaters.contains(P.TA2)) - { - inferencelog.debug(" ================================"); - inferencelog.debug(" ERASE1"); - inferencelog.debug(" ================================"); - bRegel = true; - continue; - } - } + if (P.TA1 instanceof ObjectType) { + Vector greaters = greater((ObjectType)P.TA1,fc_tto); + if (greaters.contains(P.TA2)) + { + inferencelog.debug(" ================================"); + inferencelog.debug(" ERASE1 ObjectType"); + inferencelog.debug(" ================================"); + bRegel = true; + continue; + } } + else if (P.TA1 instanceof ExtendsWildcardType) { + ObjectType pta1 = ((ExtendsWildcardType)P.TA1).getContainedType(); + Vector greaters = greater((ObjectType)pta1,fc_tto); + if (greaters.contains(P.TA2)) + { + inferencelog.debug(" ================================"); + inferencelog.debug(" ERASE1 ExtendsWildcardType"); + inferencelog.debug(" ================================"); + bRegel = true; + continue; + } + } + } + else if (P.TA1 instanceof SuperWildcardType) { + if( P.isEqual()) { + inferencelog.debug(" ================================"); + inferencelog.debug(" ERASE1 SuperWildcardType"); + inferencelog.debug(" ================================"); + bRegel = true; + continue; + } } //ERASE2 luar 15-04-07 if(P.OperatorSmallerExtends())