Skip to content
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

Add assertions for shape of possibly intercepted call #68447

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/BoundTree/BoundExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ public Location? InterceptableLocation
{
get
{
// When this assertion fails, it means a new syntax is being used which corresponds to a BoundCall.
// The developer needs to determine how this new syntax should interact with interceptors (produce an error, permit intercepting the call, etc...)
Debug.Assert(this.WasCompilerGenerated || this.Syntax is InvocationExpressionSyntax or ConstructorInitializerSyntax or PrimaryConstructorBaseTypeSyntax { ArgumentList: { } },
$"Unexpected syntax kind for BoundCall: {this.Syntax.Kind()}");

if (this.WasCompilerGenerated || this.Syntax is not InvocationExpressionSyntax syntax)
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ private void InterceptCallAndAdjustArguments(
bool invokedAsExtensionMethod,
Location? interceptableLocation)
{
// PROTOTYPE(ic):
// Add assertions for the possible shapes of calls which could come through this method.
// When the BoundCall shape changes in the future, force developer to decide what to do here.

if (this._compilation.TryGetInterceptor(interceptableLocation) is not var (attributeLocation, interceptor))
{
// The call was not intercepted.
Expand Down