Index: src/ResolvExpr/AlternativeFinder.cc
===================================================================
--- src/ResolvExpr/AlternativeFinder.cc	(revision 98278b3a3b51cc70cbf5d34dfc354879a73862b8)
+++ src/ResolvExpr/AlternativeFinder.cc	(revision b2da05741abf9ee33682eff93563c8cf8bcd7eba)
@@ -1247,5 +1247,5 @@
 	}
 
-	Expression * restructureCast( Expression * argExpr, Type * toType ) {
+	Expression * restructureCast( Expression * argExpr, Type * toType, bool isGenerated ) {
 		if ( argExpr->get_result()->size() > 1 && ! toType->isVoid() && ! dynamic_cast<ReferenceType *>( toType ) ) {
 			// Argument expression is a tuple and the target type is not void and not a reference type.
@@ -1262,5 +1262,5 @@
 				// cast each component
 				TupleIndexExpr * idx = new TupleIndexExpr( argExpr->clone(), i );
-				componentExprs.push_back( restructureCast( idx, toType->getComponent( i ) ) );
+				componentExprs.push_back( restructureCast( idx, toType->getComponent( i ), isGenerated ) );
 			}
 			delete argExpr;
@@ -1270,5 +1270,7 @@
 		} else {
 			// handle normally
-			return new CastExpr( argExpr, toType->clone() );
+			CastExpr * ret = new CastExpr( argExpr, toType->clone() );
+			ret->isGenerated = isGenerated;
+			return ret;
 		}
 	}
@@ -1314,5 +1316,5 @@
 				// count one safe conversion for each value that is thrown away
 				thisCost.incSafe( discardedValues );
-				Alternative newAlt( restructureCast( alt.expr->clone(), toType ), alt.env,
+				Alternative newAlt( restructureCast( alt.expr->clone(), toType, castExpr->isGenerated ), alt.env,
 					alt.cost, thisCost );
 				inferParameters( needAssertions, haveAssertions, newAlt, openVars,
@@ -1730,5 +1732,5 @@
 					// count one safe conversion for each value that is thrown away
 					thisCost.incSafe( discardedValues );
-					Alternative newAlt( new InitExpr( restructureCast( alt.expr->clone(), toType ), initAlt.designation->clone() ), newEnv, alt.cost, thisCost );
+					Alternative newAlt( new InitExpr( restructureCast( alt.expr->clone(), toType, true ), initAlt.designation->clone() ), newEnv, alt.cost, thisCost );
 					inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( candidates ) );
 				}
