Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,10 @@ static bool bindInvocationExpressionContinued(
var methodResult = result.ValidResult;
var method = methodResult.Member;

// PROTOTYPE: It looks like we added a bunch of code in BindInvocationExpressionContinued at this position
// that specifically deals with new extension methods. It adjusts analyzedArguments, etc.
// It is very likely we need to do the same here.

// It is possible that overload resolution succeeded, but we have chosen an
// instance method and we're in a static method. A careful reading of the
// overload resolution spec shows that the "final validation" stage allows an
Expand Down Expand Up @@ -1659,7 +1663,7 @@ internal static BoundExpression GetUnderlyingCollectionExpressionElement(BoundCo
// Add methods. This case can be hit for spreads and non-spread elements.
Debug.Assert(call.HasErrors);
Debug.Assert(call.Method.Name == "Add");
return call.Arguments[call.InvokedAsExtensionMethod ? 1 : 0];
return call.Arguments[call.InvokedAsExtensionMethod ? 1 : 0]; // PROTOTYPE: Add test coverage for new extensions
case BoundBadExpression badExpression:
Debug.Assert(false); // Add test if we hit this assert.
return badExpression;
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Binder/Binder_Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ private void ReduceFrom(FromClauseSyntax from, QueryTranslationState state, Bind

private static BoundExpression? ExtractCastInvocation(BoundCall invocation)
{
int index = invocation.InvokedAsExtensionMethod ? 1 : 0;
int index = invocation.InvokedAsExtensionMethod ? 1 : 0; // PROTOTYPE: Add test coverage for his code path
var c1 = invocation.Arguments[index] as BoundConversion;
var l1 = c1 != null ? c1.Operand as BoundLambda : null;
var r1 = l1 != null ? l1.Body.Statements[0] as BoundReturnStatement : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4517,6 +4517,7 @@ static MethodSymbol addMethodAsMemberOfContainingType(BoundCollectionElementInit
}
else
{
// PROTOTYPE: Do we need to do anything special for new extensions here?
method = (MethodSymbol)AsMemberOfType(containingType, method);
}

Expand Down Expand Up @@ -6329,6 +6330,7 @@ private static BoundExpression CreatePlaceholderIfNecessary(BoundExpression expr
// Only instance receivers go through VisitRvalue; arguments go through VisitArgumentEvaluate.
if (node.ReceiverOpt is not null)
{
// PROTOTYPE: Do we need to do anything special for new extensions here?
VisitRvalueEpilogue(receiver); // VisitRvalue does this after visiting each node
receiverType = ResultType;
CheckCallReceiver(receiver, receiverType, node.Method);
Expand Down Expand Up @@ -6394,6 +6396,7 @@ TypeWithState visitAndCheckReceiver(BoundCall node)

void reinferMethodAndVisitArguments(BoundCall node, TypeWithState receiverType, VisitResult? firstArgumentResult = null)
{
// PROTOTYPE: Do we need to do anything special for new extensions here?
var method = node.Method;
ImmutableArray<RefKind> refKindsOpt = node.ArgumentRefKindsOpt;
if (!receiverType.HasNullType)
Expand Down Expand Up @@ -8981,10 +8984,12 @@ private TypeWithState VisitConversion(
{
VisitLocalFunctionUse(localFunc);
}
// PROTOTYPE: Do we need to do anything special for new extensions here?
method = CheckMethodGroupReceiverNullability(group, parameters, method, conversion.IsExtensionMethod);
}
if (reportRemainingWarnings && invokeSignature != null)
{
// PROTOTYPE: Do we need to do anything special for new extensions here?
ReportNullabilityMismatchWithTargetDelegate(getDiagnosticLocation(), targetType, invokeSignature, method, conversion.IsExtensionMethod);
}
}
Expand Down Expand Up @@ -9941,6 +9946,7 @@ private MethodSymbol CheckMethodGroupReceiverNullability(BoundMethodGroup group,
var receiverOpt = group.ReceiverOpt;
if (TryGetMethodGroupReceiverNullability(receiverOpt, out TypeWithState receiverType))
{
// PROTOTYPE: Do we need to do anything special for new extensions here?
var syntax = group.Syntax;
if (!invokedAsExtensionMethod)
{
Expand Down Expand Up @@ -10312,6 +10318,7 @@ private void VisitDeconstructMethodArguments(ArrayBuilder<DeconstructionVariable
int n = variables.Count;
if (!invocation.InvokedAsExtensionMethod)
{
// PROTOTYPE: Do we need to do anything special for new extensions here?
_ = CheckPossibleNullReceiver(right);

// update the deconstruct method with any inferred type parameters of the containing type
Expand Down Expand Up @@ -10345,7 +10352,7 @@ private void VisitDeconstructMethodArguments(ArrayBuilder<DeconstructionVariable
int offset = invocation.InvokedAsExtensionMethod ? 1 : 0;
Debug.Assert(parameters.Length - offset == n);

if (invocation.InvokedAsExtensionMethod)
if (invocation.InvokedAsExtensionMethod) // PROTOTYPE: Do we need to do anything special for new extensions here?
{
// Check nullability for `this` parameter
var argConversion = RemoveConversion(invocation.Arguments[0], includeExplicitConversions: false).conversion;
Expand Down