diff --git a/src/Compilers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs b/src/Compilers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs index 903bdb32e579f..6db5d2f55bf29 100644 --- a/src/Compilers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs +++ b/src/Compilers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs @@ -821,13 +821,19 @@ static ImmutableArray getArgumentRefKinds(MethodSymbol method, bool use { var result = method.ParameterRefKinds; - if (useStrictArgumentRefKinds && result.Contains(RefKind.In)) + if (!result.IsDefaultOrEmpty && (result.Contains(RefKind.RefReadOnlyParameter) || + (useStrictArgumentRefKinds && result.Contains(RefKind.In)))) { var builder = ArrayBuilder.GetInstance(result.Length); foreach (var refKind in result) { - builder.Add(refKind == RefKind.In ? RefKindExtensions.StrictIn : refKind); + builder.Add(refKind switch + { + RefKind.In or RefKind.RefReadOnlyParameter when useStrictArgumentRefKinds => RefKindExtensions.StrictIn, + RefKind.RefReadOnlyParameter => RefKind.In, + _ => refKind + }); } return builder.ToImmutableAndFree(); diff --git a/src/Compilers/CSharp/Test/Emit2/Semantics/RefReadonlyParameterTests.cs b/src/Compilers/CSharp/Test/Emit2/Semantics/RefReadonlyParameterTests.cs index 1ebdaf0de08d1..3fa645c87bba8 100644 --- a/src/Compilers/CSharp/Test/Emit2/Semantics/RefReadonlyParameterTests.cs +++ b/src/Compilers/CSharp/Test/Emit2/Semantics/RefReadonlyParameterTests.cs @@ -2089,7 +2089,7 @@ void M(ref readonly int p) Diagnostic(ErrorCode.ERR_AssgReadonly, "rorro").WithLocation(23, 9)); } - [Fact(Skip = "https://github.com/dotnet/roslyn/issues/68714")] + [ConditionalFact(typeof(WindowsOnly), Reason = ConditionalSkipReason.RestrictedTypesNeedDesktop)] public void RefReadonlyParameter_Arglist() { var source = """ @@ -2105,7 +2105,11 @@ static void Main() } } """; - var verifier = CompileAndVerify(source, expectedOutput: "111"); + var verifier = CompileAndVerify(source, verify: Verification.FailsILVerify, expectedOutput: """ + 111 + 111 + 111 + """); verifier.VerifyDiagnostics( // (7,11): warning CS9503: Argument 1 should be passed with 'ref' or 'in' keyword // M(x, __arglist(x)); diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/OverloadResolutionTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/OverloadResolutionTests.cs index 22c292a8e1281..e60b63ed2e7b4 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/OverloadResolutionTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/OverloadResolutionTests.cs @@ -9706,7 +9706,7 @@ static unsafe void Main() verify: Verification.Fails).VerifyDiagnostics(expectedDiagnostics); } - [Fact(Skip = "https://github.com/dotnet/roslyn/issues/68714")] + [ConditionalFact(typeof(WindowsOnly), Reason = ConditionalSkipReason.RestrictedTypesNeedDesktop)] public void PassingArgumentsToInParameters_Arglist() { var source = """ @@ -9723,9 +9723,9 @@ static void Main() } """; CreateCompilation(source, parseOptions: TestOptions.Regular11).VerifyDiagnostics( - // (8,15): error CS1615: Argument 1 may not be passed with the 'ref' keyword + // (8,15): error CS9505: Argument 1 may not be passed with the 'ref' keyword in language version 11.0. To pass 'ref' arguments to 'in' parameters, upgrade to language version preview or greater. // M(ref x, __arglist(x)); - Diagnostic(ErrorCode.ERR_BadArgExtraRef, "x").WithArguments("1", "ref").WithLocation(8, 15)); + Diagnostic(ErrorCode.ERR_BadArgExtraRefLangVersion, "x").WithArguments("1", "11.0", "preview").WithLocation(8, 15)); var expectedDiagnostics = new[] { @@ -9734,8 +9734,8 @@ static void Main() Diagnostic(ErrorCode.WRN_BadArgRef, "x").WithArguments("1").WithLocation(8, 15) }; - CompileAndVerify(source, expectedOutput: "555", parseOptions: TestOptions.RegularNext).VerifyDiagnostics(expectedDiagnostics); - CompileAndVerify(source, expectedOutput: "555").VerifyDiagnostics(expectedDiagnostics); + CompileAndVerify(source, expectedOutput: "555", verify: Verification.FailsILVerify, parseOptions: TestOptions.RegularNext).VerifyDiagnostics(expectedDiagnostics); + CompileAndVerify(source, expectedOutput: "555", verify: Verification.FailsILVerify).VerifyDiagnostics(expectedDiagnostics); } [Fact]