@@ -37,38 +37,38 @@ protected internal override Expression VisitBinary(Expr.Binary expr)
3737 var lhs = Visit ( expr . Left ) ;
3838 var rhs = Visit ( expr . Right ) ;
3939
40- var factory = CreateOperatorFactory ( expr . Operator . Name ) ;
40+ var lhsType = lhs . Type ;
41+ var rhsType = rhs . Type ;
4142
42- var l = lhs ;
43- var r = rhs ;
43+ var factory = ResolveBinaryOperatorFactory ( expr . Operator . Name ) ;
4444
4545 switch ( expr . Operator . Name )
4646 {
4747 case "&&" :
4848 case "||" :
49- l = ApplyImplicitConversion ( lhs , typeof ( bool ) ) ;
50- r = ApplyImplicitConversion ( rhs , typeof ( bool ) ) ;
49+ lhs = ApplyImplicitConversion ( lhs , typeof ( bool ) ) ;
50+ rhs = ApplyImplicitConversion ( rhs , typeof ( bool ) ) ;
5151
52- if ( l is null )
53- Error . MissingImplicitConversion ( lhs . Type , typeof ( bool ) ) ;
52+ if ( lhs is null )
53+ Error . MissingImplicitConversion ( lhsType , typeof ( bool ) ) ;
5454
55- if ( r is null )
56- Error . MissingImplicitConversion ( rhs . Type , typeof ( bool ) ) ;
55+ if ( rhs is null )
56+ Error . MissingImplicitConversion ( rhsType , typeof ( bool ) ) ;
5757
5858 break ;
5959
6060 case "??" :
61- if ( lhs . Type . IsValueType && ! lhs . Type . IsNullable ( ) )
62- Error . NonApplicableBinaryOperator ( expr . Operator , lhs . Type , rhs . Type ) ;
61+ if ( lhsType . IsValueType && ! lhsType . IsNullable ( ) )
62+ Error . NonApplicableBinaryOperator ( expr . Operator , lhsType , rhsType ) ;
6363
64- r = ApplyImplicitConversion ( rhs , lhs . Type ) ;
65- if ( r is null )
66- Error . NonApplicableBinaryOperator ( expr . Operator , lhs . Type , rhs . Type ) ;
64+ rhs = ApplyImplicitConversion ( rhs , lhsType ) ;
65+ if ( rhs is null )
66+ Error . NonApplicableBinaryOperator ( expr . Operator , lhsType , rhsType ) ;
6767
6868 break ;
6969
7070 case "+" :
71- if ( lhs . Type != typeof ( string ) && rhs . Type != typeof ( string ) )
71+ if ( lhsType != typeof ( string ) && rhsType != typeof ( string ) )
7272 break ;
7373
7474 var arguments = new List < Expression > ( ) ;
@@ -137,11 +137,11 @@ void Flatten(Expression e)
137137
138138 try
139139 {
140- return ApplyBinaryExpression ( expr . Operator , factory , l , r ) ;
140+ return ApplyBinaryExpression ( expr . Operator , factory , lhs , rhs ) ;
141141 }
142142 catch ( Exception e ) when ( e is not ParseErrorException )
143143 {
144- Error . NonApplicableBinaryOperator ( expr . Operator , lhs . Type , rhs . Type ) ;
144+ Error . NonApplicableBinaryOperator ( expr . Operator , lhsType , rhsType ) ;
145145 }
146146
147147 return null ! ;
0 commit comments