| Newsgroups |
gmane.comp.gnome.mono.patches |
| Message-ID |
<000001418537772e-911e9e58-780a-4794-a1d7-9d31c201180b-000000@email.amazonses.com> |
Branch: refs/heads/master
Home: https://github.com/mono/mono
Compare: https://github.com/mono/mono/compare/fd7cec894df1...009d937c1df7
Commit: 7585958bfd474af44d7a3292e26eaa0e0b72e61d
Author: Marek Safar <[email protected]> (marek-safar)
Date: 2013-10-04 20:42:57 GMT
URL: https://github.com/mono/mono/commit/7585958bfd474af44d7a3292e26eaa0e0b72e61d
Fix some code issue warnings
Changed paths:
M mcs/mcs/anonymous.cs
M mcs/mcs/assembly.cs
M mcs/mcs/async.cs
M mcs/mcs/cfold.cs
M mcs/mcs/class.cs
M mcs/mcs/constant.cs
M mcs/mcs/context.cs
M mcs/mcs/cs-parser.jay
M mcs/mcs/cs-tokenizer.cs
M mcs/mcs/decl.cs
M mcs/mcs/doc.cs
M mcs/mcs/driver.cs
M mcs/mcs/dynamic.cs
M mcs/mcs/ecore.cs
M mcs/mcs/enum.cs
M mcs/mcs/eval.cs
M mcs/mcs/expression.cs
M mcs/mcs/field.cs
M mcs/mcs/generic.cs
M mcs/mcs/ikvm.cs
M mcs/mcs/import.cs
M mcs/mcs/membercache.cs
M mcs/mcs/method.cs
M mcs/mcs/namespace.cs
M mcs/mcs/nullable.cs
M mcs/mcs/parameter.cs
M mcs/mcs/property.cs
M mcs/mcs/report.cs
M mcs/mcs/settings.cs
M mcs/mcs/statement.cs
M mcs/mcs/typespec.cs
Modified: mcs/mcs/anonymous.cs
===================================================================
@@ -199,14 +199,9 @@ public ThisInitializer (HoistedThis hoisted_this, AnonymousMethodStorey parent)
this.parent = parent;
}
- public override bool Resolve (BlockContext bc)
- {
- return base.Resolve (bc);
- }
-
protected override void DoEmit (EmitContext ec)
{
- Expression source = EmptyExpression.Null;
+ Expression source;
if (parent == null)
source = new CompilerGeneratedThis (ec.CurrentType, loc);
Modified: mcs/mcs/assembly.cs
===================================================================
@@ -1110,13 +1110,13 @@ public virtual void SetVersion (Version version, Location loc)
}
}
- abstract class AssemblyReferencesLoader<T>
+ abstract class AssemblyReferencesLoader<T> where T : class
{
protected readonly CompilerContext compiler;
protected readonly List<string> paths;
- public AssemblyReferencesLoader (CompilerContext compiler)
+ protected AssemblyReferencesLoader (CompilerContext compiler)
{
this.compiler = compiler;
Modified: mcs/mcs/async.cs
===================================================================
@@ -221,7 +221,7 @@ public Expression GetResultExpression (EmitContext ec)
public void EmitPrologue (EmitContext ec)
{
- awaiter = ((AsyncTaskStorey) machine_initializer.Storey).AddAwaiter (expr.Type, loc);
+ awaiter = ((AsyncTaskStorey) machine_initializer.Storey).AddAwaiter (expr.Type);
var fe_awaiter = new FieldExpr (awaiter, loc);
fe_awaiter.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc);
@@ -409,11 +409,6 @@ protected override BlockContext CreateBlockContext (ResolveContext rc)
return ctx;
}
- public override Expression CreateExpressionTree (ResolveContext ec)
- {
- return base.CreateExpressionTree (ec);
- }
-
public override void Emit (EmitContext ec)
{
throw new NotImplementedException ();
@@ -483,7 +478,7 @@ public AsyncTaskStorey (ParametersBlock block, IMemberContext context, AsyncInit
#endregion
- public Field AddAwaiter (TypeSpec type, Location loc)
+ public Field AddAwaiter (TypeSpec type)
{
if (mutator != null)
type = mutator.Mutate (type);
Modified: mcs/mcs/cfold.cs
===================================================================
@@ -920,7 +920,7 @@ internal static void Error_CompileTimeOverflow (ResolveContext rc, Location loc)
IntConstant sic = right.ConvertImplicitly (ec.BuiltinTypes.Int) as IntConstant;
if (sic == null){
- Binary.Error_OperatorCannotBeApplied (ec, left, right, oper, loc); ;
+ Binary.Error_OperatorCannotBeApplied (ec, left, right, oper, loc);
return null;
}
int rshift_val = sic.Value;
Modified: mcs/mcs/class.cs
===================================================================
@@ -53,7 +53,7 @@ public abstract class TypeContainer : MemberCore
protected bool is_defined;
- public TypeContainer (TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind)
+ protected TypeContainer (TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind)
: base (parent, name, attrs)
{
this.Kind = kind;
@@ -556,7 +556,7 @@ enum CachedMethods
/// </remarks>
PendingImplementation pending;
- public TypeDefinition (TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind)
+ protected TypeDefinition (TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind)
: base (parent, name, attrs, kind)
{
PartialContainer = this;
@@ -971,7 +971,7 @@ public void ResolveFieldInitializers (BlockContext ec)
if (s == null) {
s = EmptyExpressionStatement.Instance;
} else if (!fi.IsSideEffectFree) {
- has_complex_initializer |= true;
+ has_complex_initializer = true;
}
init [i] = s;
@@ -2474,7 +2474,7 @@ public abstract class ClassOrStruct : TypeDefinition
SecurityType declarative_security;
- public ClassOrStruct (TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind)
+ protected ClassOrStruct (TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind)
: base (parent, name, attrs, kind)
{
}
@@ -3137,7 +3137,7 @@ public abstract class InterfaceMemberBase : MemberBase
readonly Modifiers explicit_mod_flags;
public MethodAttributes flags;
- public InterfaceMemberBase (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs)
+ protected InterfaceMemberBase (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs)
: base (parent, type, mod, allowed_mod, Modifiers.PRIVATE, name, attrs)
{
IsInterface = parent.Kind == MemberKind.Interface;
Modified: mcs/mcs/constant.cs
===================================================================
@@ -70,7 +70,7 @@ public override void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec t
}
}
- public Constant ImplicitConversionRequired (ResolveContext ec, TypeSpec type, Location loc)
+ public Constant ImplicitConversionRequired (ResolveContext ec, TypeSpec type)
{
Constant c = ConvertImplicitly (type);
if (c == null)
Modified: mcs/mcs/context.cs
===================================================================
@@ -325,7 +325,7 @@ public enum Options
// it's public so that we can use a struct at the callsite
public struct FlagsHandle : IDisposable
{
- ResolveContext ec;
+ readonly ResolveContext ec;
readonly Options invmask, oldval;
public FlagsHandle (ResolveContext ec, Options flagsToSet)
@@ -730,7 +730,7 @@ public enum Options
// it's public so that we can use a struct at the callsite
public struct FlagsHandle : IDisposable
{
- BuilderContext ec;
+ readonly BuilderContext ec;
readonly Options invmask, oldval;
public FlagsHandle (BuilderContext ec, Options flagsToSet)
Modified: mcs/mcs/cs-parser.jay
===================================================================
@@ -3938,7 +3938,7 @@ unary_expression
if (current_anonymous_method is LambdaExpression) {
report.Error (4034, GetLocation ($1),
"The `await' operator can only be used when its containing lambda expression is marked with the `async' modifier");
- } else if (current_anonymous_method is AnonymousMethodExpression) {
+ } else if (current_anonymous_method != null) {
report.Error (4035, GetLocation ($1),
"The `await' operator can only be used when its containing anonymous method is marked with the `async' modifier");
} else if (interactive_async != null) {
Modified: mcs/mcs/cs-tokenizer.cs
===================================================================
@@ -2391,7 +2391,7 @@ void ReadSingleLineComment ()
/// <summary>
/// Handles #pragma directive
/// </summary>
- void ParsePragmaDirective (string arg)
+ void ParsePragmaDirective ()
{
int c;
int length = TokenizePreprocessorIdentifier (out c);
@@ -2861,7 +2861,7 @@ bool ParsePreprocessingDirective (bool caller_is_taking)
Report.FeatureIsNotAvailable (context, Location, "#pragma");
}
- ParsePragmaDirective (arg);
+ ParsePragmaDirective ();
return true;
case PreprocessorDirective.Line:
Modified: mcs/mcs/decl.cs
===================================================================
@@ -303,7 +303,7 @@ public enum Flags {
/// </summary>
internal Flags caching_flags;
- public MemberCore (TypeContainer parent, MemberName name, Attributes attrs)
+ protected MemberCore (TypeContainer parent, MemberName name, Attributes attrs)
{
this.Parent = parent;
member_name = name;
@@ -435,7 +435,7 @@ public virtual void Emit ()
if ((mod_flags & Modifiers.COMPILER_GENERATED) != 0)
return true;
- return Parent == null ? false : Parent.IsCompilerGenerated;
+ return Parent != null && Parent.IsCompilerGenerated;
}
}
@@ -884,7 +884,7 @@ public virtual void WriteDebugSymbol (MonoSymbolFile file)
if (GetAttributeObsolete () != null)
return true;
- return Parent == null ? false : Parent.IsObsolete;
+ return Parent != null && Parent.IsObsolete;
}
}
@@ -893,7 +893,7 @@ public virtual void WriteDebugSymbol (MonoSymbolFile file)
if ((ModFlags & Modifiers.UNSAFE) != 0)
return true;
- return Parent == null ? false : Parent.IsUnsafe;
+ return Parent != null && Parent.IsUnsafe;
}
}
Modified: mcs/mcs/doc.cs
===================================================================
@@ -147,16 +147,13 @@ internal void GenerateDocumentationForMember (MemberCore mc)
}
// FIXME: it could be done with XmlReader
- var ds_target = mc as TypeContainer;
- if (ds_target == null)
- ds_target = mc.Parent;
foreach (XmlElement see in n.SelectNodes (".//see"))
- HandleSee (mc, ds_target, see);
+ HandleSee (mc, see);
foreach (XmlElement seealso in n.SelectNodes (".//seealso"))
- HandleSeeAlso (mc, ds_target, seealso);
+ HandleSeeAlso (mc, seealso);
foreach (XmlElement see in n.SelectNodes (".//exception"))
- HandleException (mc, ds_target, see);
+ HandleException (mc, see);
foreach (XmlElement node in n.SelectNodes (".//typeparam"))
HandleTypeParam (mc, node);
foreach (XmlElement node in n.SelectNodes (".//typeparamref"))
@@ -228,25 +225,25 @@ bool HandleInclude (MemberCore mc, XmlElement el)
//
// Handles <see> elements.
//
- void HandleSee (MemberCore mc, TypeContainer ds, XmlElement see)
+ void HandleSee (MemberCore mc, XmlElement see)
{
- HandleXrefCommon (mc, ds, see);
+ HandleXrefCommon (mc, see);
}
//
// Handles <seealso> elements.
//
- void HandleSeeAlso (MemberCore mc, TypeContainer ds, XmlElement seealso)
+ void HandleSeeAlso (MemberCore mc, XmlElement seealso)
{
- HandleXrefCommon (mc, ds, seealso);
+ HandleXrefCommon (mc, seealso);
}
//
// Handles <exception> elements.
//
- void HandleException (MemberCore mc, TypeContainer ds, XmlElement seealso)
+ void HandleException (MemberCore mc, XmlElement seealso)
{
- HandleXrefCommon (mc, ds, seealso);
+ HandleXrefCommon (mc, seealso);
}
//
@@ -319,7 +316,7 @@ FullNamedExpression ResolveMemberName (IMemberContext context, MemberName mn)
//
// Processes "see" or "seealso" elements from cref attribute.
//
- void HandleXrefCommon (MemberCore mc, TypeContainer ds, XmlElement xref)
+ void HandleXrefCommon (MemberCore mc, XmlElement xref)
{
string cref = xref.GetAttribute ("cref");
// when, XmlReader, "if (cref == null)"
@@ -340,7 +337,7 @@ void HandleXrefCommon (MemberCore mc, TypeContainer ds, XmlElement xref)
var report = new Report (doc_module.Compiler, new NullReportPrinter ());
if (session == null)
- session = new ParserSession () {
+ session = new ParserSession {
UseJayGlobalArrays = true
};
Modified: mcs/mcs/driver.cs
===================================================================
@@ -78,7 +78,7 @@ void Parse (ModuleContainer module)
Location.Initialize (sources);
- var session = new ParserSession () {
+ var session = new ParserSession {
UseJayGlobalArrays = true,
LocatedTokens = new LocatedToken[15000]
};
Modified: mcs/mcs/dynamic.cs
===================================================================
@@ -224,8 +224,8 @@ class DynamicExpressionStatement : ExpressionStatement
//
protected class BinderFlags : EnumConstant
{
- DynamicExpressionStatement statement;
- CSharpBinderFlags flags;
+ readonly DynamicExpressionStatement statement;
+ readonly CSharpBinderFlags flags;
public BinderFlags (CSharpBinderFlags flags, DynamicExpressionStatement statement)
: base (statement.loc)
Modified: mcs/mcs/ecore.cs
===================================================================
@@ -339,7 +339,7 @@ public void Error_TypeArgumentsCannotBeUsed (IMemberContext context, MemberSpec
}
}
- public void Error_TypeArgumentsCannotBeUsed (IMemberContext context, string exprType, string name, Location loc)
+ public static void Error_TypeArgumentsCannotBeUsed (IMemberContext context, string exprType, string name, Location loc)
{
context.Module.Compiler.Report.Error (307, loc, "The {0} `{1}' cannot be used with type arguments",
exprType, name);
@@ -989,7 +989,7 @@ public virtual string ExprClassName
/// <summary>
/// Reports that we were expecting `expr' to be of class `expected'
/// </summary>
- public void Error_UnexpectedKind (IMemberContext ctx, Expression memberExpr, string expected, string was, Location loc)
+ public static void Error_UnexpectedKind (IMemberContext ctx, Expression memberExpr, string expected, string was, Location loc)
{
var name = memberExpr.GetSignatureForError ();
@@ -2479,7 +2479,7 @@ protected virtual void Error_TypeOrNamespaceNotFound (IMemberContext ctx)
if (ctx.CurrentType != null) {
var member = MemberLookup (ctx, false, ctx.CurrentType, Name, 0, MemberLookupRestrictions.ExactArity, loc) as MemberExpr;
if (member != null) {
- member.Error_UnexpectedKind (ctx, member, "type", member.KindName, loc);
+ Error_UnexpectedKind (ctx, member, "type", member.KindName, loc);
return;
}
}
@@ -2724,7 +2724,7 @@ public override Expression LookupNameExpression (ResolveContext rc, MemberLookup
} else {
var me = MemberLookup (rc, false, rc.CurrentType, Name, Arity, restrictions & ~MemberLookupRestrictions.InvocableOnly, loc) as MemberExpr;
if (me != null) {
- me.Error_UnexpectedKind (rc, me, "method group", me.KindName, loc);
+ Error_UnexpectedKind (rc, me, "method group", me.KindName, loc);
return ErrorExpression.Instance;
}
}
@@ -2770,7 +2770,7 @@ Expression SimpleNameResolve (ResolveContext ec, Expression right_side)
return null;
if (e is FullNamedExpression && e.eclass != ExprClass.Unresolved) {
- e.Error_UnexpectedKind (ec, e, "variable", e.ExprClassName, loc);
+ Error_UnexpectedKind (ec, e, "variable", e.ExprClassName, loc);
return e;
}
@@ -2827,7 +2827,7 @@ public override TypeSpec ResolveAsType (IMemberContext mc)
TypeExpr te = fne as TypeExpr;
if (te == null) {
- fne.Error_UnexpectedKind (mc, fne, "type", fne.ExprClassName, loc);
+ Error_UnexpectedKind (mc, fne, "type", fne.ExprClassName, loc);
return null;
}
@@ -3535,8 +3535,7 @@ public MethodGroupExpr (MethodSpec m, TypeSpec type, Location loc)
public override bool IsSideEffectFree {
get {
- return InstanceExpression != null ?
- InstanceExpression.IsSideEffectFree : true;
+ return InstanceExpression == null || InstanceExpression.IsSideEffectFree;
}
}
@@ -5003,8 +5002,7 @@ static TypeSpec MoreSpecific (TypeSpec p, TypeSpec q)
}
// Restore expanded arguments
- if (candidate_args != args)
- candidate_args = args;
+ candidate_args = args;
}
} while (best_candidate_rate != 0 && (type_members = base_provider.GetBaseMembers (type_members[0].DeclaringType.BaseType)) != null);
@@ -6745,7 +6743,7 @@ protected override Expression DoResolve (ResolveContext ec)
// Don't capture temporary variables except when using
// state machine redirection and block yields
//
- if (ec.CurrentAnonymousMethod != null && ec.CurrentAnonymousMethod is StateMachineInitializer &&
+ if (ec.CurrentAnonymousMethod is StateMachineInitializer &&
(ec.CurrentBlock.Explicit.HasYield || ec.CurrentBlock.Explicit.HasAwait) &&
ec.IsVariableCapturingRequired) {
AnonymousMethodStorey storey = li.Block.Explicit.CreateAnonymousMethodStorey (ec);
Modified: mcs/mcs/enum.cs
===================================================================
@@ -66,7 +66,7 @@ public override Constant ConvertInitializer (ResolveContext rc, Constant expr)
var underlying = ((Enum) Parent).UnderlyingType;
if (expr != null) {
- expr = expr.ImplicitConversionRequired (rc, underlying, Location);
+ expr = expr.ImplicitConversionRequired (rc, underlying);
if (expr != null && !IsValidEnumType (expr.Type)) {
Enum.Error_1008 (Location, Report);
expr = null;
Modified: mcs/mcs/eval.cs
===================================================================
@@ -1216,10 +1216,6 @@ public override void EmitStatement(EmitContext ec)
public class Undo
{
List<Action> undo_actions;
-
- public Undo ()
- {
- }
public void AddTypeContainer (TypeContainer current_container, TypeDefinition tc)
{
Modified: mcs/mcs/expression.cs
===================================================================
@@ -1319,7 +1319,7 @@ public abstract class Probe : Expression
protected Expression expr;
protected TypeSpec probe_type_expr;
- public Probe (Expression expr, Expression probe_type, Location l)
+ protected Probe (Expression expr, Expression probe_type, Location l)
{
ProbeType = probe_type;
loc = l;
@@ -2845,7 +2845,7 @@ static bool IsEnumOrNullableEnum (TypeSpec type)
// at least one of 'left' or 'right' is an enumeration constant (EnumConstant or SideEffectConstant or ...)
// if 'left' is not an enumeration constant, create one from the type of 'right'
- Constant EnumLiftUp (ResolveContext ec, Constant left, Constant right, Location loc)
+ Constant EnumLiftUp (ResolveContext ec, Constant left, Constant right)
{
switch (oper) {
case Operator.BitwiseOr:
@@ -3237,9 +3237,9 @@ protected override Expression DoResolve (ResolveContext ec)
// The conversion rules are ignored in enum context but why
if (!ec.HasSet (ResolveContext.Options.EnumScope) && lc != null && rc != null && (left.Type.IsEnum || right.Type.IsEnum)) {
- lc = EnumLiftUp (ec, lc, rc, loc);
+ lc = EnumLiftUp (ec, lc, rc);
if (lc != null)
- rc = EnumLiftUp (ec, rc, lc, loc);
+ rc = EnumLiftUp (ec, rc, lc);
}
if (rc != null && lc != null) {
@@ -4950,7 +4950,7 @@ public override void Emit (EmitContext ec)
public class PointerArithmetic : Expression {
Expression left, right;
- Binary.Operator op;
+ readonly Binary.Operator op;
//
// We assume that `l' is always a pointer
@@ -6070,7 +6070,7 @@ protected override Expression DoResolve (ResolveContext ec)
} else {
if (member_expr is RuntimeValueExpression) {
ec.Report.Error (Report.RuntimeErrorId, loc, "Cannot invoke a non-delegate type `{0}'",
- member_expr.Type.GetSignatureForError ()); ;
+ member_expr.Type.GetSignatureForError ());
return null;
}
@@ -6786,7 +6786,7 @@ public class ArrayCreation : Expression
protected List<Expression> arguments;
protected TypeSpec array_element_type;
- int num_arguments = 0;
+ int num_arguments;
protected int dimensions;
protected readonly ComposedTypeSpecifier rank;
Expression first_emit;
@@ -8944,7 +8944,7 @@ protected virtual void Error_IdentifierNotFound (IMemberContext rc, TypeSpec exp
var any_other_member = MemberLookup (rc, false, expr_type, Name, 0, MemberLookupRestrictions.None, loc);
if (any_other_member != null) {
- any_other_member.Error_UnexpectedKind (rc, any_other_member, "type", any_other_member.ExprClassName, loc);
+ Error_UnexpectedKind (rc, any_other_member, "type", any_other_member.ExprClassName, loc);
return;
}
@@ -8962,7 +8962,7 @@ protected override void Error_TypeDoesNotContainDefinition (ResolveContext ec, T
if (ec.Module.Compiler.Settings.Version > LanguageVersion.ISO_2 && !ec.IsRuntimeBinder && MethodGroupExpr.IsExtensionMethodArgument (expr)) {
ec.Report.SymbolRelatedToPreviousError (type);
- var cand = ec.Module.GlobalRootNamespace.FindExtensionMethodNamespaces (ec, type, name, Arity);
+ var cand = ec.Module.GlobalRootNamespace.FindExtensionMethodNamespaces (ec, name, Arity);
string missing;
// a using directive or an assembly reference
if (cand != null) {
@@ -11086,11 +11086,6 @@ protected override Expression DoResolve (ResolveContext ec)
eclass = ExprClass.Value;
return this;
}
-
- public override void EmitStatement (EmitContext ec)
- {
- base.EmitStatement (ec);
- }
public override object Accept (StructuralVisitor visitor)
{
Modified: mcs/mcs/field.cs
===================================================================
@@ -370,7 +370,7 @@ public override List<MissingTypeSpecReference> ResolveMissingDependencies (Membe
public class FixedField : FieldBase
{
public const string FixedElementName = "FixedElementField";
- static int GlobalCounter = 0;
+ static int GlobalCounter;
TypeBuilder fixed_buffer_type;
@@ -400,7 +400,7 @@ public FixedField (TypeDefinition parent, FullNamedExpression type, Modifiers mo
public override Constant ConvertInitializer (ResolveContext rc, Constant expr)
{
- return expr.ImplicitConversionRequired (rc, rc.BuiltinTypes.Int, Location);
+ return expr.ImplicitConversionRequired (rc, rc.BuiltinTypes.Int);
}
public override bool Define ()
Modified: mcs/mcs/generic.cs
===================================================================
@@ -117,9 +117,9 @@ public override FullNamedExpression ResolveAsTypeOrNamespace (IMemberContext ec)
//
public class Constraints
{
- SimpleMemberName tparam;
- List<FullNamedExpression> constraints;
- Location loc;
+ readonly SimpleMemberName tparam;
+ readonly List<FullNamedExpression> constraints;
+ readonly Location loc;
bool resolved;
bool resolving;
@@ -398,7 +398,7 @@ public void VerifyClsCompliance (Report report)
//
public class TypeParameter : MemberCore, ITypeDefinition
{
- static readonly string[] attribute_target = new string [] { "type parameter" };
+ static readonly string[] attribute_target = { "type parameter" };
Constraints constraints;
GenericTypeParameterBuilder builder;
@@ -2849,7 +2849,7 @@ bool DoSecondPhase (ResolveContext ec, TypeInferenceContext tic, TypeSpec[] meth
var mi = Delegate.GetInvokeMethod (t_i);
TypeSpec rtype = mi.ReturnType;
- if (tic.IsReturnTypeNonDependent (ec, mi, rtype)) {
+ if (tic.IsReturnTypeNonDependent (mi, rtype)) {
// It can be null for default arguments
if (arguments[i] == null)
continue;
@@ -3296,7 +3296,7 @@ public TypeSpec InflateGenericArgument (IModuleContext context, TypeSpec paramet
// Tests whether all delegate input arguments are fixed and generic output type
// requires output type inference
//
- public bool IsReturnTypeNonDependent (ResolveContext ec, MethodSpec invoke, TypeSpec returnType)
+ public bool IsReturnTypeNonDependent (MethodSpec invoke, TypeSpec returnType)
{
AParametersCollection d_parameters = invoke.Parameters;
@@ -3529,7 +3529,7 @@ public int OutputTypeInference (ResolveContext ec, Expression e, TypeSpec t)
var invoke = Delegate.GetInvokeMethod (t);
TypeSpec rtype = invoke.ReturnType;
- if (!IsReturnTypeNonDependent (ec, invoke, rtype))
+ if (!IsReturnTypeNonDependent (invoke, rtype))
return 0;
// LAMESPEC: Standard does not specify that all methodgroup arguments
Modified: mcs/mcs/ikvm.cs
===================================================================
@@ -226,7 +226,7 @@ class StaticLoader : AssemblyReferencesLoader<Assembly>, IDisposable
readonly StaticImporter importer;
readonly Universe domain;
Assembly corlib;
- List<Tuple<AssemblyName, string, Assembly>> loaded_names;
+ readonly List<Tuple<AssemblyName, string, Assembly>> loaded_names;
static readonly Dictionary<string, string[]> sdk_directory;
static StaticLoader ()
Modified: mcs/mcs/import.cs
===================================================================
@@ -56,10 +56,10 @@ public DynamicTypeReader (object provider)
//
// Returns true when object at local position has dynamic attribute flag
//
- public bool IsDynamicObject (MetadataImporter importer)
+ public bool IsDynamicObject ()
{
if (provider != null)
- ReadAttribute (importer);
+ ReadAttribute ();
return flags != null && Position < flags.Length && flags[Position];
}
@@ -67,15 +67,15 @@ public bool IsDynamicObject (MetadataImporter importer)
//
// Returns true when DynamicAttribute exists
//
- public bool HasDynamicAttribute (MetadataImporter importer)
+ public bool HasDynamicAttribute ()
{
if (provider != null)
- ReadAttribute (importer);
+ ReadAttribute ();
return flags != null;
}
- void ReadAttribute (MetadataImporter importer)
+ void ReadAttribute ()
{
IList<CustomAttributeData> cad;
if (provider is MemberInfo) {
@@ -713,7 +713,7 @@ protected TypeSpec CreateType (MetaType type, TypeSpec declaringType, DynamicTyp
TypeSpec spec;
if (import_cache.TryGetValue (type, out spec)) {
if (spec.BuiltinType == BuiltinTypeSpec.Type.Object) {
- if (dtype.IsDynamicObject (this))
+ if (dtype.IsDynamicObject ())
return module.Compiler.BuiltinTypes.Dynamic;
return spec;
@@ -722,7 +722,7 @@ protected TypeSpec CreateType (MetaType type, TypeSpec declaringType, DynamicTyp
if (!spec.IsGeneric || type.IsGenericTypeDefinition)
return spec;
- if (!dtype.HasDynamicAttribute (this))
+ if (!dtype.HasDynamicAttribute ())
return spec;
// We've found same object in the cache but this one has a dynamic custom attribute
@@ -1372,7 +1372,7 @@ public static AttributesBag Read (MemberInfo mi, MetadataImporter importer)
protected AttributesBag cattrs;
protected readonly MetadataImporter importer;
- public ImportedDefinition (MemberInfo provider, MetadataImporter importer)
+ protected ImportedDefinition (MemberInfo provider, MetadataImporter importer)
{
this.provider = provider;
this.importer = importer;
Modified: mcs/mcs/membercache.cs
===================================================================
@@ -226,7 +226,7 @@ public void AddBaseType (TypeSpec baseType)
continue;
if (list is MemberSpec[]) {
- list = new List<MemberSpec> () { list [0] };
+ list = new List<MemberSpec> { list [0] };
member_hash[entry.Key] = list;
}
@@ -335,7 +335,7 @@ void AddMember (string name, MemberSpec member, bool removeHiddenMembers)
member_hash[name] = list;
} else {
if (list.Count == 1) {
- list = new List<MemberSpec> () { list[0] };
+ list = new List<MemberSpec> { list[0] };
member_hash[name] = list;
}
@@ -390,7 +390,7 @@ static bool AddInterfaceMember (MemberSpec member, ref IList<MemberSpec> existin
}
if (existing.Count == 1) {
- existing = new List<MemberSpec> () { existing[0], member };
+ existing = new List<MemberSpec> { existing[0], member };
return true;
}
Modified: mcs/mcs/method.cs
===================================================================
@@ -47,7 +47,7 @@ public abstract class MethodCore : InterfaceMemberBase, IParametersMember
protected ToplevelBlock block;
protected MethodSpec spec;
- public MethodCore (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod,
+ protected MethodCore (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod,
MemberName name, Attributes attrs, ParametersCompiled parameters)
: base (parent, type, mod, allowed_mod, name, attrs)
{
@@ -1405,7 +1405,7 @@ public abstract class ConstructorInitializer : ExpressionStatement
Arguments argument_list;
MethodSpec base_ctor;
- public ConstructorInitializer (Arguments argument_list, Location loc)
+ protected ConstructorInitializer (Arguments argument_list, Location loc)
{
this.argument_list = argument_list;
this.loc = loc;
@@ -2267,7 +2267,7 @@ public abstract class AbstractPropertyEventMethod : MemberCore, IMethodData, IMe
ReturnParameter return_attributes;
- public AbstractPropertyEventMethod (InterfaceMemberBase member, string prefix, Attributes attrs, Location loc)
+ protected AbstractPropertyEventMethod (InterfaceMemberBase member, string prefix, Attributes attrs, Location loc)
: base (member.Parent, SetupName (prefix, member, loc), attrs)
{
this.prefix = prefix;
Modified: mcs/mcs/namespace.cs
===================================================================
@@ -64,12 +64,12 @@ public List<string> FindTypeNamespaces (IMemberContext ctx, string name, int ari
//
// For better error reporting where compiler tries to guess missing using directive
//
- public List<string> FindExtensionMethodNamespaces (IMemberContext ctx, TypeSpec extensionType, string name, int arity)
+ public List<string> FindExtensionMethodNamespaces (IMemberContext ctx, string name, int arity)
{
List<string> res = null;
foreach (var ns in all_namespaces) {
- var methods = ns.Value.LookupExtensionMethod (ctx, extensionType, name, arity);
+ var methods = ns.Value.LookupExtensionMethod (ctx, name, arity);
if (methods != null) {
if (res == null)
res = new List<string> ();
@@ -448,7 +448,7 @@ where item.Key.StartsWith (prefix) && item.Value.Any (l => (l.Modifiers & Modifi
//
// Looks for extension method in this namespace
//
- public List<MethodSpec> LookupExtensionMethod (IMemberContext invocationContext, TypeSpec extensionType, string name, int arity)
+ public List<MethodSpec> LookupExtensionMethod (IMemberContext invocationContext, string name, int arity)
{
if (extension_method_types == null)
return null;
@@ -730,7 +730,7 @@ public override void PrepareEmit ()
void CreateUnitSymbolInfo (MonoSymbolFile symwriter)
{
var si = file.CreateSymbolInfo (symwriter);
- comp_unit = new CompileUnitEntry (symwriter, si);;
+ comp_unit = new CompileUnitEntry (symwriter, si);
if (include_files != null) {
foreach (SourceFile include in include_files.Values) {
@@ -969,7 +969,7 @@ public ExtensionMethodCandidates LookupExtensionMethod (IMemberContext invocatio
ExtensionMethodCandidates candidates;
var container = this;
do {
- candidates = container.LookupExtensionMethodCandidates (invocationContext, extensionType, name, arity, ref position);
+ candidates = container.LookupExtensionMethodCandidates (invocationContext, name, arity, ref position);
if (candidates != null || container.MemberName == null)
return candidates;
@@ -984,7 +984,7 @@ public ExtensionMethodCandidates LookupExtensionMethod (IMemberContext invocatio
while (mn != null) {
++position;
- var methods = container_ns.LookupExtensionMethod (invocationContext, extensionType, name, arity);
+ var methods = container_ns.LookupExtensionMethod (invocationContext, name, arity);
if (methods != null) {
return new ExtensionMethodCandidates (invocationContext, methods, container, position);
}
@@ -1000,14 +1000,14 @@ public ExtensionMethodCandidates LookupExtensionMethod (IMemberContext invocatio
return null;
}
- ExtensionMethodCandidates LookupExtensionMethodCandidates (IMemberContext invocationContext, TypeSpec extensionType, string name, int arity, ref int position)
+ ExtensionMethodCandidates LookupExtensionMethodCandidates (IMemberContext invocationContext, string name, int arity, ref int position)
{
List<MethodSpec> candidates = null;
if (position == 0) {
++position;
- candidates = ns.LookupExtensionMethod (invocationContext, extensionType, name, arity);
+ candidates = ns.LookupExtensionMethod (invocationContext, name, arity);
if (candidates != null) {
return new ExtensionMethodCandidates (invocationContext, candidates, this, position);
}
@@ -1017,7 +1017,7 @@ ExtensionMethodCandidates LookupExtensionMethodCandidates (IMemberContext invoca
++position;
foreach (Namespace n in namespace_using_table) {
- var a = n.LookupExtensionMethod (invocationContext, extensionType, name, arity);
+ var a = n.LookupExtensionMethod (invocationContext, name, arity);
if (a == null)
continue;
Modified: mcs/mcs/nullable.cs
===================================================================
@@ -1145,7 +1145,7 @@ Expression ConvertExpression (ResolveContext ec)
}
TypeSpec rtype = right.Type;
- if (!Convert.ImplicitConversionExists (ec, unwrap != null ? unwrap : left, rtype) || right.eclass == ExprClass.MethodGroup)
+ if (!Convert.ImplicitConversionExists (ec, unwrap ?? left, rtype) || right.eclass == ExprClass.MethodGroup)
return null;
//
@@ -1154,7 +1154,7 @@ Expression ConvertExpression (ResolveContext ec)
if (left.IsNull)
return ReducedExpression.Create (right, this).Resolve (ec);
- left = Convert.ImplicitConversion (ec, unwrap != null ? unwrap : left, rtype, loc);
+ left = Convert.ImplicitConversion (ec, unwrap ?? left, rtype, loc);
type = rtype;
return this;
}
Modified: mcs/mcs/parameter.cs
===================================================================
@@ -501,7 +501,7 @@ public void ResolveDefaultValue (ResolveContext rc)
} else {
rc.Report.Error (1909, default_expr.Location,
"The DefaultParameterValue attribute is not applicable on parameters of type `{0}'",
- default_expr.Type.GetSignatureForError ()); ;
+ default_expr.Type.GetSignatureForError ());
}
default_expr = null;
@@ -1333,11 +1333,6 @@ public DefaultParameterValueExpression (Expression expr)
{
}
- protected override Expression DoResolve (ResolveContext rc)
- {
- return base.DoResolve (rc);
- }
-
public void Resolve (ResolveContext rc, Parameter p)
{
var expr = Resolve (rc);
Modified: mcs/mcs/property.cs
===================================================================
@@ -408,7 +408,7 @@ void CheckModifiers (Modifiers modflags)
PropertyMethod get, set, first;
PropertyBuilder PropertyBuilder;
- public PropertyBase (TypeDefinition parent, FullNamedExpression type, Modifiers mod_flags, Modifiers allowed_mod, MemberName name, Attributes attrs)
+ protected PropertyBase (TypeDefinition parent, FullNamedExpression type, Modifiers mod_flags, Modifiers allowed_mod, MemberName name, Attributes attrs)
: base (parent, type, mod_flags, allowed_mod, name, attrs)
{
}
Modified: mcs/mcs/report.cs
===================================================================
@@ -954,7 +954,7 @@ public void ShowStats ()
if (timers == null)
return;
- Dictionary<TimerType, string> timer_names = new Dictionary<TimerType,string> () {
+ Dictionary<TimerType, string> timer_names = new Dictionary<TimerType,string> {
{ TimerType.ParseTotal, "Parsing source files" },
{ TimerType.AssemblyBuilderSetup, "Assembly builder setup" },
{ TimerType.CreateTypeTotal, "Compiled types created" },
@@ -1053,7 +1053,7 @@ public Disable (int line, int code)
public override bool IsEnabled (int code, bool previous)
{
- return this.code == code ? false : previous;
+ return this.code != code && previous;
}
}
@@ -1079,7 +1079,7 @@ public Enable (int line, int code)
public override bool IsEnabled(int code, bool previous)
{
- return this.code == code ? true : previous;
+ return this.code == code || previous;
}
}
Modified: mcs/mcs/settings.cs
===================================================================
@@ -301,8 +301,8 @@ enum ParseResult
UnknownOption
}
- static readonly char[] argument_value_separator = new char[] { ';', ',' };
- static readonly char[] numeric_value_separator = new char[] { ';', ',', ' ' };
+ static readonly char[] argument_value_separator = { ';', ',' };
+ static readonly char[] numeric_value_separator = { ';', ',', ' ' };
readonly TextWriter output;
readonly Report report;
@@ -469,7 +469,7 @@ void ProcessSourceFiles (string spec, bool recurse, List<SourceFile> sourceFiles
return;
}
- string[] files = null;
+ string[] files;
try {
files = Directory.GetFiles (path, pattern);
} catch (System.IO.DirectoryNotFoundException) {
@@ -975,7 +975,7 @@ ParseResult ParseOption (string option, ref string[] args, CompilerSettings sett
settings.WarningsAreErrors = true;
parser_settings.WarningsAreErrors = true;
} else {
- if (!ProcessWarningsList (value, v => settings.AddWarningAsError (v)))
+ if (!ProcessWarningsList (value, settings.AddWarningAsError))
return ParseResult.Error;
}
return ParseResult.Success;
@@ -984,7 +984,7 @@ ParseResult ParseOption (string option, ref string[] args, CompilerSettings sett
if (value.Length == 0) {
settings.WarningsAreErrors = false;
} else {
- if (!ProcessWarningsList (value, v => settings.AddWarningOnly (v)))
+ if (!ProcessWarningsList (value, settings.AddWarningOnly))
return ParseResult.Error;
}
return ParseResult.Success;
@@ -1005,7 +1005,7 @@ ParseResult ParseOption (string option, ref string[] args, CompilerSettings sett
return ParseResult.Error;
}
- if (!ProcessWarningsList (value, v => settings.SetIgnoreWarning (v)))
+ if (!ProcessWarningsList (value, settings.SetIgnoreWarning))
return ParseResult.Error;
return ParseResult.Success;
Modified: mcs/mcs/statement.cs
===================================================================
@@ -28,7 +28,7 @@ public abstract class Statement {
/// <summary>
/// Resolves the statement, true means that all sub-statements
/// did resolve ok.
- // </summary>
+ /// </summary>
public virtual bool Resolve (BlockContext bc)
{
return true;
@@ -751,7 +751,7 @@ public class StatementList : Statement
public StatementList (Statement first, Statement second)
{
- statements = new List<Statement> () { first, second };
+ statements = new List<Statement> { first, second };
}
#region Properties
@@ -3713,7 +3713,7 @@ bool ResolveAndReduce (ResolveContext rc)
return true;
}
- converted = c.ImplicitConversionRequired (rc, rc.Switch.SwitchType, loc);
+ converted = c.ImplicitConversionRequired (rc, rc.Switch.SwitchType);
return converted != null;
}
@@ -5128,7 +5128,7 @@ class StringEmitter : Emitter
{
LocalVariable pinned_string;
- public StringEmitter (Expression expr, LocalVariable li, Location loc)
+ public StringEmitter (Expression expr, LocalVariable li)
: base (expr, li)
{
}
@@ -5251,7 +5251,7 @@ protected override Expression ResolveInitializer (BlockContext bc, LocalVariable
// Case 2: string
//
if (initializer.Type.BuiltinType == BuiltinTypeSpec.Type.String) {
- return new StringEmitter (initializer, li, loc).Resolve (bc);
+ return new StringEmitter (initializer, li).Resolve (bc);
}
// Case 3: fixed buffer
Modified: mcs/mcs/typespec.cs
===================================================================
@@ -378,7 +378,7 @@ public virtual bool AddInterface (TypeSpec iface)
throw new InternalErrorException ("Modifying expanded interface list");
if (ifaces == null) {
- ifaces = new List<TypeSpec> () { iface };
+ ifaces = new List<TypeSpec> { iface };
return true;
}
Commit: 009d937c1df7d8949b7671c89426e33a11c6d284
Author: Marek Safar <[email protected]> (marek-safar)
Date: 2013-10-04 20:42:57 GMT
URL: https://github.com/mono/mono/commit/009d937c1df7d8949b7671c89426e33a11c6d284
Better check for instance equality of generic types. Fixes #15100
Changed paths:
M mcs/mcs/expression.cs
M mcs/tests/ver-il-net_4_5.xml
Added paths:
A mcs/tests/gtest-597.cs
Modified: mcs/mcs/expression.cs
===================================================================
@@ -1505,6 +1505,12 @@ protected override Expression DoResolve (ResolveContext ec)
//
if (Convert.ExplicitReferenceConversionExists (d, t))
return this;
+
+ //
+ // open generic type
+ //
+ if (d is InflatedTypeSpec && InflatedTypeSpec.ContainsTypeParameter (d))
+ return this;
} else {
var tps = t as TypeParameterSpec;
if (tps != null)
@@ -1544,9 +1550,14 @@ protected override Expression DoResolve (ResolveContext ec)
this).Resolve (ec);
}
- if (Convert.ExplicitReferenceConversionExists (d, t)) {
+ if (Convert.ExplicitReferenceConversionExists (d, t))
+ return this;
+
+ //
+ // open generic type
+ //
+ if (d is InflatedTypeSpec && InflatedTypeSpec.ContainsTypeParameter (d))
return this;
- }
}
}
Added: mcs/tests/gtest-597.cs
===================================================================
@@ -0,0 +1,44 @@
+using System;
+
+namespace Test
+{
+ class MainClass
+ {
+ public static int Main ()
+ {
+ if (!Test_1 (new Derived ()))
+ return 1;
+
+ if (!Test_2 (new S ()))
+ return 2;
+
+ return 0;
+ }
+
+ static bool Test_1<T> (Templated<T> template)
+ {
+ return template is Derived;
+ }
+
+ static bool Test_2<U> (IA<U> arg)
+ {
+ return arg is S;
+ }
+ }
+
+ public abstract class Templated<T>
+ {
+ }
+
+ public class Derived : Templated<Derived>
+ {
+ }
+
+ public interface IA<T>
+ {
+ }
+
+ public struct S : IA<S>
+ {
+ }
+}
Modified: mcs/tests/ver-il-net_4_5.xml
===================================================================
@@ -18547,6 +18547,32 @@
</method>
</type>
</test>
+ <test name="gtest-597.cs">
+ <type name="Test.MainClass">
+ <method name="Int32 Main()" attrs="150">
+ <size>63</size>
+ </method>
+ <method name="Boolean Test_1[T](Test.Templated`1[T])" attrs="145">
+ <size>18</size>
+ </method>
+ <method name="Boolean Test_2[U](Test.IA`1[U])" attrs="145">
+ <size>18</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="Test.Templated`1[T]">
+ <method name="Void .ctor()" attrs="6276">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="Test.Derived">
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="gtest-anontype-01.cs">
<type name="Test">
<method name="Int32 Main()" attrs="150">
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches