forked from JavaTX/JavaCompilerCore
adaptSup + tests
This commit is contained in:
parent
c45c426011
commit
be6a719433
@ -413,16 +413,18 @@ public class RuleSet implements IRuleSet{
|
||||
newRhs = new ExtendsType(lhsType);
|
||||
}
|
||||
else {
|
||||
lhsFromFc = new ExtendsType(finiteClosure.getType(((SuperType) lhsType).getSuperedType()));
|
||||
lhsFromFc = new SuperType(finiteClosure.getType(((SuperType) lhsType).getSuperedType()));
|
||||
newRhs = new ExtendsType(((SuperType) lhsType).getSuperedType());
|
||||
}
|
||||
|
||||
if(lhsFromFc == null)
|
||||
Type rhsFromFc = finiteClosure.getType(((SuperType) rhsType).getSuperedType());
|
||||
|
||||
if(lhsFromFc == null || rhsFromFc == null)
|
||||
return Optional.empty();
|
||||
|
||||
Set<Type> grArg = finiteClosure.grArg(lhsFromFc);
|
||||
Set<Type> smArg = finiteClosure.smArg(new SuperType(rhsFromFc));
|
||||
|
||||
Optional<Type> opt = grArg.stream().filter(x -> x.getName().equals(rhsType.getName())).findAny();
|
||||
Optional<Type> opt = smArg.stream().filter(x -> x.getName().equals(lhsType.getName())).findAny();
|
||||
|
||||
if(!opt.isPresent())
|
||||
return Optional.empty();
|
||||
@ -437,6 +439,7 @@ public class RuleSet implements IRuleSet{
|
||||
unif.andThen(new Unifier(lhsFromFcTypeParams.get(i), lhsTypeParams.get(i)));
|
||||
|
||||
return Optional.of(new MPair(newLhs.apply(unif), newRhs, PairOperator.SMALLERDOTWC));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,9 +92,7 @@ public class FiniteClosure implements IFiniteClosure {
|
||||
|
||||
Set<Type> result = new HashSet<Type>();
|
||||
|
||||
Type t = inheritanceGraph.get(type).getContent();
|
||||
|
||||
result.add(t);
|
||||
result.add(type);
|
||||
smaller(type).forEach(x -> result.add(new SuperType(x)));
|
||||
greater(type).forEach(x -> result.add(new ExtendsType(x)));
|
||||
|
||||
@ -108,7 +106,7 @@ public class FiniteClosure implements IFiniteClosure {
|
||||
|
||||
Set<Type> result = new HashSet<Type>();
|
||||
|
||||
Type t = inheritanceGraph.get(type.getExtendedType()).getContent();
|
||||
Type t = type.getExtendedType();
|
||||
|
||||
greater(t).forEach(x -> result.add(new ExtendsType(x)));
|
||||
|
||||
@ -122,7 +120,7 @@ public class FiniteClosure implements IFiniteClosure {
|
||||
|
||||
Set<Type> result = new HashSet<Type>();
|
||||
|
||||
Type t = inheritanceGraph.get(type.getSuperedType()).getContent();
|
||||
Type t = type.getSuperedType();
|
||||
|
||||
smaller(t).forEach(x -> result.add(new SuperType(x)));
|
||||
|
||||
@ -146,9 +144,7 @@ public class FiniteClosure implements IFiniteClosure {
|
||||
|
||||
Set<Type> result = new HashSet<Type>();
|
||||
|
||||
Type t = inheritanceGraph.get(type).getContent();
|
||||
|
||||
result.add(t);
|
||||
result.add(type);
|
||||
smaller(type).forEach(x -> result.add(new ExtendsType(x)));
|
||||
|
||||
return result;
|
||||
@ -160,7 +156,7 @@ public class FiniteClosure implements IFiniteClosure {
|
||||
|
||||
Set<Type> result = new HashSet<Type>();
|
||||
|
||||
Type t = inheritanceGraph.get(type.getExtendedType()).getContent();
|
||||
Type t = type.getExtendedType();
|
||||
|
||||
result.add(t);
|
||||
smaller(t).forEach(x -> {
|
||||
@ -179,7 +175,7 @@ public class FiniteClosure implements IFiniteClosure {
|
||||
|
||||
Set<Type> result = new HashSet<Type>();
|
||||
|
||||
Type t = inheritanceGraph.get(type.getSuperedType()).getContent();
|
||||
Type t = type.getSuperedType();
|
||||
|
||||
result.add(t);
|
||||
greater(t).forEach(x -> {
|
||||
|
@ -630,9 +630,12 @@ public class RuleSetTest {
|
||||
SimpleType t1 = tf.getSimpleType("Type1", "T", "U");
|
||||
SimpleType t2 = tf.getSimpleType("Type2", "T");
|
||||
SimpleType t3 = tf.getSimpleType("Type3", tf.getPlaceholderType("T"), tf.getSimpleType("Integer"));
|
||||
SimpleType t32 = tf.getSimpleType("Type3", "T", "U");
|
||||
SimpleType t4 = tf.getSimpleType("Object");
|
||||
|
||||
fcb.add(t1, t2);
|
||||
fcb.add(t2, t3);
|
||||
fcb.add(t32, t4);
|
||||
|
||||
IRuleSet rules = new RuleSet(fcb.getFiniteClosure());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user