// <summary> // Resolve is used in method definitions // </summary> public virtual Type Resolve(IResolveContext ec) { // HACK: to resolve attributes correctly this.resolve_context = ec; if (parameter_type != null) { return(parameter_type); } TypeExpr texpr = TypeName.ResolveAsTypeTerminal(ec, false); if (texpr == null) { return(null); } parameter_type = texpr.Type; if ((modFlags & Parameter.Modifier.ISBYREF) != 0 && TypeManager.IsSpecialType(parameter_type)) { Report.Error(1601, Location, "Method or delegate parameter cannot be of type `{0}'", GetSignatureForError()); return(null); } #if GMCS_SOURCE TypeParameterExpr tparam = texpr as TypeParameterExpr; if (tparam != null) { return(parameter_type); } #endif if ((parameter_type.Attributes & Class.StaticClassAttribute) == Class.StaticClassAttribute) { 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) { Report.Error(1103, Location, "The type of extension method cannot be `{0}'", TypeManager.CSharpName(parameter_type)); } return(parameter_type); }
// // Public function used to locate types. // // Set 'ignore_cs0104' to true if you want to ignore cs0104 errors. // // Returns: Type or null if they type can not be found. // public override FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc) { FullNamedExpression e; if (arity == 0 && Cache.TryGetValue (name, out e) && mode != LookupMode.IgnoreAccessibility) return e; e = null; if (arity == 0) { var tp = CurrentTypeParameters; if (tp != null) { TypeParameter tparam = tp.Find (name); if (tparam != null) e = new TypeParameterExpr (tparam, Location.Null); } } if (e == null) { TypeSpec t = LookupNestedTypeInHierarchy (name, arity); if (t != null && (t.IsAccessible (this) || mode == LookupMode.IgnoreAccessibility)) e = new TypeExpression (t, Location.Null); else { e = Parent.LookupNamespaceOrType (name, arity, mode, loc); } } // TODO MemberCache: How to cache arity stuff ? if (arity == 0 && mode == LookupMode.Normal) Cache[name] = e; return e; }
// // Public function used to locate types. // // Returns: Type or null if they type can not be found. // public override FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc) { FullNamedExpression e; if (arity == 0 && Cache.TryGetValue (name, out e) && mode != LookupMode.IgnoreAccessibility) return e; e = null; if (arity == 0) { var tp = CurrentTypeParameters; if (tp != null) { TypeParameter tparam = tp.Find (name); if (tparam != null) e = new TypeParameterExpr (tparam, Location.Null); } } if (e == null) { TypeSpec t = LookupNestedTypeInHierarchy (name, arity); if (t != null && (t.IsAccessible (this) || mode == LookupMode.IgnoreAccessibility)) e = new TypeExpression (t, Location.Null); else { var errors = Compiler.Report.Errors; e = Parent.LookupNamespaceOrType (name, arity, mode, loc); // TODO: LookupNamespaceOrType does more than just lookup. The result // cannot be cached or the error reporting won't happen if (errors != Compiler.Report.Errors) return e; } } // TODO MemberCache: How to cache arity stuff ? if (arity == 0 && mode == LookupMode.Normal) Cache[name] = e; return e; }
// // Public function used to locate types. // // Set 'ignore_cs0104' to true if you want to ignore cs0104 errors. // // Returns: Type or null if they type can not be found. // public override FullNamedExpression LookupNamespaceOrType (string name, int arity, Location loc, bool ignore_cs0104) { FullNamedExpression e; if (arity == 0 && Cache.TryGetValue (name, out e)) return e; e = null; int errors = Report.Errors; if (arity == 0) { TypeParameter[] tp = CurrentTypeParameters; if (tp != null) { TypeParameter tparam = TypeParameter.FindTypeParameter (tp, name); if (tparam != null) e = new TypeParameterExpr (tparam, Location.Null); } } if (e == null) { TypeSpec t = LookupNestedTypeInHierarchy (name, arity); if (t != null) e = new TypeExpression (t, Location.Null); else if (Parent != null) { e = Parent.LookupNamespaceOrType (name, arity, loc, ignore_cs0104); } else e = NamespaceEntry.LookupNamespaceOrType (name, arity, loc, ignore_cs0104); } // TODO MemberCache: How to cache arity stuff ? if (errors == Report.Errors && arity == 0) Cache[name] = e; return e; }
// // Public function used to locate types. // // Set 'ignore_cs0104' to true if you want to ignore cs0104 errors. // // Returns: Type or null if they type can not be found. // public override FullNamedExpression LookupNamespaceOrType (string name, Location loc, bool ignore_cs0104) { if (Cache.Contains (name)) return (FullNamedExpression) Cache [name]; FullNamedExpression e = null; int errors = Report.Errors; TypeParameter[] tp = CurrentTypeParameters; if (tp != null) { TypeParameter tparam = TypeParameter.FindTypeParameter (tp, name); if (tparam != null) e = new TypeParameterExpr (tparam, Location.Null); } if (e == null) { Type t = LookupNestedTypeInHierarchy (name); if (t != null) e = new TypeExpression (t, Location.Null); else if (Parent != null) e = Parent.LookupNamespaceOrType (name, loc, ignore_cs0104); else e = NamespaceEntry.LookupNamespaceOrType (name, loc, ignore_cs0104); } if (errors == Report.Errors) Cache [name] = e; return e; }