Skip to content

Incorrect "CS0229 Ambiguity between" for partial prop with primary ctor, at design time only #76651

@jnm2

Description

@jnm2

Version Used: 17.13.0 Preview 2.1

Thanks to @RoccoZero who reported that this issue has been happening for a few months.

  1. Building succeeds, though the error list and code editor show the errors.
  2. The repro requires separate source files.
  3. The repro disappears if the primary ctor is deleted.
.csproj
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net9.0</TargetFramework>
  </PropertyGroup>

</Project>
File 1
partial class PartialClass
{
    public partial string Prop => null;
}

partial class PartialClass(int p)
{
    public partial string Prop { get; }
}
File 2
class Repro
{
    void M(PartialClass c)
    {
        // ❌ CS0229 Ambiguity between 'PartialClass.Prop' and 'PartialClass.Prop'
        _ = c.Prop;
        _ = c.Prop; // Yep, error still here.
        _ = new PartialClass(0).Prop; // No error here!
        _ = c.Prop; // ERROR DISAPPEARS
        _ = c.Prop; // IT'S STILL GONE
    }
}

Image

Image

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions