Repository: dotnet/roslyn
File: src/Compilers/CSharp/Test/Semantic/Semantics/TargetTypedConditionalOperatorTests.cs (C#)

Code before:
                        return b ? new(a) : default;
                    }
                }
                """;

            var comp = CreateCompilation(source);
            comp.VerifyDiagnostics(
                // (5,24): error CS0103: The name 'a' does not exist in the current context
                //         return b ? new(a) : default;
                Diagnostic(ErrorCode.ERR_NameNotInContext, "a").WithArguments("a").WithLocation(5, 24));

            var tree = comp.SyntaxTrees.First();
            var model = comp.GetSemanticModel(tree);

            var conditionalExpression = tree.GetCompilationUnitRoot().DescendantNodes().OfType<ConditionalExpressionSyntax>().Single();
            var typeInfo = model.GetTypeInfo(conditionalExpression);
            Assert.Null(typeInfo.Type);
            Assert.Equal("C", typeInfo.ConvertedType.ToTestDisplayString());

            var trueBranch = conditionalExpression.WhenTrue;
            var trueBranchTypeInfo = model.GetTypeInfo(trueBranch);
            Assert.Equal("C", trueBranchTypeInfo.Type.ToTestDisplayString());
            Assert.Equal("C", trueBranchTypeInfo.ConvertedType.ToTestDisplayString());
            var trueBranchSymbolInfo = model.GetSymbolInfo(trueBranch);
            Assert.Null(trueBranchSymbolInfo.Symbol);
            Assert.Collection(trueBranchSymbolInfo.CandidateSymbols,
                static c => Assert.Equal("C..ctor()", c.ToTestDisplayString()));
            var trueBranchSymbolGroup = model.GetMemberGroup(trueBranch);
            Assert.Collection(trueBranchSymbolGroup,
                static c => Assert.Equal("C..ctor()", c.ToTestDisplayString()));

            var falseBranchTypeInfo = model.GetTypeInfo(conditionalExpression.WhenFalse);
            Assert.Equal("C", falseBranchTypeInfo.Type.ToTestDisplayString());
            Assert.Equal("C", falseBranchTypeInfo.ConvertedType.ToTestDisplayString());
        }

        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/81021")]
        public void ErrorRecovery_VariableDeclaration()
        {
            var source = """
                class C
                {
                    void M(bool b)
                    {
                        C c = b ? new(a) : default;
                    }
                }
                """;

            var comp = CreateCompilation(source);
            comp.VerifyDiagnostics(

Review comment (refactor):
>trueBranchSymbolInfo.CandidateSymbols [](http://example.com/codeflow?start=30&length=37)

I think we have `ToTestDisplayStrings` helper used as follows:
```
            AssertEx.SetEqual([
                "C N1.E1.<G>$9794DAFCCB9E752B29BFD6350ADA77F2.op_Addition(C c1, C c2)",
                "C N2.E2.<G>$9794DAFCCB9E752B29BFD6350ADA77F2.op_Addition(C c1, C c2)"
                ], symbolInfo.CandidateSymbols.ToTestDisplayStrings());
```

Please use it instead, here and in other similar places.  #Closed

Code after:
                        return b ? new(a) : default;
                    }
                }
                """;

            var comp = CreateCompilation(source);
            comp.VerifyDiagnostics(
                // (5,24): error CS0103: The name 'a' does not exist in the current context
                //         return b ? new(a) : default;
                Diagnostic(ErrorCode.ERR_NameNotInContext, "a").WithArguments("a").WithLocation(5, 24));

            var tree = comp.SyntaxTrees.First();
            var model = comp.GetSemanticModel(tree);

            var conditionalExpression = tree.GetCompilationUnitRoot().DescendantNodes().OfType<ConditionalExpressionSyntax>().Single();
            var typeInfo = model.GetTypeInfo(conditionalExpression);
            Assert.Null(typeInfo.Type);
            Assert.Equal("C", typeInfo.ConvertedType.ToTestDisplayString());

            var trueBranch = conditionalExpression.WhenTrue;
            var trueBranchTypeInfo = model.GetTypeInfo(trueBranch);
            Assert.Equal("C", trueBranchTypeInfo.Type.ToTestDisplayString());
            Assert.Equal("C", trueBranchTypeInfo.ConvertedType.ToTestDisplayString());
            var trueBranchSymbolInfo = model.GetSymbolInfo(trueBranch);
            Assert.Null(trueBranchSymbolInfo.Symbol);
            Assert.Equal(CandidateReason.OverloadResolutionFailure, trueBranchSymbolInfo.CandidateReason);
            AssertEx.SetEqual(["C..ctor()"], trueBranchSymbolInfo.CandidateSymbols.ToTestDisplayStrings());
            var trueBranchSymbolGroup = model.GetMemberGroup(trueBranch);
            AssertEx.SetEqual(["C..ctor()"], trueBranchSymbolGroup.ToTestDisplayStrings());

            var falseBranchTypeInfo = model.GetTypeInfo(conditionalExpression.WhenFalse);
            Assert.Equal("C", falseBranchTypeInfo.Type.ToTestDisplayString());
            Assert.Equal("C", falseBranchTypeInfo.ConvertedType.ToTestDisplayString());
        }

        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/81021")]
        public void ErrorRecovery_VariableDeclaration()
        {
            var source = """
                class C
                {
                    void M(bool b)
                    {
                        C c = b ? new(a) : default;
                    }
                }
                """;

            var comp = CreateCompilation(source);
            comp.VerifyDiagnostics(
                // (5,23): error CS0103: The name 'a' does not exist in the current context