use of org.eclipse.n4js.typesystem.StructuralTypingComputer.StructTypingInfo in project n4js by eclipse.
the class Reducer method reduceStructuralTypeRef.
private boolean reduceStructuralTypeRef(TypeRef left, TypeRef right, Variance variance) {
if (variance == CONTRA) {
return reduceStructuralTypeRef(right, left, CO);
}
// now, variance is either CO or INV
final StructuralTypingComputer stc = tsh.getStructuralTypingComputer();
final RuleEnvironment G2 = RuleEnvironmentExtensions.wrap(G);
final StructTypingInfo infoFaked = new // <- G2 will be changed!
StructTypingInfo(// <- G2 will be changed!
G2, // <- G2 will be changed!
left, // <- G2 will be changed!
right, left.getTypingStrategy(), right.getTypingStrategy());
boolean wasAdded = false;
final StructuralTypesHelper structTypesHelper = tsh.getStructuralTypesHelper();
final StructuralMembersTripleIterator iter = structTypesHelper.getMembersTripleIterator(G2, left, right, false);
while (iter.hasNext()) {
final StructuralMembersTriple next = iter.next();
final TMember l = next.getLeft();
final TMember r = next.getRight();
if (l == null || r == null) {
// commencing with type inference here produces better error messages.)
continue;
}
final TypeConstraint constraint = stc.reduceMembers(left, l, r, variance, infoFaked);
if (containsReopenedExistentialType(G2, constraint)) {
// TODO reconsider handling of re-opened ExistentialTypeRefs in InferenceContext, IDE-1653
continue;
}
wasAdded |= reduce(constraint);
}
return wasAdded;
}
Aggregations