Index: src/GenPoly/Lvalue.cc
===================================================================
--- src/GenPoly/Lvalue.cc	(revision e3e16bcf91a7300a6d1f71eaad04e2f3f498cfc2)
+++ src/GenPoly/Lvalue.cc	(revision 06903509f799ad9b509246cc8b08bb77dcd2f1f4)
@@ -47,11 +47,11 @@
 			if ( SymTab::dereferenceOperator ) {
 				VariableExpr * deref = new VariableExpr( SymTab::dereferenceOperator );
-				deref->set_result( new PointerType( Type::Qualifiers(), deref->get_result() ) );
-				Type * base = InitTweak::getPointerBase( arg->get_result() );
-				assertf( base, "expected pointer type in dereference (type was %s)", toString( arg->get_result() ).c_str() );
+				deref->result = new PointerType( Type::Qualifiers(), deref->result );
+				Type * base = InitTweak::getPointerBase( arg->result );
+				assertf( base, "expected pointer type in dereference (type was %s)", toString( arg->result ).c_str() );
 				ApplicationExpr * ret = new ApplicationExpr( deref, { arg } );
-				delete ret->get_result();
-				ret->set_result( base->clone() );
-				ret->get_result()->set_lvalue( true );
+				delete ret->result;
+				ret->result = base->clone();
+				ret->result->set_lvalue( true );
 				return ret;
 			} else {
@@ -308,31 +308,34 @@
 					int diff = depth1-depth2;
 					if ( diff == 0 ) {
+						// conversion between references of the same depth
 						assertf( depth1 == depth2, "non-intrinsic reference with cast of reference to reference not yet supported: %d %d %s", depth1, depth2, toString( castExpr ).c_str() );
 						PRINT( std::cerr << castExpr << std::endl; )
 						return castExpr;
 					} else if ( diff < 0 ) {
-						Expression * ret = castExpr->get_arg();
+						// conversion from reference to reference with less depth (e.g. int && -> int &): add dereferences
+						Expression * ret = castExpr->arg;
 						for ( int i = 0; i < diff; ++i ) {
 							ret = mkDeref( ret );
 						}
-						ret->set_env( castExpr->get_env() );
-						delete ret->get_result();
-						ret->set_result( castExpr->get_result() );
-						castExpr->set_env( nullptr );
-						castExpr->set_arg( nullptr );
-						castExpr->set_result( nullptr );
+						ret->env = castExpr->env;
+						delete ret->result;
+						ret->result = castExpr->result;
+						castExpr->env = nullptr;
+						castExpr->arg = nullptr;
+						castExpr->result = nullptr;
 						delete castExpr;
 						return ret;
 					} else if ( diff > 0 ) {
-						Expression * ret = castExpr->get_arg();
+						// conversion from reference to reference with more depth (e.g. int & -> int &&): add address-of
+						Expression * ret = castExpr->arg;
 						for ( int i = 0; i < diff; ++i ) {
 							ret = new AddressExpr( ret );
 						}
-						ret->set_env( castExpr->get_env() );
-						delete ret->get_result();
-						ret->set_result( castExpr->get_result() );
-						castExpr->set_env( nullptr );
-						castExpr->set_arg( nullptr );
-						castExpr->set_result( nullptr );
+						ret->env = castExpr->env;
+						delete ret->result;
+						ret->result = castExpr->result;
+						castExpr->env = nullptr;
+						castExpr->arg = nullptr;
+						castExpr->result = nullptr;
 						delete castExpr;
 						return ret;
@@ -342,5 +345,5 @@
 					PRINT( std::cerr << castExpr << std::endl; )
 					return castExpr;
-				} else if ( castExpr->get_arg()->get_result()->get_lvalue() ) {
+				} else if ( castExpr->arg->result->get_lvalue() ) {
 					// conversion from lvalue to reference
 					// xxx - keep cast, but turn into pointer cast??
@@ -348,18 +351,18 @@
 					PRINT(
 						std::cerr << "convert lvalue to reference -- &" << std::endl;
-						std::cerr << castExpr->get_arg() << std::endl;
+						std::cerr << castExpr->arg << std::endl;
 					)
-					AddressExpr * ret = new AddressExpr( castExpr->get_arg() );
-					if ( refType->get_base()->get_qualifiers() != castExpr->get_arg()->get_result()->get_qualifiers() ) {
+					AddressExpr * ret = new AddressExpr( castExpr->arg );
+					if ( refType->base->get_qualifiers() != castExpr->arg->result->get_qualifiers() ) {
 						// must keep cast if cast-to type is different from the actual type
-						castExpr->set_arg( ret );
+						castExpr->arg = ret;
 						return castExpr;
 					}
-					ret->set_env( castExpr->get_env() );
-					delete ret->get_result();
-					ret->set_result( castExpr->get_result() );
-					castExpr->set_env( nullptr );
-					castExpr->set_arg( nullptr );
-					castExpr->set_result( nullptr );
+					ret->env = castExpr->env;
+					delete ret->result;
+					ret->result = castExpr->result;
+					castExpr->env = nullptr;
+					castExpr->arg = nullptr;
+					castExpr->result = nullptr;
 					delete castExpr;
 					return ret;
@@ -368,5 +371,5 @@
 				}
 				assertf( false, "Only conversions to reference from lvalue are currently supported: %s", toString( castExpr ).c_str() );
-			} else if ( ReferenceType * refType = dynamic_cast< ReferenceType * >( castExpr->get_arg()->get_result() ) ) {
+			} else if ( ReferenceType * refType = dynamic_cast< ReferenceType * >( castExpr->arg->result ) ) {
 				(void)refType;
 				// conversion from reference to rvalue
@@ -375,6 +378,6 @@
 					std::cerr << "was = " << castExpr << std::endl;
 				)
-				Expression * ret = castExpr->get_arg();
-				TypeSubstitution * env = castExpr->get_env();
+				Expression * ret = castExpr->arg;
+				TypeSubstitution * env = castExpr->env;
 				castExpr->set_env( nullptr );
 				if ( ! isIntrinsicReference( ret ) ) {
@@ -382,12 +385,12 @@
 					ret = mkDeref( ret );
 				}
-				if ( ResolvExpr::typesCompatibleIgnoreQualifiers( castExpr->get_result(), castExpr->get_arg()->get_result()->stripReferences(), SymTab::Indexer() ) ) {
+				if ( ResolvExpr::typesCompatibleIgnoreQualifiers( castExpr->result, castExpr->arg->result->stripReferences(), SymTab::Indexer() ) ) {
 					// can remove cast if types are compatible, changing expression type to value type
-					ret->set_result( castExpr->get_result()->clone() );
-					castExpr->set_arg( nullptr );
+					ret->result = castExpr->result->clone();
+					castExpr->arg = nullptr;
 					delete castExpr;
 				} else {
 					// must keep cast if types are different
-					castExpr->set_arg( ret );
+					castExpr->arg = ret;
 					ret = castExpr;
 				}
