|
|
|
@@ -745,7 +745,7 @@ public class RuleSet implements IRuleSet{
|
|
|
|
|
|
|
|
|
|
UnifyType lhsType = pair.getLhsType();
|
|
|
|
|
UnifyType rhsType = pair.getRhsType();
|
|
|
|
|
if(!(lhsType instanceof ReferenceType) || !(rhsType instanceof ExtendsType))
|
|
|
|
|
if((!(lhsType instanceof ReferenceType) && !(lhsType instanceof FunNType)) || !(rhsType instanceof ExtendsType))
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
|
|
|
|
|
return Optional.of(new UnifyPair(lhsType, ((ExtendsType) rhsType).getExtendedType(), PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair()));
|
|
|
|
@@ -771,7 +771,7 @@ public class RuleSet implements IRuleSet{
|
|
|
|
|
|
|
|
|
|
UnifyType lhsType = pair.getLhsType();
|
|
|
|
|
UnifyType rhsType = pair.getRhsType();
|
|
|
|
|
if(!(lhsType instanceof ReferenceType) || !(rhsType instanceof SuperType))
|
|
|
|
|
if((!(lhsType instanceof ReferenceType) && !(lhsType instanceof FunNType)) || !(rhsType instanceof SuperType))
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
|
|
|
|
|
return Optional.of(new UnifyPair(((SuperType) rhsType).getSuperedType(), lhsType, PairOperator.SMALLERDOTWC, pair.getSubstitution(), pair.getBasePair()));
|
|
|
|
@@ -861,16 +861,19 @@ public class RuleSet implements IRuleSet{
|
|
|
|
|
UnifyType r = x.getRhsType();
|
|
|
|
|
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
logFile.write("FUNgreater: " + pair + "\n");
|
|
|
|
|
logFile.write("FUNred: " + result + "\n");
|
|
|
|
|
logFile.flush();
|
|
|
|
|
}
|
|
|
|
|
logFile.write("FUNgreater: " + pair + "\n");
|
|
|
|
|
logFile.write("FUNgreater: " + result + "\n");
|
|
|
|
|
logFile.flush();
|
|
|
|
|
}
|
|
|
|
|
catch (IOException e) {
|
|
|
|
|
System.out.println("logFile-Error");
|
|
|
|
|
System.out.println("lofFile-Error");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Optional.of(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@@ -897,7 +900,7 @@ public class RuleSet implements IRuleSet{
|
|
|
|
|
|
|
|
|
|
var fiArgs = intf.getFunctionalInterfaceTypeArguments(refType);
|
|
|
|
|
var retType = fiArgs.getFirst();
|
|
|
|
|
var lhsArgs = intf.getFunctionalInterfaceTypeArguments(lhsType);
|
|
|
|
|
var lhsArgs = intf.getFunctionalInterfaceTypeArguments(lhsType); //FALSCHRUM????
|
|
|
|
|
var lhsRet = lhsArgs.getFirst();
|
|
|
|
|
|
|
|
|
|
Set<UnifyPair> result = new HashSet<>();
|
|
|
|
@@ -934,8 +937,8 @@ public class RuleSet implements IRuleSet{
|
|
|
|
|
|
|
|
|
|
Set<UnifyPair> result = new HashSet<UnifyPair>();
|
|
|
|
|
|
|
|
|
|
Integer variance = ((PlaceholderType)rhsType).getVariance();
|
|
|
|
|
Integer inversVariance = distributeVariance.inverseVariance(variance);
|
|
|
|
|
int variance = ((PlaceholderType)rhsType).getVariance();
|
|
|
|
|
int inversVariance = distributeVariance.inverseVariance(variance);
|
|
|
|
|
|
|
|
|
|
UnifyType[] freshPlaceholders = new UnifyType[funNLhsType.getTypeParams().size()];
|
|
|
|
|
for(int i = 0; i < freshPlaceholders.length-1; i++) {
|
|
|
|
@@ -943,6 +946,7 @@ public class RuleSet implements IRuleSet{
|
|
|
|
|
((PlaceholderType)freshPlaceholders[i]).setVariance(inversVariance);
|
|
|
|
|
}
|
|
|
|
|
freshPlaceholders[freshPlaceholders.length-1] = PlaceholderType.freshPlaceholder();
|
|
|
|
|
|
|
|
|
|
((PlaceholderType)freshPlaceholders[freshPlaceholders.length-1]).setVariance(variance);
|
|
|
|
|
result.add(new UnifyPair(funNLhsType.getTypeParams().get(funNLhsType.getTypeParams().size()-1), freshPlaceholders[funNLhsType.getTypeParams().size()-1], PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair()));
|
|
|
|
|
|
|
|
|
@@ -953,42 +957,94 @@ public class RuleSet implements IRuleSet{
|
|
|
|
|
result.add(new UnifyPair(rhsType, funNLhsType.setTypeParams(new TypeParams(freshPlaceholders)), PairOperator.EQUALSDOT, pair.getSubstitution(), pair.getBasePair()));
|
|
|
|
|
|
|
|
|
|
result.stream().forEach(x -> { UnifyType l = x.getLhsType();
|
|
|
|
|
if (l instanceof PlaceholderType) { ((PlaceholderType)l).disableWildcardtable(); }
|
|
|
|
|
if (l instanceof PlaceholderType) { ((PlaceholderType)l).disableWildcardtable(); }
|
|
|
|
|
UnifyType r = x.getRhsType();
|
|
|
|
|
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
|
|
|
|
} );
|
|
|
|
|
try {
|
|
|
|
|
logFile.write("FUNgreater: " + pair + "\n");
|
|
|
|
|
logFile.write("FUNgreater: " + result + "\n");
|
|
|
|
|
logFile.flush();
|
|
|
|
|
}
|
|
|
|
|
catch (IOException e) {
|
|
|
|
|
System.out.println("lofFile-Error");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
logFile.write("FUNgreater: " + pair + "\n");
|
|
|
|
|
logFile.write("FUNsmaller: " + result + "\n");
|
|
|
|
|
logFile.flush();
|
|
|
|
|
}
|
|
|
|
|
catch (IOException e) {
|
|
|
|
|
System.out.println("lofFile-Error");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Optional.of(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Optional<Set<UnifyPair>> smallerFunN(UnifyPair pair) {
|
|
|
|
|
public Optional<Set<UnifyPair>> smallerFunN(UnifyPair pair, IFiniteClosure fc) {
|
|
|
|
|
if(pair.getPairOp() != PairOperator.SMALLERDOT)
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
|
|
|
|
|
UnifyType lhsType = pair.getLhsType();
|
|
|
|
|
UnifyType rhsType = pair.getRhsType();
|
|
|
|
|
|
|
|
|
|
if(!(lhsType instanceof PlaceholderType) || !(rhsType instanceof FunNType))
|
|
|
|
|
if(!(rhsType instanceof FunNType))
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
|
|
|
|
|
/* muss nach angepasst werden */
|
|
|
|
|
//FunN$$<...> <. FunctinalInterface<...> wird umgewandelt in FunN$$<...> <. FunN$$<... args aus FuntionalInterface ...>
|
|
|
|
|
if (lhsType instanceof ReferenceType) {
|
|
|
|
|
UnifyType typeFI = pair.getLhsType();
|
|
|
|
|
|
|
|
|
|
Optional<UnifyType> opt = fc.getRightHandedFunctionalInterfaceType(typeFI.getName());
|
|
|
|
|
if(!opt.isPresent())
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
|
|
|
|
|
if (!(typeFI instanceof ReferenceType refType) || !(refType instanceof FunInterfaceType intf))
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
|
|
|
|
|
var fiArgs = intf.getFunctionalInterfaceTypeArguments(refType);
|
|
|
|
|
var retType = fiArgs.getFirst();
|
|
|
|
|
var rhsArgs = intf.getFunctionalInterfaceTypeArguments(rhsType);
|
|
|
|
|
var rhsRet = rhsArgs.getFirst();
|
|
|
|
|
|
|
|
|
|
Set<UnifyPair> result = new HashSet<>();
|
|
|
|
|
//if (retType instanceof ExtendsType) {
|
|
|
|
|
result.add(new UnifyPair(retType, rhsRet, PairOperator.SMALLER));
|
|
|
|
|
//} else if (retType instanceof SuperType) {
|
|
|
|
|
// return Optional.empty();
|
|
|
|
|
//} else {
|
|
|
|
|
// result.add(new UnifyPair(lhsRet, retType, PairOperator.EQUALSDOT));
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
for (var i = 1; i < fiArgs.size(); i++) {
|
|
|
|
|
var rh = rhsArgs.get(i);
|
|
|
|
|
var lh = fiArgs.get(i);
|
|
|
|
|
|
|
|
|
|
//if (rh instanceof SuperType) {
|
|
|
|
|
result.add(new UnifyPair(rh, lh, PairOperator.SMALLER));
|
|
|
|
|
//} else if (rh instanceof ExtendsType) {
|
|
|
|
|
// return Optional.empty();
|
|
|
|
|
//} else {
|
|
|
|
|
// result.add(new UnifyPair(lh, rh, PairOperator.EQUALSDOT));
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Optional.of(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
if(!(lhsType instanceof PlaceholderType))
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FunNType funNRhsType = (FunNType) rhsType;
|
|
|
|
|
|
|
|
|
|
Set<UnifyPair> result = new HashSet<UnifyPair>();
|
|
|
|
|
|
|
|
|
|
Integer variance = ((PlaceholderType)lhsType).getVariance();
|
|
|
|
|
Integer inversVariance = distributeVariance.inverseVariance(variance);
|
|
|
|
|
int variance = ((PlaceholderType)lhsType).getVariance();
|
|
|
|
|
int inversVariance = distributeVariance.inverseVariance(variance);
|
|
|
|
|
|
|
|
|
|
UnifyType[] freshPlaceholders = new UnifyType[funNRhsType.getTypeParams().size()];
|
|
|
|
|
for(int i = 0; i < freshPlaceholders.length-1; i++) {
|
|
|
|
|
freshPlaceholders[i] = PlaceholderType.freshPlaceholder();
|
|
|
|
|
freshPlaceholders[i] = PlaceholderType.freshPlaceholder();
|
|
|
|
|
((PlaceholderType)freshPlaceholders[i]).setVariance(inversVariance);
|
|
|
|
|
}
|
|
|
|
|
freshPlaceholders[freshPlaceholders.length-1] = PlaceholderType.freshPlaceholder();
|
|
|
|
@@ -1003,21 +1059,139 @@ public class RuleSet implements IRuleSet{
|
|
|
|
|
result.add(new UnifyPair(lhsType, funNRhsType.setTypeParams(new TypeParams(freshPlaceholders)), PairOperator.EQUALSDOT, pair.getSubstitution(), pair.getBasePair()));
|
|
|
|
|
|
|
|
|
|
result.stream().forEach(x -> { UnifyType l = x.getLhsType();
|
|
|
|
|
if (l instanceof PlaceholderType) { ((PlaceholderType)l).disableWildcardtable(); }
|
|
|
|
|
if (l instanceof PlaceholderType) { ((PlaceholderType)l).disableWildcardtable(); }
|
|
|
|
|
UnifyType r = x.getRhsType();
|
|
|
|
|
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
|
|
|
|
} );
|
|
|
|
|
try {
|
|
|
|
|
logFile.write("FUNgreater: " + pair + "\n");
|
|
|
|
|
logFile.write("FUNsmaller: " + result + "\n");
|
|
|
|
|
logFile.flush();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
logFile.write("FUNgreater: " + pair + "\n");
|
|
|
|
|
logFile.write("FUNsmaller: " + result + "\n");
|
|
|
|
|
logFile.flush();
|
|
|
|
|
}
|
|
|
|
|
catch (IOException e) {
|
|
|
|
|
System.out.println("lofFile-Error");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Optional.of(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Optional<Set<UnifyPair>> reduceFIFunN(UnifyPair pair, IFiniteClosure fc) {
|
|
|
|
|
if(pair.getPairOp() != PairOperator.EQUALSDOT)
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
|
|
|
|
|
UnifyType lhsType = pair.getLhsType();
|
|
|
|
|
UnifyType rhsType = pair.getRhsType();
|
|
|
|
|
|
|
|
|
|
if(!(rhsType instanceof FunNType))
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
|
|
|
|
|
/* muss nach angepasst werden */
|
|
|
|
|
//FunN$$<...> <. FunctinalInterface<...> wird umgewandelt in FunN$$<...> <. FunN$$<... args aus FuntionalInterface ...>
|
|
|
|
|
if (lhsType instanceof ReferenceType) {
|
|
|
|
|
UnifyType typeFI = pair.getLhsType();
|
|
|
|
|
|
|
|
|
|
Optional<UnifyType> opt = fc.getRightHandedFunctionalInterfaceType(typeFI.getName());
|
|
|
|
|
if(!opt.isPresent())
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
|
|
|
|
|
if (!(typeFI instanceof ReferenceType refType) || !(refType instanceof FunInterfaceType intf))
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
|
|
|
|
|
var fiArgs = intf.getFunctionalInterfaceTypeArguments(refType);
|
|
|
|
|
var retType = fiArgs.getFirst();
|
|
|
|
|
var rhsArgs = intf.getFunctionalInterfaceTypeArguments(rhsType);
|
|
|
|
|
var rhsRet = rhsArgs.getFirst();
|
|
|
|
|
|
|
|
|
|
Set<UnifyPair> result = new HashSet<>();
|
|
|
|
|
//if (retType instanceof ExtendsType) {
|
|
|
|
|
result.add(new UnifyPair(retType, rhsRet, PairOperator.EQUALSDOT));
|
|
|
|
|
//} else if (retType instanceof SuperType) {
|
|
|
|
|
// return Optional.empty();
|
|
|
|
|
//} else {
|
|
|
|
|
// result.add(new UnifyPair(lhsRet, retType, PairOperator.EQUALSDOT));
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
for (var i = 1; i < fiArgs.size(); i++) {
|
|
|
|
|
var rh = rhsArgs.get(i);
|
|
|
|
|
var lh = fiArgs.get(i);
|
|
|
|
|
|
|
|
|
|
//if (rh instanceof SuperType) {
|
|
|
|
|
result.add(new UnifyPair(rh, lh, PairOperator.EQUALSDOT));
|
|
|
|
|
//} else if (rh instanceof ExtendsType) {
|
|
|
|
|
// return Optional.empty();
|
|
|
|
|
//} else {
|
|
|
|
|
// result.add(new UnifyPair(lh, rh, PairOperator.EQUALSDOT));
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Optional.of(result);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
}
|
|
|
|
|
catch (IOException e) {
|
|
|
|
|
System.out.println("lofFile-Error");
|
|
|
|
|
}
|
|
|
|
|
return Optional.of(result);
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Optional<Set<UnifyPair>> reduceFunNFi(UnifyPair pair, IFiniteClosure fc) {
|
|
|
|
|
if(pair.getPairOp() != PairOperator.EQUALSDOT)
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
|
|
|
|
|
UnifyType lhsType = pair.getLhsType();
|
|
|
|
|
UnifyType rhsType = pair.getRhsType();
|
|
|
|
|
|
|
|
|
|
if(!(lhsType instanceof FunNType))
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
|
|
|
|
|
//FunN$$<...> <. FunctinalInterface<...> wird umgewandelt in FunN$$<...> <. FunN$$<... args aus FuntionalInterface ...>
|
|
|
|
|
if (rhsType instanceof ReferenceType) {
|
|
|
|
|
UnifyType typeFI = pair.getRhsType();
|
|
|
|
|
|
|
|
|
|
Optional<UnifyType> opt = fc.getRightHandedFunctionalInterfaceType(typeFI.getName());
|
|
|
|
|
if(!opt.isPresent())
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
|
|
|
|
|
if (!(typeFI instanceof ReferenceType refType) || !(refType instanceof FunInterfaceType intf))
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
|
|
|
|
|
var fiArgs = intf.getFunctionalInterfaceTypeArguments(refType);
|
|
|
|
|
var retType = fiArgs.getFirst();
|
|
|
|
|
var lhsArgs = intf.getFunctionalInterfaceTypeArguments(lhsType);
|
|
|
|
|
var lhsRet = lhsArgs.getFirst();
|
|
|
|
|
|
|
|
|
|
Set<UnifyPair> result = new HashSet<>();
|
|
|
|
|
//if (retType instanceof ExtendsType) {
|
|
|
|
|
// result.add(new UnifyPair(lhsRet, retType, PairOperator.SMALLERDOTWC));
|
|
|
|
|
//} else if (retType instanceof SuperType) {
|
|
|
|
|
// return Optional.empty();
|
|
|
|
|
//} else {
|
|
|
|
|
result.add(new UnifyPair(lhsRet, retType, PairOperator.EQUALSDOT));
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
for (var i = 1; i < fiArgs.size(); i++) {
|
|
|
|
|
var lh = lhsArgs.get(i);
|
|
|
|
|
var rh = fiArgs.get(i);
|
|
|
|
|
|
|
|
|
|
//if (rh instanceof SuperType) {
|
|
|
|
|
// result.add(new UnifyPair(lh, rh, PairOperator.SMALLERDOTWC));
|
|
|
|
|
//} else if (rh instanceof ExtendsType) {
|
|
|
|
|
// return Optional.empty();
|
|
|
|
|
//} else {
|
|
|
|
|
result.add(new UnifyPair(lh, rh, PairOperator.EQUALSDOT));
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Optional.of(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Optional<UnifyPair> reduceTph(UnifyPair pair) {
|
|
|
|
|
if(pair.getPairOp() != PairOperator.SMALLERDOTWC)
|
|
|
|
@@ -1025,7 +1199,7 @@ public class RuleSet implements IRuleSet{
|
|
|
|
|
|
|
|
|
|
UnifyType lhsType = pair.getLhsType();
|
|
|
|
|
UnifyType rhsType = pair.getRhsType();
|
|
|
|
|
if(!(lhsType instanceof PlaceholderType) || !(rhsType instanceof ReferenceType))
|
|
|
|
|
if(!(lhsType instanceof PlaceholderType) || (!(rhsType instanceof ReferenceType) && !(rhsType instanceof FunNType)))
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
|
|
|
|
|
return Optional.of(new UnifyPair(lhsType, rhsType, PairOperator.EQUALSDOT, pair.getSubstitution(), pair.getBasePair()));
|
|
|
|
@@ -1051,7 +1225,7 @@ public class RuleSet implements IRuleSet{
|
|
|
|
|
if(isGen)
|
|
|
|
|
result.add(new UnifyPair(rhsType, lhsType, PairOperator.EQUALSDOT, pair.getSubstitution(), pair.getBasePair()));
|
|
|
|
|
else {
|
|
|
|
|
UnifyType freshTph = PlaceholderType.freshPlaceholder();
|
|
|
|
|
UnifyType freshTph = PlaceholderType.freshPlaceholder();
|
|
|
|
|
result.add(new UnifyPair(rhsType, new ExtendsType(freshTph), PairOperator.EQUALSDOT, pair.getSubstitution(), pair.getBasePair()));
|
|
|
|
|
result.add(new UnifyPair(extendedType, freshTph, PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair()));
|
|
|
|
|
}
|
|
|
|
@@ -1079,7 +1253,7 @@ public class RuleSet implements IRuleSet{
|
|
|
|
|
if(isGen)
|
|
|
|
|
result.add(new UnifyPair(rhsType, lhsType, PairOperator.EQUALSDOT, pair.getSubstitution(), pair.getBasePair()));
|
|
|
|
|
else {
|
|
|
|
|
UnifyType freshTph = PlaceholderType.freshPlaceholder();
|
|
|
|
|
UnifyType freshTph = PlaceholderType.freshPlaceholder();
|
|
|
|
|
result.add(new UnifyPair(rhsType, new SuperType(freshTph), PairOperator.EQUALSDOT, pair.getSubstitution(), pair.getBasePair()));
|
|
|
|
|
Set<UnifyType> fBounded = pair.getfBounded();
|
|
|
|
|
fBounded.add(lhsType);
|
|
|
|
|