Skip to content

Creating Too Many Constraints #180

@JasonBock

Description

@JasonBock

To reproduce this:

public interface IValue<TValue>
  where TValue : IValue<TValue> { }

public class Value<TValue>
  where TValue : unmanaged, IValue<TValue> { }

public interface IUnmanagedValue
{
    void Use<TValue>(Value<TValue> value)
        where TValue : unmanaged, IValue<TValue>;
}

public static class Test
{
  public static void Run()
  {
    var expectations = Rock.Create<IUnmanagedValue>();
  }
}

This will create a constraint like where TValue : unmanaged, struct, IValue<TValue> . But that's illegal - struct shouldn't be there. The ITypeParameterSymbol for TValue ends up having HasUnmanagedTypeConstraint and HasValueTypeConstraint, but I'm guessing that if the unmanaged constraint exists, you don't need to look at HasValueTypeConstraint.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions