Search in sources :

Example 1 with StructTypingInfo

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;
}
Also used : StructuralTypesHelper(org.eclipse.n4js.utils.StructuralTypesHelper) StructuralMembersTriple(org.eclipse.n4js.utils.StructuralMembersTriple) StructuralTypingComputer(org.eclipse.n4js.typesystem.StructuralTypingComputer) RuleEnvironment(org.eclipse.xsemantics.runtime.RuleEnvironment) TMember(org.eclipse.n4js.ts.types.TMember) StructTypingInfo(org.eclipse.n4js.typesystem.StructuralTypingComputer.StructTypingInfo) StructuralMembersTripleIterator(org.eclipse.n4js.utils.StructuralMembersTripleIterator)

Aggregations

TMember (org.eclipse.n4js.ts.types.TMember)1 StructuralTypingComputer (org.eclipse.n4js.typesystem.StructuralTypingComputer)1 StructTypingInfo (org.eclipse.n4js.typesystem.StructuralTypingComputer.StructTypingInfo)1 StructuralMembersTriple (org.eclipse.n4js.utils.StructuralMembersTriple)1 StructuralMembersTripleIterator (org.eclipse.n4js.utils.StructuralMembersTripleIterator)1 StructuralTypesHelper (org.eclipse.n4js.utils.StructuralTypesHelper)1 RuleEnvironment (org.eclipse.xsemantics.runtime.RuleEnvironment)1