@@ -19777,6 +19777,129 @@ class C(int p)
19777
19777
AssertEx.Equal("System.Int32 C.this[System.Int32 i] { get; }", info.Symbol.ToTestDisplayString());
19778
19778
}
19779
19779
19780
+ [WorkItem("https://github.com/dotnet/roslyn/issues/75002")]
19781
+ [Fact]
19782
+ public void PartialMembers_01()
19783
+ {
19784
+ var source1 = """
19785
+ C c = null;
19786
+ c.M();
19787
+ _ = c.P;
19788
+ """;
19789
+ var source2 = """
19790
+ partial class C(int p)
19791
+ {
19792
+ public partial void M() { }
19793
+ public partial void M();
19794
+ public partial object P { get; }
19795
+ public partial object P { get => null; }
19796
+ }
19797
+ """;
19798
+ var comp = CreateCompilation([source1, source2]);
19799
+ var tree = comp.SyntaxTrees[0];
19800
+ var model = comp.GetSemanticModel(tree);
19801
+ model.GetDiagnostics().Verify(
19802
+ // (2,3): error CS0121: The call is ambiguous between the following methods or properties: 'C.M()' and 'C.M()'
19803
+ // c.M();
19804
+ Diagnostic(ErrorCode.ERR_AmbigCall, "M").WithArguments("C.M()", "C.M()").WithLocation(2, 3),
19805
+ // (3,7): error CS0229: Ambiguity between 'C.P' and 'C.P'
19806
+ // _ = c.P;
19807
+ Diagnostic(ErrorCode.ERR_AmbigMember, "P").WithArguments("C.P", "C.P").WithLocation(3, 7));
19808
+ }
19809
+
19810
+ [Fact]
19811
+ public void NullableAttributes_01()
19812
+ {
19813
+ var source1 = """
19814
+ #nullable enable
19815
+ C c = null!;
19816
+ object o;
19817
+ o = c.M();
19818
+ o = c.P;
19819
+ """;
19820
+ var source2 = """
19821
+ #nullable enable
19822
+ using System.Diagnostics.CodeAnalysis;
19823
+ class C(int p)
19824
+ {
19825
+ [return: MaybeNull] public object M() => new();
19826
+ [MaybeNull] public object P { get => new(); }
19827
+ }
19828
+ """;
19829
+ var comp = CreateCompilation([source1, source2]);
19830
+ var tree = comp.SyntaxTrees[0];
19831
+ var model = comp.GetSemanticModel(tree);
19832
+ model.GetDiagnostics().Verify();
19833
+ }
19834
+
19835
+ [WorkItem("https://github.com/dotnet/roslyn/issues/75002")]
19836
+ [Fact]
19837
+ public void NullableAttributes_PartialMembers_01()
19838
+ {
19839
+ var source1 = """
19840
+ #nullable enable
19841
+ C c = null!;
19842
+ object o;
19843
+ o = c.M();
19844
+ o = c.P;
19845
+ """;
19846
+ var source2 = """
19847
+ #nullable enable
19848
+ using System.Diagnostics.CodeAnalysis;
19849
+ partial class C(int p)
19850
+ {
19851
+ public partial object M() => new();
19852
+ [return: MaybeNull] public partial object M();
19853
+ [MaybeNull] public partial object P { get; }
19854
+ public partial object P { get => new(); }
19855
+ }
19856
+ """;
19857
+ var comp = CreateCompilation([source1, source2]);
19858
+ var tree = comp.SyntaxTrees[0];
19859
+ var model = comp.GetSemanticModel(tree);
19860
+ model.GetDiagnostics().Verify(
19861
+ // (4,7): error CS0121: The call is ambiguous between the following methods or properties: 'C.M()' and 'C.M()'
19862
+ // o = c.M();
19863
+ Diagnostic(ErrorCode.ERR_AmbigCall, "M").WithArguments("C.M()", "C.M()").WithLocation(4, 7),
19864
+ // (5,7): error CS0229: Ambiguity between 'C.P' and 'C.P'
19865
+ // o = c.P;
19866
+ Diagnostic(ErrorCode.ERR_AmbigMember, "P").WithArguments("C.P", "C.P").WithLocation(5, 7));
19867
+ }
19868
+
19869
+ [WorkItem("https://github.com/dotnet/roslyn/issues/75002")]
19870
+ [Fact]
19871
+ public void NullableAttributes_PartialMembers_02()
19872
+ {
19873
+ var source1 = """
19874
+ #nullable enable
19875
+ C c = null!;
19876
+ object o;
19877
+ o = c.M();
19878
+ o = c.P;
19879
+ """;
19880
+ var source2 = """
19881
+ #nullable enable
19882
+ using System.Diagnostics.CodeAnalysis;
19883
+ partial class C(int p)
19884
+ {
19885
+ [return: MaybeNull] public partial object M() => new();
19886
+ public partial object M();
19887
+ public partial object P { get; }
19888
+ [MaybeNull] public partial object P { get => new(); }
19889
+ }
19890
+ """;
19891
+ var comp = CreateCompilation([source1, source2]);
19892
+ var tree = comp.SyntaxTrees[0];
19893
+ var model = comp.GetSemanticModel(tree);
19894
+ model.GetDiagnostics().Verify(
19895
+ // (4,7): error CS0121: The call is ambiguous between the following methods or properties: 'C.M()' and 'C.M()'
19896
+ // o = c.M();
19897
+ Diagnostic(ErrorCode.ERR_AmbigCall, "M").WithArguments("C.M()", "C.M()").WithLocation(4, 7),
19898
+ // (5,7): error CS0229: Ambiguity between 'C.P' and 'C.P'
19899
+ // o = c.P;
19900
+ Diagnostic(ErrorCode.ERR_AmbigMember, "P").WithArguments("C.P", "C.P").WithLocation(5, 7));
19901
+ }
19902
+
19780
19903
[Fact]
19781
19904
public void IllegalCapturingInStruct_01()
19782
19905
{
0 commit comments