Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv committed Mar 19, 2024
1 parent f26ea40 commit 4de2055
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
13 changes: 7 additions & 6 deletions src/Compilers/CSharp/Portable/Binder/UsingStatementBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,16 @@ bool bindDisposable(bool fromExpression, out MethodArgumentInfo? patternDisposeI

CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = originalBinder.GetNewCompoundUseSiteInfo(diagnostics);
Conversion iDisposableConversion = classifyConversion(fromExpression, disposableInterface, ref useSiteInfo);
patternDisposeInfo = null;
awaitableType = null;

diagnostics.Add(syntax, useSiteInfo);

if (iDisposableConversion.IsImplicit)
{
if (hasAwait)
{
awaitableType = originalBinder.Compilation.GetWellKnownType(WellKnownType.System_Threading_Tasks_ValueTask);
}
patternDisposeInfo = null;

awaitableType = hasAwait
? originalBinder.Compilation.GetWellKnownType(WellKnownType.System_Threading_Tasks_ValueTask)
: null;

return !ReportUseSite(disposableInterface, diagnostics, hasAwait ? awaitKeyword : usingKeyword);
}
Expand All @@ -264,6 +263,8 @@ bool bindDisposable(bool fromExpression, out MethodArgumentInfo? patternDisposeI
Error(diagnostics, errorCode, syntax, declarationTypeOpt ?? expressionOpt!.Display);
}

patternDisposeInfo = null;
awaitableType = null;
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ public async Task M1()
}/*</bind>*/
}
public async System.Threading.Tasks.ValueTask DisposeAsync()
{
public async System.Threading.Tasks.ValueTask DisposeAsync()
{
await Task.Yield();
}
}
Expand Down Expand Up @@ -204,8 +204,8 @@ public async Task M1()
}/*</bind>*/
}
async ValueTask IAsyncDisposable.DisposeAsync()
{
async ValueTask IAsyncDisposable.DisposeAsync()
{
await Task.Yield();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,10 @@ static async Task Main()
";
var expected = new[]
{
// (8,15): error CS8652: The feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater.
// 0.cs(8,9): error CS8370: Feature 'pattern-based disposal' is not available in C# 7.3. Please use language version 8.0 or greater.
// await using IAsyncDisposable x = null;
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7_3, "await using IAsyncDisposable x = null;").WithArguments("pattern-based disposal", "8.0").WithLocation(8, 9),
// 0.cs(8,15): error CS8370: Feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater.
// await using IAsyncDisposable x = null;
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7_3, "using").WithArguments("using declarations", "8.0").WithLocation(8, 15)
};
Expand Down

0 comments on commit 4de2055

Please sign in to comment.