var tps = (TypeParameterSpec) MemberwiseClone ();
tps.BaseType = inflator.Inflate (BaseType);
if (ifaces != null) {
- tps.ifaces = new TypeSpec[ifaces.Count];
+ tps.ifaces = new List<TypeSpec> (ifaces.Count);
for (int i = 0; i < ifaces.Count; ++i)
- tps.ifaces[i] = inflator.Inflate (ifaces[i]);
+ tps.ifaces.Add (inflator.Inflate (ifaces[i]));
}
if (targs != null) {
tps.targs = new TypeSpec[targs.Length];
}
}
+ public bool IsConvertibleToInterface (TypeSpec iface)
+ {
+ if (Interfaces != null) {
+ foreach (var t in Interfaces) {
+ if (t == iface)
+ return true;
+ }
+ }
+
+ if (TypeArguments != null) {
+ foreach (var t in TypeArguments) {
+ if (((TypeParameterSpec) t).IsConvertibleToInterface (iface))
+ return true;
+ }
+ }
+
+ return false;
+ }
+
public override TypeSpec Mutate (TypeParameterMutator mutator)
{
return mutator.Mutate (this);
if (tparams [i] == tp)
return targs[i];
- // CECIL: This can happen when inflating nested types
+ // This can happen when inflating nested types
// without type arguments specified
return tp;
}
for (int i = 0; i < names.Length; i++) {
string type_argument_name = names[i].Name;
int idx = parameters.GetParameterIndexByName (type_argument_name);
+
if (idx >= 0) {
- Block b = m.Block;
+ var b = m.Block;
if (b == null)
- b = new Block (null);
+ b = new ToplevelBlock (Compiler, Location);
- b.Error_AlreadyDeclaredTypeParameter (Report, parameters [i].Location,
+ b.Error_AlreadyDeclaredTypeParameter (parameters [i].Location,
type_argument_name, "method parameter");
}
+
+ if (m.Block != null) {
+ var ikv = m.Block.GetKnownVariable (type_argument_name);
+ if (ikv != null)
+ ikv.Block.Error_AlreadyDeclaredTypeParameter (ikv.Location, type_argument_name, "local variable");
+ }
snames[i] = type_argument_name;
}
if (!tp.IsMethodOwned)
return parameter;
- return fixed_types [tp.DeclaredPosition];
+ return fixed_types [tp.DeclaredPosition] ?? parameter;
}
var gt = parameter as InflatedTypeSpec;