public override BoundNode VisitDynamicInvocation(BoundDynamicInvocation node) { return this.SetMayHaveSideEffects(); }
public override BoundNode VisitDynamicInvocation(BoundDynamicInvocation node) { return(this.SetMayHaveSideEffects()); }
public BoundExpression VisitDynamicInvocation(BoundDynamicInvocation node, bool resultDiscarded) { var loweredArguments = VisitList(node.Arguments); bool hasImplicitReceiver; BoundExpression loweredReceiver; ImmutableArray<TypeSymbol> typeArguments; string name; switch (node.Expression.Kind) { case BoundKind.MethodGroup: // method invocation BoundMethodGroup methodGroup = (BoundMethodGroup)node.Expression; typeArguments = methodGroup.TypeArgumentsOpt; name = methodGroup.Name; hasImplicitReceiver = (methodGroup.Flags & BoundMethodGroupFlags.HasImplicitReceiver) != 0; // Should have been eliminated during binding of dynamic invocation: Debug.Assert(methodGroup.ReceiverOpt == null || methodGroup.ReceiverOpt.Kind != BoundKind.TypeOrValueExpression); if (methodGroup.ReceiverOpt == null) { // Calling a static method defined on an outer class via its simple name. NamedTypeSymbol firstContainer = node.ApplicableMethods.First().ContainingType; Debug.Assert(node.ApplicableMethods.All(m => m.IsStatic && m.ContainingType == firstContainer)); loweredReceiver = new BoundTypeExpression(node.Syntax, null, firstContainer); } else if (hasImplicitReceiver && _factory.TopLevelMethod.IsStatic) { // Calling a static method defined on the current class via its simple name. loweredReceiver = new BoundTypeExpression(node.Syntax, null, _factory.CurrentType); } else { loweredReceiver = VisitExpression(methodGroup.ReceiverOpt); } // If we are calling a method on a NoPIA type, we need to embed all methods/properties // with the matching name of this dynamic invocation. EmbedIfNeedTo(loweredReceiver, methodGroup.Methods, node.Syntax); break; case BoundKind.DynamicMemberAccess: // method invocation var memberAccess = (BoundDynamicMemberAccess)node.Expression; name = memberAccess.Name; typeArguments = memberAccess.TypeArgumentsOpt; loweredReceiver = VisitExpression(memberAccess.Receiver); hasImplicitReceiver = false; break; default: // delegate invocation var loweredExpression = VisitExpression(node.Expression); return _dynamicFactory.MakeDynamicInvocation(loweredExpression, loweredArguments, node.ArgumentNamesOpt, node.ArgumentRefKindsOpt, resultDiscarded).ToExpression(); } Debug.Assert(loweredReceiver != null); return _dynamicFactory.MakeDynamicMemberInvocation( name, loweredReceiver, typeArguments, loweredArguments, node.ArgumentNamesOpt, node.ArgumentRefKindsOpt, hasImplicitReceiver, resultDiscarded).ToExpression(); }
public override BoundNode VisitDynamicInvocation(BoundDynamicInvocation node) { if (_inExpressionLambda) { Error(ErrorCode.ERR_ExpressionTreeContainsDynamicOperation, node); // avoid reporting errors for the method group: if (node.Expression.Kind == BoundKind.MethodGroup) { return base.VisitMethodGroup((BoundMethodGroup)node.Expression); } } return base.VisitDynamicInvocation(node); }
public override BoundNode VisitDynamicInvocation(BoundDynamicInvocation node) { return VisitDynamicInvocation(node, resultDiscarded: false); }