@@ -100,7 +100,6 @@ internal static BoundStatement BindUsingStatementOrDeclarationFromParts(SyntaxNo
100100 Debug . Assert ( ( object ) disposableInterface != null ) ;
101101 bool hasErrors = ReportUseSite ( disposableInterface , diagnostics , hasAwait ? awaitKeyword : usingKeyword ) ;
102102
103- Conversion iDisposableConversion ;
104103 ImmutableArray < BoundLocalDeclaration > declarationsOpt = default ;
105104 BoundMultipleLocalDeclarations ? multipleDeclarationsOpt = null ;
106105 BoundExpression ? expressionOpt = null ;
@@ -111,7 +110,7 @@ internal static BoundStatement BindUsingStatementOrDeclarationFromParts(SyntaxNo
111110 if ( isExpression )
112111 {
113112 expressionOpt = usingBinderOpt ! . BindTargetExpression ( diagnostics , originalBinder ) ;
114- hasErrors |= ! populateDisposableConversionOrDisposeMethod ( fromExpression : true , out iDisposableConversion , out patternDisposeInfo , out awaitableTypeOpt ) ;
113+ hasErrors |= ! bindDisposable ( fromExpression : true , out patternDisposeInfo , out awaitableTypeOpt ) ;
115114 }
116115 else
117116 {
@@ -124,13 +123,12 @@ internal static BoundStatement BindUsingStatementOrDeclarationFromParts(SyntaxNo
124123
125124 if ( declarationTypeOpt . IsDynamic ( ) )
126125 {
127- iDisposableConversion = Conversion . ImplicitDynamic ;
128126 patternDisposeInfo = null ;
129127 awaitableTypeOpt = null ;
130128 }
131129 else
132130 {
133- hasErrors |= ! populateDisposableConversionOrDisposeMethod ( fromExpression : false , out iDisposableConversion , out patternDisposeInfo , out awaitableTypeOpt ) ;
131+ hasErrors |= ! bindDisposable ( fromExpression : false , out patternDisposeInfo , out awaitableTypeOpt ) ;
134132 }
135133 }
136134
@@ -156,7 +154,7 @@ internal static BoundStatement BindUsingStatementOrDeclarationFromParts(SyntaxNo
156154 // In the future it might be better to have a separate shared type that we add the info to, and have the callers create the appropriate bound nodes from it
157155 if ( isUsingDeclaration )
158156 {
159- return new BoundUsingLocalDeclarations ( syntax , patternDisposeInfo , iDisposableConversion , awaitOpt , declarationsOpt , hasErrors ) ;
157+ return new BoundUsingLocalDeclarations ( syntax , patternDisposeInfo , awaitOpt , declarationsOpt , hasErrors ) ;
160158 }
161159 else
162160 {
@@ -167,17 +165,16 @@ internal static BoundStatement BindUsingStatementOrDeclarationFromParts(SyntaxNo
167165 usingBinderOpt . Locals ,
168166 multipleDeclarationsOpt ,
169167 expressionOpt ,
170- iDisposableConversion ,
171168 boundBody ,
172169 awaitOpt ,
173170 patternDisposeInfo ,
174171 hasErrors ) ;
175172 }
176173
177- bool populateDisposableConversionOrDisposeMethod ( bool fromExpression , out Conversion iDisposableConversion , out MethodArgumentInfo ? patternDisposeInfo , out TypeSymbol ? awaitableType )
174+ bool bindDisposable ( bool fromExpression , out MethodArgumentInfo ? patternDisposeInfo , out TypeSymbol ? awaitableType )
178175 {
179176 CompoundUseSiteInfo < AssemblySymbol > useSiteInfo = originalBinder . GetNewCompoundUseSiteInfo ( diagnostics ) ;
180- iDisposableConversion = classifyConversion ( fromExpression , disposableInterface , ref useSiteInfo ) ;
177+ Conversion iDisposableConversion = classifyConversion ( fromExpression , disposableInterface , ref useSiteInfo ) ;
181178 patternDisposeInfo = null ;
182179 awaitableType = null ;
183180
@@ -261,12 +258,18 @@ Conversion classifyConversion(bool fromExpression, TypeSymbol targetInterface, r
261258 if ( fromExpression )
262259 {
263260 Debug . Assert ( expressionOpt is { } ) ;
264- return conversions . ClassifyImplicitConversionFromExpression ( expressionOpt , targetInterface , ref useSiteInfo ) ;
261+ var result = conversions . ClassifyImplicitConversionFromExpression ( expressionOpt , targetInterface , ref useSiteInfo ) ;
262+
263+ Debug . Assert ( expressionOpt . Type ? . IsDynamic ( ) != true || result . Kind == ConversionKind . ImplicitDynamic ) ;
264+ return result ;
265265 }
266266 else
267267 {
268268 Debug . Assert ( declarationTypeOpt is { } ) ;
269- return conversions . ClassifyImplicitConversionFromType ( declarationTypeOpt , targetInterface , ref useSiteInfo ) ;
269+ var result = conversions . ClassifyImplicitConversionFromType ( declarationTypeOpt , targetInterface , ref useSiteInfo ) ;
270+
271+ Debug . Assert ( ! declarationTypeOpt . IsDynamic ( ) || result . Kind == ConversionKind . ImplicitDynamic ) ;
272+ return result ;
270273 }
271274 }
272275
0 commit comments