Repository: dotnet/roslyn
File: src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs (C#)

Code before:
            return false;
        }

        private BoundExpression BindNameofOperatorInternal(InvocationExpressionSyntax node, BindingDiagnosticBag diagnostics)
        {
            CheckFeatureAvailability(node, MessageID.IDS_FeatureNameof, diagnostics);
            var argument = node.ArgumentList.Arguments[0].Expression;
            var boundArgument = BindExpression(argument, diagnostics);

            bool syntaxIsOk = CheckSyntaxForNameofArgument(argument, out string name, boundArgument.HasAnyErrors ? BindingDiagnosticBag.Discarded : diagnostics);
            if (boundArgument is BoundMethodGroup methodGroup)
            {
                if (!boundArgument.HasAnyErrors && syntaxIsOk)
                {
                    if (!methodGroup.TypeArgumentsOpt.IsDefaultOrEmpty)
                    {
                        // method group with type parameters not allowed
                        diagnostics.Add(ErrorCode.ERR_NameofMethodGroupWithTypeParameters, argument.Location);
                    }
                    else
                    {
                        EnsureNameofExpressionSymbols(methodGroup, diagnostics);
                    }
                }

                bool useType = !Compilation.IsFeatureEnabled(MessageID.IDS_FeatureInstanceMemberInNameof);
                boundArgument = methodGroup.Update(
                    methodGroup.TypeArgumentsOpt,
                    methodGroup.Name,
                    methodGroup.Methods,
                    methodGroup.LookupSymbolOpt,
                    methodGroup.LookupError,
                    methodGroup.Flags,
                    methodGroup.FunctionType,
                    receiverOpt: ReplaceTypeOrValueReceiver(methodGroup.ReceiverOpt, useType: useType, BindingDiagnosticBag.Discarded), //only change
                    methodGroup.ResultKind);
            }
            else if (boundArgument is BoundPropertyAccess propertyAccess)
            {
                if (propertyAccess.PropertySymbol.IsExtensionBlockMember())
                {
                    diagnostics.Add(ErrorCode.ERR_NameofExtensionMember, boundArgument.Syntax);
                }
            }
            else if (boundArgument is BoundNamespaceExpression nsExpr)
            {
                diagnostics.AddAssembliesUsedByNamespaceReference(nsExpr.NamespaceSymbol);
            }
            else if (boundArgument is BoundIndexerAccess indexerAccess)
            {
                // nameof(x[y]) where the argument is an indexer is an error. Ref analysis requires

Review comment (suggestion):
>bool useType = !Compilation.IsFeatureEnabled(MessageID.IDS_FeatureInstanceMemberInNameof); [](http://example.com/codeflow?start=16&length=90)

Is there an observable difference from this check? I cannot tell from the added tests. #Closed

Code after:
            return false;
        }

        private BoundExpression BindNameofOperatorInternal(InvocationExpressionSyntax node, BindingDiagnosticBag diagnostics)
        {
            CheckFeatureAvailability(node, MessageID.IDS_FeatureNameof, diagnostics);
            var argument = node.ArgumentList.Arguments[0].Expression;
            var boundArgument = BindExpression(argument, diagnostics);

            bool syntaxIsOk = CheckSyntaxForNameofArgument(argument, out string name, boundArgument.HasAnyErrors ? BindingDiagnosticBag.Discarded : diagnostics);
            if (boundArgument is BoundMethodGroup methodGroup)
            {
                if (!boundArgument.HasAnyErrors && syntaxIsOk)
                {
                    if (!methodGroup.TypeArgumentsOpt.IsDefaultOrEmpty)
                    {
                        // method group with type parameters not allowed
                        diagnostics.Add(ErrorCode.ERR_NameofMethodGroupWithTypeParameters, argument.Location);
                    }
                    else
                    {
                        EnsureNameofExpressionSymbols(methodGroup, diagnostics);
                    }
                }

                boundArgument = methodGroup.Update(
                    methodGroup.TypeArgumentsOpt,
                    methodGroup.Name,
                    methodGroup.Methods,
                    methodGroup.LookupSymbolOpt,
                    methodGroup.LookupError,
                    methodGroup.Flags,
                    methodGroup.FunctionType,
                    receiverOpt: ReplaceTypeOrValueReceiver(methodGroup.ReceiverOpt, useType: true, boundArgument.HasAnyErrors ? BindingDiagnosticBag.Discarded : diagnostics), //only change
                    methodGroup.ResultKind);
            }
            else if (boundArgument is BoundPropertyAccess propertyAccess)
            {
                if (propertyAccess.PropertySymbol.IsExtensionBlockMember())
                {
                    diagnostics.Add(ErrorCode.ERR_NameofExtensionMember, boundArgument.Syntax);
                }
            }
            else if (boundArgument is BoundNamespaceExpression nsExpr)
            {
                diagnostics.AddAssembliesUsedByNamespaceReference(nsExpr.NamespaceSymbol);
            }
            else if (boundArgument is BoundIndexerAccess indexerAccess)
            {
                // nameof(x[y]) where the argument is an indexer is an error. Ref analysis requires
                // the indexer to be recognized as get, set, or both. We don't know which was