Skip to content

Report error implementing unannotated interface member with [UnscopedRef] member #64508

@cston

Description

@cston

Report an error when an unannotated interface member is implemented with an [UnscopedRef] member, such as S1.GetRef() and S2.GetRef() below.

using System.Diagnostics.CodeAnalysis;

interface I<T>
{
    ref T GetRef();
}

struct S1 : I<int>
{
    private int _f;
    [UnscopedRef] public ref int GetRef() => ref _f;
}

struct S2 : I<int>
{
    private int _f;
    [UnscopedRef] ref int I<int>.GetRef() => ref _f;
}

See dotnet/csharplang#6337 (comment).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions