if (TypeManager.IsGenericParameter (d))
return ResolveGenericParameter (ec, t, (TypeParameterSpec) d);
- if (TypeManager.ContainsGenericParameters (d))
+ if (InflatedTypeSpec.ContainsTypeParameter (d))
return this;
if (Convert.ImplicitReferenceConversionExists (expr, t) ||
return this;
}
- Expression e = Convert.ImplicitConversion (ec, expr, type, loc);
- if (e != null){
+ Expression e = Convert.ImplicitConversionStandard (ec, expr, type, loc);
+ if (e != null) {
expr = e;
return this;
}
return this;
}
- if (TypeManager.ContainsGenericParameters (etype) ||
- TypeManager.ContainsGenericParameters (type)) {
+ if (InflatedTypeSpec.ContainsTypeParameter (etype) || InflatedTypeSpec.ContainsTypeParameter (type)) {
expr = new BoxedCast (expr, etype);
do_isinst = true;
return this;
return false;
}
- static bool ContainsTypeParameter (TypeSpec type)
- {
- if (type.Kind == MemberKind.TypeParameter)
- return true;
-
- var element_container = type as ElementTypeSpec;
- if (element_container != null)
- return ContainsTypeParameter (element_container.Element);
-
- foreach (var t in type.TypeArguments) {
- if (ContainsTypeParameter (t)) {
- return true;
- }
- }
-
- return false;
- }
-
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
{
// Target type is not System.Type therefore must be object
if (!(QueriedType is GenericOpenTypeExpr)) {
var gt = typearg;
while (gt != null) {
- if (ContainsTypeParameter (gt)) {
+ if (InflatedTypeSpec.ContainsTypeParameter (gt)) {
rc.Compiler.Report.Error (416, loc, "`{0}': an attribute argument cannot use type parameters",
typearg.GetSignatureForError ());
return;
#endregion
+ public static bool ContainsTypeParameter (TypeSpec type)
+ {
+ if (type.Kind == MemberKind.TypeParameter)
+ return true;
+
+ var element_container = type as ElementTypeSpec;
+ if (element_container != null)
+ return ContainsTypeParameter (element_container.Element);
+
+ foreach (var t in type.TypeArguments) {
+ if (ContainsTypeParameter (t)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
TypeParameterInflator CreateLocalInflator ()
{
TypeParameterSpec[] tparams_full;
if (source_type != null) {
Argument a = arguments[0];
- if (TypeManager.IsGenericType (source_type) && TypeManager.ContainsGenericParameters (source_type)) {
+ if (TypeManager.IsGenericType (source_type) && InflatedTypeSpec.ContainsTypeParameter (source_type)) {
TypeInferenceContext tic = new TypeInferenceContext (source_type.TypeArguments);
tic.OutputTypeInference (rc, a.Expr, source_type);
if (tic.FixAllTypes (rc)) {