IParameterReferenceOperation: x (OperationKind.ParameterReference, Type: ?) (Syntax: 'x')
",newDiagnosticDescription[]{
// file.cs(9,18): error CS1929: 'string' does not contain a definition for 'Cast' and the best extension method overload 'Queryable.Cast<GC>(IQueryable)' requires a receiver of type 'IQueryable'
// file.cs(9,31): error CS0718: 'GC': static types cannot be used as type arguments
// var q2 = string.Empty.Cast<GC>().Select(x => x);
// file.cs(10,41): error CS1929: 'string' does not contain a definition for 'Cast' and the best extension method overload 'Queryable.Cast<GC>(IQueryable)' requires a receiver of type 'IQueryable'
public void CS0452_GenericConstraintError_HasHigherPriorityThanMethodOverloadError()
{
var code = @"
class Code
{
void GenericMethod<T>(int i) where T: class => throw null;
void GenericMethod<T>(string s) => throw null;
void IncorrectMethodCall()
{
GenericMethod<int>(1);
}
}";
CreateCompilation(code).VerifyDiagnostics(
// (9,9): error CS0452: The type 'int' must be a reference type in order to use it as parameter 'T' in the generic type or method 'Code.GenericMethod<T>(int)'