-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Move runtime async method validation into initial binding #78310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
351c386
442f9f8
216d5c9
ff721e5
1f5aefc
33a4423
7918319
9df8371
c10918c
459f528
0e5c942
fa1b1d9
20273bb
5a789ef
3bb7189
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -316,7 +316,7 @@ internal bool IsNullableAnalysisEnabledAlways | |
/// Returns true if this method should be processed with runtime async handling instead | ||
/// of compiler async state machine generation. | ||
/// </summary> | ||
internal bool IsRuntimeAsyncEnabledIn(MethodSymbol method) | ||
internal bool IsRuntimeAsyncEnabledIn(Symbol? symbol) | ||
{ | ||
// PROTOTYPE: EE tests fail this assert, handle and test | ||
//Debug.Assert(ReferenceEquals(method.ContainingAssembly, Assembly)); | ||
|
@@ -325,7 +325,21 @@ internal bool IsRuntimeAsyncEnabledIn(MethodSymbol method) | |
return false; | ||
} | ||
|
||
return method switch | ||
if (symbol is not MethodSymbol method) | ||
{ | ||
return false; | ||
} | ||
|
||
var methodReturn = method.ReturnType.OriginalDefinition; | ||
if (!ReferenceEquals(methodReturn, GetSpecialType(InternalSpecialType.System_Threading_Tasks_Task)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice if there a way to say something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I think we can, since this is special types, not well-known types. |
||
&& !ReferenceEquals(methodReturn, GetSpecialType(InternalSpecialType.System_Threading_Tasks_Task_T)) | ||
&& !ReferenceEquals(methodReturn, GetSpecialType(InternalSpecialType.System_Threading_Tasks_ValueTask)) | ||
&& !ReferenceEquals(methodReturn, GetSpecialType(InternalSpecialType.System_Threading_Tasks_ValueTask_T))) | ||
{ | ||
return false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a corresponding update to the design doc? Or should we have a follow-up comment to make the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to update the design doc, the runtime-side is very clear that only Task/ValueTask methods can be runtime async. |
||
} | ||
|
||
return symbol switch | ||
{ | ||
SourceMethodSymbol { IsRuntimeAsyncEnabledInMethod: ThreeState.True } => true, | ||
SourceMethodSymbol { IsRuntimeAsyncEnabledInMethod: ThreeState.False } => false, | ||
|
@@ -2211,11 +2225,12 @@ internal bool ReturnsAwaitableToVoidOrInt(MethodSymbol method, BindingDiagnostic | |
var dumbInstance = new BoundLiteral(syntax, ConstantValue.Null, namedType); | ||
var binder = GetBinder(syntax); | ||
BoundExpression? result; | ||
var success = binder.GetAwaitableExpressionInfo(dumbInstance, out result, syntax, diagnostics); | ||
var success = binder.GetAwaitableExpressionInfo(dumbInstance, out result, out MethodSymbol? runtimeAwaitMethod, syntax, diagnostics); | ||
|
||
RoslynDebug.Assert(!namedType.IsDynamic()); | ||
return success && | ||
(result!.Type!.IsVoidType() || result.Type!.SpecialType == SpecialType.System_Int32); | ||
Debug.Assert(result is { Type: not null } || runtimeAwaitMethod is { ReturnType: not null }); | ||
var returnType = result?.Type ?? runtimeAwaitMethod!.ReturnType; | ||
return success && (returnType.IsVoidType() || returnType.SpecialType == SpecialType.System_Int32); | ||
} | ||
|
||
/// <summary> | ||
|
Uh oh!
There was an error while loading. Please reload this page.