Skip to content

Incorrect Generation of default Constraint #210

@JasonBock

Description

@JasonBock

To reproduce:

public class BaseStuff
{
  public virtual T? GetService<T>(object[] args) where T : class => default!;
}

public static class Test
{
  public static void Go() => Rock.Create<BaseStuff>();
}

This will give the following error:

CS8822: Method 'CreateExpectationsOfBaseStuffExtensions.RockBaseStuff.GetService<T>(object[])' specifies a 'default' constraint for type parameter 'T', but corresponding type parameter 'T' of overridden or explicitly implemented method 'BaseStuff.GetService<T>(object[])' is constrained to a reference type or a value type.

This was found on System.Reactive.PlatformServices.CurrentPlatformEnlightenmentProvider.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions