forked from JavaTX/JavaCompilerCore
fixed RuleSetStrucType refl().
This commit is contained in:
parent
a17342458e
commit
6f85c2b376
@ -51,25 +51,38 @@ public class RuleSetStrucType extends RuleSet {
|
||||
// Filter SMALLERDOT Pairs
|
||||
final Set<UnifyPair> pairsSmallerDot = pairs.stream().filter(p -> PairOperator.SMALLERDOT.equals(p.getPairOp()))
|
||||
.collect(Collectors.toSet());
|
||||
// System.out.println("Pairs to test: " + pairsSmallerDot);
|
||||
// Filter Tuples of Pairs for a potential Linking (t<T1,T1<T2,...,Tn<t)
|
||||
List<Pair<UnifyPair, UnifyPair>> tupleOfPotentialLinkings = new ArrayList<>();
|
||||
for (UnifyPair pair : pairsSmallerDot) {
|
||||
if (!(pair.getRhsType() instanceof PlaceholderType)) {
|
||||
// System.out.println("Pair not suitable for outerLeftPair: " + pair);
|
||||
continue;
|
||||
}
|
||||
tupleOfPotentialLinkings = pairsSmallerDot.stream()
|
||||
.filter(p -> p.getLhsType() instanceof PlaceholderType && p.getRhsType().equals(pair.getLhsType()))
|
||||
.map(p -> new Pair<>(pair, p)).collect(Collectors.toList());
|
||||
// System.out.println("Try to find tuple of potential linkings for pair " + pair);
|
||||
tupleOfPotentialLinkings.addAll(pairsSmallerDot.stream().filter(p -> {
|
||||
// System.out.println(" Pair pair: " + pair);
|
||||
// System.out.println("Pair p: " + p);
|
||||
// System.out.println("p.lhs instnceof PH: " + (p.getLhsType() instanceof PlaceholderType));
|
||||
// System.out.println("p.rhs equals pair.lhs: " + (p.getRhsType().equals(pair.getLhsType())));
|
||||
return (p.getLhsType() instanceof PlaceholderType) && (p.getRhsType().equals(pair.getLhsType()));
|
||||
}).map(p -> {
|
||||
// System.out.println("Pair to map: " + p);
|
||||
return new Pair<>(pair, p);
|
||||
}).collect(Collectors.toList()));
|
||||
// System.out.println("tuple of potential linkings: " + tupleOfPotentialLinkings);
|
||||
}
|
||||
// Build Linking between the Pairs. Empty if no Linking is possible.
|
||||
for (Pair<UnifyPair, UnifyPair> tuple : tupleOfPotentialLinkings) {
|
||||
UnifyPair outerLeftPair = tuple.getKey();
|
||||
UnifyPair outerRightPair = tuple.getValue();
|
||||
// System.out.println("Try linking pair: " + outerLeftPair + ", " + outerRightPair);
|
||||
Optional<Set<UnifyPair>> opt = StrucTypeUnifyUtils.linkPairs(outerLeftPair, outerRightPair,
|
||||
pairsSmallerDot);
|
||||
// Remove Pairs of the Linking incl. outerLeft and outerRight, add
|
||||
// EQUALSDOT Pairs instead.
|
||||
if (opt.isPresent()) {
|
||||
// System.out.println("Linking found: " + opt.get());
|
||||
pairs.remove(outerLeftPair);
|
||||
pairs.remove(outerRightPair);
|
||||
pairs.removeAll(opt.get());
|
||||
@ -86,6 +99,7 @@ public class RuleSetStrucType extends RuleSet {
|
||||
.add(UnifyTypeFactory.generateEqualDotPair(placeholder, outermostUnifyType)));
|
||||
return Optional.of(pairs);
|
||||
}
|
||||
// System.out.println("No Linking found");
|
||||
}
|
||||
// No Linking was found.
|
||||
return Optional.empty();
|
||||
|
Loading…
Reference in New Issue
Block a user