diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs index f285780bc03e6..d2e2524286523 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs @@ -2090,12 +2090,12 @@ private BoundExpression BindNonMethod(SimpleNameSyntax node, Symbol symbol, Bind } else if (parameter.IsExtensionParameter() && (InParameterDefaultValue || InAttributeArgument || - this.ContainingMember() is not { Kind: not SymbolKind.NamedType, IsStatic: false } || // We are not in an instance member + this.ContainingMember() is null or { Kind: SymbolKind.NamedType } or { IsStatic: true } || // We are not in an instance member (object)this.ContainingMember().ContainingSymbol != parameter.ContainingSymbol) && !IsInsideNameof) { // Give a better error for the simple case of using an extension parameter in a static member, while avoiding any of the other cases where it is always illegal - if (this.ContainingMember().IsStatic && !InParameterDefaultValue && !InAttributeArgument && (object)this.ContainingMember().ContainingSymbol == parameter.ContainingSymbol) + if (this.ContainingMember() is { IsStatic: true } && !InParameterDefaultValue && !InAttributeArgument && (object)this.ContainingMember().ContainingSymbol == parameter.ContainingSymbol) { // Static members cannot access the value of extension parameter '{0}'. Error(diagnostics, ErrorCode.ERR_ExtensionParameterInStaticContext, node, parameter.Name);