Changeset 661214c


Ignore:
Timestamp:
Mar 7, 2018, 5:02:11 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
b2e8841
Parents:
02c816f
Message:

Apply generic substitution to member type when transforming generic member expressions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r02c816f r661214c  
    15871587                        assert( newMemberExpr );
    15881588
    1589                         Type *memberType = memberExpr->member->get_type();
     1589                        // Must apply the generic substitution to the member type to handle cases where the member is a generic parameter substituted by a known concrete type, e.g.
     1590                        //   forall(otype T) struct Box { T x; }
     1591                        //   forall(otype T) f() {
     1592                        //     Box(T *) b; b.x;
     1593                        //   }
     1594                        // TODO: memberExpr->result should be exactly memberExpr->member->get_type() after substitution, so it doesn't seem like it should be necessary to apply the substitution manually. For some reason this is not currently the case. This requires more investigation.
     1595                        Type *memberType = memberExpr->member->get_type()->clone();
     1596                        TypeSubstitution sub = objectType->genericSubstitution();
     1597                        sub.apply( memberType );
    15901598                        if ( ! isPolyType( memberType, scopeTyVars ) ) {
    15911599                                // Not all members of a polymorphic type are themselves of polymorphic type; in this case the member expression should be wrapped and dereferenced to form an lvalue
     
    15951603                        }
    15961604
     1605                        delete memberType;
    15971606                        delete memberExpr;
    15981607                        return newMemberExpr;
Note: See TracChangeset for help on using the changeset viewer.