public virtual TypeSpec Resolve (IMemberContext rc, int index)
{
if (parameter_type != null)
return parameter_type;
if (attributes != null)
attributes.AttachTo (this, rc);
var expr = texpr.ResolveAsTypeTerminal (rc, false);
if (expr == null)
return null;
this.idx = index;
texpr = expr;
parameter_type = texpr.Type;
if ((modFlags & Parameter.Modifier.ISBYREF) != 0 &&
TypeManager.IsSpecialType (parameter_type)) {
rc.Compiler.Report.Error (1601, Location, "Method or delegate parameter cannot be of type `{0}'",
GetSignatureForError ());
return null;
}
TypeManager.CheckTypeVariance (parameter_type,
(modFlags & Parameter.Modifier.ISBYREF) != 0 ? Variance.None : Variance.Contravariant,
rc);
if (parameter_type.IsStatic) {
rc.Compiler.Report.Error (721, Location, "`{0}': static types cannot be used as parameters",
texpr.GetSignatureForError ());
return parameter_type;
}
if ((modFlags & Modifier.This) != 0 && (parameter_type.IsPointer || parameter_type == InternalType.Dynamic)) {
rc.Compiler.Report.Error (1103, Location, "The extension method cannot be of type `{0}'",
TypeManager.CSharpName (parameter_type));
}
return parameter_type;
}