diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs index b5e2811d66d113619b5d9db10605caeb04ee9b55..b66cb01e0c6e94e47e0ade80c29b5325a2d2b008 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs @@ -3377,16 +3377,19 @@ private static bool IsNegativeConstantForArraySize(BoundExpression expression) var refKinds = analyzedArguments.RefKinds.ToImmutableOrNull(); var argsToParamsOpt = memberResolutionResult.Result.ArgsToParamsOpt; - hasErrors |= !CheckInvocationArgMixing( - nonNullSyntax, - resultMember, - receiver, - resultMember.Parameters, - arguments, - refKinds, - argsToParamsOpt, - this.LocalScopeDepth, - diagnostics); + if (!hasErrors) + { + hasErrors = !CheckInvocationArgMixing( + nonNullSyntax, + resultMember, + receiver, + resultMember.Parameters, + arguments, + refKinds, + argsToParamsOpt, + this.LocalScopeDepth, + diagnostics); + } return new BoundCall( nonNullSyntax, @@ -4491,16 +4494,20 @@ private bool IsConstructorAccessible(MethodSymbol constructor, ref HashSet throw null; + public int this[int x] => throw null; + public S1(S1 x, int y) => throw null; + } + + static void Main() + { + // these are all errors, we should not be doing escape analysis on them. + S1.Test(1); + var x = S1[1]; + var y = new S1(S1, 1); + } +}"); + + comp.VerifyDiagnostics( + // (14,9): error CS0120: An object reference is required for the non-static field, method, or property 'Program.S1.Test(int)' + // S1.Test(1); + Diagnostic(ErrorCode.ERR_ObjectRequired, "S1.Test").WithArguments("Program.S1.Test(int)").WithLocation(14, 9), + // (15,17): error CS0119: 'Program.S1' is a type, which is not valid in the given context + // var x = S1[1]; + Diagnostic(ErrorCode.ERR_BadSKunknown, "S1").WithArguments("Program.S1", "type").WithLocation(15, 17), + // (16,24): error CS0119: 'Program.S1' is a type, which is not valid in the given context + // var y = new S1(S1, 1); + Diagnostic(ErrorCode.ERR_BadSKunknown, "S1").WithArguments("Program.S1", "type").WithLocation(16, 24) + ); + } } }