Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/ApplicationExpr.cc

    r0b00df0 raaeacf4  
    2929
    3030ParamEntry::ParamEntry( const ParamEntry &other ) :
    31                 decl( other.decl ), actualType( maybeClone( other.actualType ) ), formalType( maybeClone( other.formalType ) ), expr( maybeClone( other.expr ) )/*, inferParams( new InferredParams( *other.inferParams ) )*/ {
     31                decl( other.decl ), declptr( maybeClone( other.declptr ) ), actualType( maybeClone( other.actualType ) ), formalType( maybeClone( other.formalType ) ), expr( maybeClone( other.expr ) )/*, inferParams( new InferredParams( *other.inferParams ) )*/ {
    3232}
    3333
    3434ParamEntry &ParamEntry::operator=( const ParamEntry &other ) {
    3535        if ( &other == this ) return *this;
    36         decl = other.decl;
     36        const_cast<UniqueId &>(decl) = other.decl;
     37        const_cast<Declaration * &>(declptr) = maybeClone( other.declptr );
    3738        // xxx - this looks like a memory leak
    38         actualType = maybeClone( other.actualType );
    39         formalType = maybeClone( other.formalType );
     39        const_cast<Type * &>(actualType) = maybeClone( other.actualType );
     40        const_cast<Type * &>(formalType) = maybeClone( other.formalType );
    4041        expr = maybeClone( other.expr );
    4142        // *inferParams = *other.inferParams;
     
    4445
    4546ParamEntry::~ParamEntry() {
     47        delete declptr;
    4648        delete actualType;
    4749        delete formalType;
     
    5052
    5153ParamEntry::ParamEntry( ParamEntry && other ) :
    52                 decl( other.decl ), actualType( other.actualType ), formalType( other.formalType ), expr( other.expr )/*, inferParams( std::move( other.inferParams ) )*/ {
    53         other.actualType = nullptr;
    54         other.formalType = nullptr;
     54                decl( other.decl ), declptr( other.declptr ), actualType( other.actualType ), formalType( other.formalType ), expr( other.expr )/*, inferParams( std::move( other.inferParams ) )*/ {
     55        const_cast<Declaration * &>(other.declptr) = nullptr;
     56        const_cast<Type * &>(other.actualType) = nullptr;
     57        const_cast<Type * &>(other.formalType) = nullptr;
    5558        other.expr = nullptr;
    5659}
     
    5861ParamEntry & ParamEntry::operator=( ParamEntry && other ) {
    5962        if ( &other == this ) return *this;
     63        delete declptr;
    6064        delete actualType;
    6165        delete formalType;
    6266        delete expr;
    63         decl = other.decl;
    64         actualType = other.actualType;
    65         formalType = other.formalType;
     67        const_cast<UniqueId &>(decl) = other.decl;
     68        const_cast<Declaration * &>(declptr) = other.declptr;
     69        const_cast<Type * &>(actualType) = other.actualType;
     70        const_cast<Type * &>(formalType) = other.formalType;
    6671        expr = other.expr;
    67         other.actualType = nullptr;
    68         other.formalType = nullptr;
     72        const_cast<Declaration * &>(other.declptr) = nullptr;
     73        const_cast<Type * &>(other.actualType) = nullptr;
     74        const_cast<Type * &>(other.formalType) = nullptr;
    6975        other.expr = nullptr;
    7076        // inferParams = std::move( other.inferParams );
Note: See TracChangeset for help on using the changeset viewer.