diff --git a/src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs b/src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs index 3a8d05bf62d28d44d9dfb6c836241cce1a526d7b..080982a01177a7801875997fbf401976415e9738 100644 --- a/src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs +++ b/src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs @@ -4447,7 +4447,7 @@ private static BoundConversion GetConversionIfApplicable(BoundExpression convers return operandType; } } - if (operandType.Type?.IsTupleType == true) + if (operandType.Type?.IsTupleType == true || conversionOperand.Kind == BoundKind.TupleLiteral) { goto case ConversionKind.ImplicitTuple; } @@ -4550,7 +4550,7 @@ private static BoundConversion GetConversionIfApplicable(BoundExpression convers } } - if (checkConversion) + if (checkConversion && !targetType.IsErrorType()) { // https://github.com/dotnet/roslyn/issues/29699: Report warnings for user-defined conversions on tuple elements. conversion = GenerateConversion(_conversions, conversionOperand, operandType.Type, targetType, fromExplicitCast, extensionMethodThisArgument); diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs index 86081cb4c5d2e8ae2b95fd260dad56d5301bb0ed..f65d407093deaff5a87a2fafcf3c1bba763cce1b 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs @@ -51919,7 +51919,8 @@ static void F(object? x, object? y) Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "t.Rest.Item2").WithLocation(11, 13)); } - [Fact(Skip = "https://github.com/dotnet/roslyn/issues/35157")] + [Fact] + [WorkItem(35157, "https://github.com/dotnet/roslyn/issues/35157")] public void TupleTypeInference_08() { var source = @@ -51929,11 +51930,23 @@ class C void M() { _ = (null, 2); + _ = (null, (2, 3)); + _ = (null, (null, (2, 3))); } }"; var comp = CreateCompilation(source, options: WithNonNullTypesTrue()); - comp.VerifyDiagnostics(); + comp.VerifyDiagnostics( + // (6,9): error CS8183: Cannot infer the type of implicitly-typed discard. + // _ = (null, 2); + Diagnostic(ErrorCode.ERR_DiscardTypeInferenceFailed, "_").WithLocation(6, 9), + // (7,9): error CS8183: Cannot infer the type of implicitly-typed discard. + // _ = (null, (2, 3)); + Diagnostic(ErrorCode.ERR_DiscardTypeInferenceFailed, "_").WithLocation(7, 9), + // (8,9): error CS8183: Cannot infer the type of implicitly-typed discard. + // _ = (null, (null, (2, 3))); + Diagnostic(ErrorCode.ERR_DiscardTypeInferenceFailed, "_").WithLocation(8, 9) + ); } [Fact] diff --git a/src/EditorFeatures/CSharpTest/NameTupleElement/NameTupleElementTests.cs b/src/EditorFeatures/CSharpTest/NameTupleElement/NameTupleElementTests.cs index 3d79f05afae29335dedcfd7a4cc16631ea656cc6..186168c736d1ef5efc46f318686df7e34ed98906 100644 --- a/src/EditorFeatures/CSharpTest/NameTupleElement/NameTupleElementTests.cs +++ b/src/EditorFeatures/CSharpTest/NameTupleElement/NameTupleElementTests.cs @@ -5,6 +5,7 @@ using Microsoft.CodeAnalysis.CSharp.NameTupleElement; using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeRefactorings; using Microsoft.CodeAnalysis.Test.Utilities; +using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.NameTupleElement @@ -85,7 +86,8 @@ public async Task TestInCall_FirstElement_AlreadyNamed() await TestMissingAsync(@"class C { void M((int arg1, int arg2) x) => M(([||]arg1: 1, 2)); }"); } - [Fact(Skip = "https://github.com/dotnet/roslyn/issues/35157")] + [Fact] + [WorkItem(35157, "https://github.com/dotnet/roslyn/issues/35157")] public async Task TestUntypedTuple() { await TestMissingAsync(