Skip to content

Commit

Permalink
Add assertions for shape of possibly intercepted call (#68447)
Browse files Browse the repository at this point in the history
  • Loading branch information
RikkiGibson authored Jun 9, 2023
1 parent d9a4149 commit 0386fd6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
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

0 comments on commit 0386fd6

Please sign in to comment.