@@ -382,6 +382,21 @@ protected internal override TranslatedStatement VisitLeave(Leave inst)
382382 . WithRR ( new ConversionResolveResult ( currentResultType , expr . ResolveResult , Conversion . IdentityConversion ) ) . WithoutILInstruction ( ) ;
383383 }
384384 return new ReturnStatement ( expr ) . WithILInstruction ( inst ) ;
385+
386+ static bool IsPossibleLossOfTypeInformation ( IType givenType , IType expectedType )
387+ {
388+ if ( expectedType . ContainsAnonymousType ( ) )
389+ return false ;
390+ if ( NormalizeTypeVisitor . IgnoreNullability . EquivalentTypes ( givenType , expectedType ) )
391+ return false ;
392+ if ( expectedType is TupleType { ElementNames . IsEmpty : false } )
393+ return true ;
394+ if ( expectedType == SpecialType . Dynamic )
395+ return true ;
396+ if ( givenType == SpecialType . NullType )
397+ return true ;
398+ return false ;
399+ }
385400 }
386401 else
387402 return new ReturnStatement ( ) . WithILInstruction ( inst ) ;
@@ -403,19 +418,6 @@ protected internal override TranslatedStatement VisitLeave(Leave inst)
403418 return new GotoStatement ( label ) . WithILInstruction ( inst ) ;
404419 }
405420
406- private bool IsPossibleLossOfTypeInformation ( IType givenType , IType expectedType )
407- {
408- if ( NormalizeTypeVisitor . IgnoreNullability . EquivalentTypes ( givenType , expectedType ) )
409- return false ;
410- if ( expectedType is TupleType { ElementNames . IsEmpty : false } )
411- return true ;
412- if ( expectedType == SpecialType . Dynamic )
413- return true ;
414- if ( givenType == SpecialType . NullType )
415- return ! expectedType . ContainsAnonymousType ( ) ;
416- return false ;
417- }
418-
419421 protected internal override TranslatedStatement VisitThrow ( Throw inst )
420422 {
421423 return new ThrowStatement ( exprBuilder . Translate ( inst . Argument ) ) . WithILInstruction ( inst ) ;
0 commit comments