Browse Source

Updated mcs.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
6a45cef6d6
  1. 26
      ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs
  2. 16
      ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs
  3. 773
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs
  4. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay
  5. 9
      ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs
  6. 327
      ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs
  7. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs
  8. 28
      ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs
  9. 18
      ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs
  10. 14
      ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs
  11. 6
      ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs
  12. 9
      ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs
  13. 5
      ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs
  14. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs
  15. 10
      ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs
  16. 21
      ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs

26
ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs

@ -960,11 +960,16 @@ namespace Mono.CSharp { @@ -960,11 +960,16 @@ namespace Mono.CSharp {
return Block.Parameters;
}
}
public bool IsAsync {
get;
internal set;
}
public ReportPrinter TypeInferenceReportPrinter {
get; set;
}
#endregion
//
@ -975,7 +980,13 @@ namespace Mono.CSharp { @@ -975,7 +980,13 @@ namespace Mono.CSharp {
{
using (ec.With (ResolveContext.Options.InferReturnType, false)) {
using (ec.Set (ResolveContext.Options.ProbingMode)) {
return Compatible (ec, delegate_type) != null;
var prev = ec.Report.SetPrinter (TypeInferenceReportPrinter ?? new NullReportPrinter ());
var res = Compatible (ec, delegate_type) != null;
ec.Report.SetPrinter (prev);
return res;
}
}
}
@ -1109,12 +1120,23 @@ namespace Mono.CSharp { @@ -1109,12 +1120,23 @@ namespace Mono.CSharp {
}
using (ec.Set (ResolveContext.Options.ProbingMode | ResolveContext.Options.InferReturnType)) {
ReportPrinter prev;
if (TypeInferenceReportPrinter != null) {
prev = ec.Report.SetPrinter (TypeInferenceReportPrinter);
} else {
prev = null;
}
var body = CompatibleMethodBody (ec, tic, null, delegate_type);
if (body != null) {
am = body.Compatible (ec, body);
} else {
am = null;
}
if (TypeInferenceReportPrinter != null) {
ec.Report.SetPrinter (prev);
}
}
if (am == null)

16
ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs

@ -70,6 +70,12 @@ namespace Mono.CSharp @@ -70,6 +70,12 @@ namespace Mono.CSharp
}
}
public Dictionary<string, MemberCore> DefinedNames {
get {
return defined_names;
}
}
public TypeDefinition PartialContainer {
get {
return main_container;
@ -2403,16 +2409,6 @@ namespace Mono.CSharp @@ -2403,16 +2409,6 @@ namespace Mono.CSharp
base.AddNameToContainer (symbol, name);
}
public override void VerifyMembers ()
{
base.VerifyMembers ();
if (containers != null) {
foreach (var t in containers)
t.VerifyMembers ();
}
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.IsValidSecurityAttribute ()) {

773
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs

File diff suppressed because it is too large Load Diff

2
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay

@ -3327,6 +3327,7 @@ argument_list @@ -3327,6 +3327,7 @@ argument_list
}
| argument_list COMMA error
{
lexer.putback (')'); // TODO: Wrong but what can I do
Error_SyntaxError (yyToken);
$$ = $1;
}
@ -5414,6 +5415,7 @@ for_statement_condition @@ -5414,6 +5415,7 @@ for_statement_condition
{
$$ = $4;
}
| boolean_expression CLOSE_PARENS {
report.Error (1525, GetLocation ($2), "Unexpected symbol ')', expected ';'");
For f = (For) $0;

9
ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs

@ -945,6 +945,15 @@ namespace Mono.CSharp { @@ -945,6 +945,15 @@ namespace Mono.CSharp {
GenericTask = 1 << 22
}
//
// Some flags can be copied directly from other member
//
protected const StateFlags SharedStateFlags =
StateFlags.CLSCompliant | StateFlags.CLSCompliant_Undetected |
StateFlags.Obsolete | StateFlags.Obsolete_Undetected |
StateFlags.MissingDependency | StateFlags.MissingDependency_Undetected |
StateFlags.HasDynamicElement;
protected Modifiers modifiers;
public StateFlags state;
protected IMemberDefinition definition;

327
ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs

@ -2777,8 +2777,14 @@ namespace Mono.CSharp { @@ -2777,8 +2777,14 @@ namespace Mono.CSharp {
}
}
// TODO: For now we do it for any hoisted call even if it's needed for
// hoisted stories only but that requires a new expression wrapper
//
// When base access is used inside anonymous method/iterator/etc we need to
// get back to the context of original type. We do it by emiting proxy
// method in original class and rewriting base call to this compiler
// generated method call which does the actual base invocation. This may
// introduce redundant storey but with `this' only but it's tricky to avoid
// at this stage as we don't know what expressions follow base
//
if (rc.CurrentAnonymousMethod != null) {
if (targs == null && method.IsGeneric) {
targs = method.TypeArguments;
@ -2792,8 +2798,9 @@ namespace Mono.CSharp { @@ -2792,8 +2798,9 @@ namespace Mono.CSharp {
// Ideally this should apply to any proxy rewrite but in the case of unary mutators on
// get/set member expressions second call would fail to proxy because left expression
// would be of 'this' and not 'base'
if (rc.CurrentType.IsStruct)
// would be of 'this' and not 'base' because we share InstanceExpression for get/set
// FIXME: The async check is another hack but will probably fail with mutators
if (rc.CurrentType.IsStruct || rc.CurrentAnonymousMethod.Storey is AsyncTaskStorey)
InstanceExpression = new This (loc).Resolve (rc);
}
@ -2993,12 +3000,15 @@ namespace Mono.CSharp { @@ -2993,12 +3000,15 @@ namespace Mono.CSharp {
if (me != null) {
me.ResolveInstanceExpression (rc, rhs);
var fe = me as FieldExpr;
if (fe != null && fe.IsMarshalByRefAccess (rc)) {
rc.Report.SymbolRelatedToPreviousError (me.DeclaringType);
rc.Report.Warning (1690, 1, loc,
"Cannot call methods, properties, or indexers on `{0}' because it is a value type member of a marshal-by-reference class",
me.GetSignatureForError ());
// Using this check to detect probing instance expression resolve
if (!rc.OmitStructFlowAnalysis) {
var fe = me as FieldExpr;
if (fe != null && fe.IsMarshalByRefAccess (rc)) {
rc.Report.SymbolRelatedToPreviousError (me.DeclaringType);
rc.Report.Warning (1690, 1, loc,
"Cannot call methods, properties, or indexers on `{0}' because it is a value type member of a marshal-by-reference class",
me.GetSignatureForError ());
}
}
return true;
@ -3587,7 +3597,6 @@ namespace Mono.CSharp { @@ -3587,7 +3597,6 @@ namespace Mono.CSharp {
TypeSpec best_candidate_return_type;
SessionReportPrinter lambda_conv_msgs;
ReportPrinter prev_recorder;
public OverloadResolver (IList<MemberSpec> members, Restrictions restrictions, Location loc)
: this (members, null, restrictions, loc)
@ -4045,6 +4054,7 @@ namespace Mono.CSharp { @@ -4045,6 +4054,7 @@ namespace Mono.CSharp {
//
// A return value rates candidate method compatibility,
// 0 = the best, int.MaxValue = the worst
// -1 = fatal error
//
int IsApplicable (ResolveContext ec, ref Arguments arguments, int arg_count, ref MemberSpec candidate, IParametersMember pm, ref bool params_expanded_form, ref bool dynamicArgument, ref TypeSpec returnType)
{
@ -4166,6 +4176,18 @@ namespace Mono.CSharp { @@ -4166,6 +4176,18 @@ namespace Mono.CSharp {
arg_count = arguments.Count;
}
//
// Don't do any expensive checks when the candidate cannot succeed
//
if (arg_count != param_count && !cpd.HasParams)
return (param_count - arg_count) * 2 + 1;
var dep = candidate.GetMissingDependencies ();
if (dep != null) {
ImportedTypeDefinition.Error_MissingDependency (ec, dep, loc);
return -1;
}
//
// 1. Handle generic method using type arguments when specified or type inference
//
@ -4182,20 +4204,41 @@ namespace Mono.CSharp { @@ -4182,20 +4204,41 @@ namespace Mono.CSharp {
ms = ms.MakeGenericMethod (ec, type_arguments.Arguments);
} else {
// TODO: It should not be here (we don't know yet whether any argument is lambda) but
// for now it simplifies things. I should probably add a callback to ResolveContext
//
// Deploy custom error reporting for infered anonymous expression or lambda methods. When
// probing lambda methods keep all errors reported in separate set and once we are done and no best
// candidate was found use the set to report more details about what was wrong with lambda body.
// The general idea is to distinguish between code errors and errors caused by
// trial-and-error type inference
//
if (lambda_conv_msgs == null) {
lambda_conv_msgs = new SessionReportPrinter ();
prev_recorder = ec.Report.SetPrinter (lambda_conv_msgs);
for (int i = 0; i < arg_count; i++) {
Argument a = arguments[i];
if (a == null)
continue;
var am = a.Expr as AnonymousMethodExpression;
if (am != null) {
if (lambda_conv_msgs == null)
lambda_conv_msgs = new SessionReportPrinter ();
am.TypeInferenceReportPrinter = lambda_conv_msgs;
}
}
}
var ti = new TypeInference (arguments);
TypeSpec[] i_args = ti.InferMethodArguments (ec, ms);
lambda_conv_msgs.EndSession ();
if (i_args == null)
return ti.InferenceScore - 20000;
//
// Clear any error messages when the result was success
//
if (lambda_conv_msgs != null)
lambda_conv_msgs.ClearSession ();
if (i_args.Length != 0) {
ms = ms.MakeGenericMethod (ec, i_args);
}
@ -4403,28 +4446,11 @@ namespace Mono.CSharp { @@ -4403,28 +4446,11 @@ namespace Mono.CSharp {
if (argument.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && (restrictions & Restrictions.CovariantDelegate) == 0)
return -1;
//
// Deploy custom error reporting for lambda methods. When probing lambda methods
// keep all errors reported in separate set and once we are done and no best
// candidate was found, this set is used to report more details about what was wrong
// with lambda body
//
if (argument.Expr.Type == InternalType.AnonymousMethod) {
if (lambda_conv_msgs == null) {
lambda_conv_msgs = new SessionReportPrinter ();
prev_recorder = ec.Report.SetPrinter (lambda_conv_msgs);
}
}
//
// Use implicit conversion in all modes to return same candidates when the expression
// is used as argument or delegate conversion
//
if (!Convert.ImplicitConversionExists (ec, argument.Expr, parameter)) {
if (lambda_conv_msgs != null) {
lambda_conv_msgs.EndSession ();
}
return 2;
}
}
@ -4494,147 +4520,148 @@ namespace Mono.CSharp { @@ -4494,147 +4520,148 @@ namespace Mono.CSharp {
bool error_mode = false;
MemberSpec invocable_member = null;
// Be careful, cannot return until error reporter is restored
while (true) {
best_candidate = null;
best_candidate_rate = int.MaxValue;
var type_members = members;
try {
do {
for (int i = 0; i < type_members.Count; ++i) {
var member = type_members[i];
//
// Methods in a base class are not candidates if any method in a derived
// class is applicable
//
if ((member.Modifiers & Modifiers.OVERRIDE) != 0)
continue;
if (!error_mode) {
if (!member.IsAccessible (rc))
continue;
do {
for (int i = 0; i < type_members.Count; ++i) {
var member = type_members[i];
if (rc.IsRuntimeBinder && !member.DeclaringType.IsAccessible (rc))
continue;
if ((member.Modifiers & (Modifiers.PROTECTED | Modifiers.STATIC)) == Modifiers.PROTECTED &&
instance_qualifier != null && !instance_qualifier.CheckProtectedMemberAccess (rc, member)) {
continue;
}
}
IParametersMember pm = member as IParametersMember;
if (pm == null) {
//
// Methods in a base class are not candidates if any method in a derived
// class is applicable
// Will use it later to report ambiguity between best method and invocable member
//
if ((member.Modifiers & Modifiers.OVERRIDE) != 0)
continue;
if (Invocation.IsMemberInvocable (member))
invocable_member = member;
if (!error_mode) {
if (!member.IsAccessible (rc))
continue;
continue;
}
if (rc.IsRuntimeBinder && !member.DeclaringType.IsAccessible (rc))
continue;
//
// Overload resolution is looking for base member but using parameter names
// and default values from the closest member. That means to do expensive lookup
// for the closest override for virtual or abstract members
//
if ((member.Modifiers & (Modifiers.VIRTUAL | Modifiers.ABSTRACT)) != 0) {
var override_params = base_provider.GetOverrideMemberParameters (member);
if (override_params != null)
pm = override_params;
}
if ((member.Modifiers & (Modifiers.PROTECTED | Modifiers.STATIC)) == Modifiers.PROTECTED &&
instance_qualifier != null && !instance_qualifier.CheckProtectedMemberAccess (rc, member)) {
//
// Check if the member candidate is applicable
//
bool params_expanded_form = false;
bool dynamic_argument = false;
TypeSpec rt = pm.MemberType;
int candidate_rate = IsApplicable (rc, ref candidate_args, args_count, ref member, pm, ref params_expanded_form, ref dynamic_argument, ref rt);
if (lambda_conv_msgs != null)
lambda_conv_msgs.EndSession ();
//
// How does it score compare to others
//
if (candidate_rate < best_candidate_rate) {
// Fatal error (missing dependency), cannot continue
if (candidate_rate < 0)
return null;
best_candidate_rate = candidate_rate;
best_candidate = member;
best_candidate_args = candidate_args;
best_candidate_params = params_expanded_form;
best_candidate_dynamic = dynamic_argument;
best_parameter_member = pm;
best_candidate_return_type = rt;
} else if (candidate_rate == 0) {
//
// The member look is done per type for most operations but sometimes
// it's not possible like for binary operators overload because they
// are unioned between 2 sides
//
if ((restrictions & Restrictions.BaseMembersIncluded) != 0) {
if (TypeSpec.IsBaseClass (best_candidate.DeclaringType, member.DeclaringType, true))
continue;
}
}
IParametersMember pm = member as IParametersMember;
if (pm == null) {
bool is_better;
if (best_candidate.DeclaringType.IsInterface && member.DeclaringType.ImplementsInterface (best_candidate.DeclaringType, false)) {
//
// Will use it later to report ambiguity between best method and invocable member
// We pack all interface members into top level type which makes the overload resolution
// more complicated for interfaces. We compensate it by removing methods with same
// signature when building the cache hence this path should not really be hit often
//
if (Invocation.IsMemberInvocable (member))
invocable_member = member;
// Example:
// interface IA { void Foo (int arg); }
// interface IB : IA { void Foo (params int[] args); }
//
// IB::Foo is the best overload when calling IB.Foo (1)
//
is_better = true;
if (ambiguous_candidates != null) {
foreach (var amb_cand in ambiguous_candidates) {
if (member.DeclaringType.ImplementsInterface (best_candidate.DeclaringType, false)) {
continue;
}
continue;
}
is_better = false;
break;
}
//
// Overload resolution is looking for base member but using parameter names
// and default values from the closest member. That means to do expensive lookup
// for the closest override for virtual or abstract members
//
if ((member.Modifiers & (Modifiers.VIRTUAL | Modifiers.ABSTRACT)) != 0) {
var override_params = base_provider.GetOverrideMemberParameters (member);
if (override_params != null)
pm = override_params;
if (is_better)
ambiguous_candidates = null;
}
} else {
// Is the new candidate better
is_better = BetterFunction (rc, candidate_args, member, pm.Parameters, params_expanded_form, best_candidate, best_parameter_member.Parameters, best_candidate_params);
}
//
// Check if the member candidate is applicable
//
bool params_expanded_form = false;
bool dynamic_argument = false;
TypeSpec rt = pm.MemberType;
int candidate_rate = IsApplicable (rc, ref candidate_args, args_count, ref member, pm, ref params_expanded_form, ref dynamic_argument, ref rt);
//
// How does it score compare to others
//
if (candidate_rate < best_candidate_rate) {
best_candidate_rate = candidate_rate;
if (is_better) {
best_candidate = member;
best_candidate_args = candidate_args;
best_candidate_params = params_expanded_form;
best_candidate_dynamic = dynamic_argument;
best_parameter_member = pm;
best_candidate_return_type = rt;
} else if (candidate_rate == 0) {
//
// The member look is done per type for most operations but sometimes
// it's not possible like for binary operators overload because they
// are unioned between 2 sides
//
if ((restrictions & Restrictions.BaseMembersIncluded) != 0) {
if (TypeSpec.IsBaseClass (best_candidate.DeclaringType, member.DeclaringType, true))
continue;
}
bool is_better;
if (best_candidate.DeclaringType.IsInterface && member.DeclaringType.ImplementsInterface (best_candidate.DeclaringType, false)) {
//
// We pack all interface members into top level type which makes the overload resolution
// more complicated for interfaces. We compensate it by removing methods with same
// signature when building the cache hence this path should not really be hit often
//
// Example:
// interface IA { void Foo (int arg); }
// interface IB : IA { void Foo (params int[] args); }
//
// IB::Foo is the best overload when calling IB.Foo (1)
//
is_better = true;
if (ambiguous_candidates != null) {
foreach (var amb_cand in ambiguous_candidates) {
if (member.DeclaringType.ImplementsInterface (best_candidate.DeclaringType, false)) {
continue;
}
is_better = false;
break;
}
if (is_better)
ambiguous_candidates = null;
}
} else {
// Is the new candidate better
is_better = BetterFunction (rc, candidate_args, member, pm.Parameters, params_expanded_form, best_candidate, best_parameter_member.Parameters, best_candidate_params);
}
} else {
// It's not better but any other found later could be but we are not sure yet
if (ambiguous_candidates == null)
ambiguous_candidates = new List<AmbiguousCandidate> ();
if (is_better) {
best_candidate = member;
best_candidate_args = candidate_args;
best_candidate_params = params_expanded_form;
best_candidate_dynamic = dynamic_argument;
best_parameter_member = pm;
best_candidate_return_type = rt;
} else {
// It's not better but any other found later could be but we are not sure yet
if (ambiguous_candidates == null)
ambiguous_candidates = new List<AmbiguousCandidate> ();
ambiguous_candidates.Add (new AmbiguousCandidate (member, pm.Parameters, params_expanded_form));
}
ambiguous_candidates.Add (new AmbiguousCandidate (member, pm.Parameters, params_expanded_form));
}
// Restore expanded arguments
if (candidate_args != args)
candidate_args = args;
}
} while (best_candidate_rate != 0 && (type_members = base_provider.GetBaseMembers (type_members[0].DeclaringType.BaseType)) != null);
} finally {
if (prev_recorder != null)
rc.Report.SetPrinter (prev_recorder);
}
// Restore expanded arguments
if (candidate_args != args)
candidate_args = args;
}
} while (best_candidate_rate != 0 && (type_members = base_provider.GetBaseMembers (type_members[0].DeclaringType.BaseType)) != null);
//
// We've found exact match
@ -4744,11 +4771,6 @@ namespace Mono.CSharp { @@ -4744,11 +4771,6 @@ namespace Mono.CSharp {
if (oa != null && !rc.IsObsolete)
AttributeTester.Report_ObsoleteMessage (oa, best_candidate.GetSignatureForError (), loc, rc.Report);
var dep = best_candidate.GetMissingDependencies ();
if (dep != null) {
ImportedTypeDefinition.Error_MissingDependency (rc, dep, loc);
}
best_candidate.MemberDefinition.SetIsUsed ();
args = best_candidate_args;
@ -4825,9 +4847,8 @@ namespace Mono.CSharp { @@ -4825,9 +4847,8 @@ namespace Mono.CSharp {
return;
}
if (lambda_conv_msgs != null) {
if (lambda_conv_msgs.Merge (rc.Report.Printer))
return;
if (lambda_conv_msgs != null && lambda_conv_msgs.Merge (rc.Report.Printer)) {
return;
}
@ -5279,7 +5300,7 @@ namespace Mono.CSharp { @@ -5279,7 +5300,7 @@ namespace Mono.CSharp {
if (lvalue_instance && var != null && var.VariableInfo != null) {
var.VariableInfo.SetStructFieldAssigned (ec, Name);
}
if (fb != null) {
IFixedExpression fe = InstanceExpression as IFixedExpression;
if (!ec.HasSet (ResolveContext.Options.FixedInitializerScope) && (fe == null || !fe.IsFixed)) {

2
ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs

@ -6987,7 +6987,7 @@ namespace Mono.CSharp @@ -6987,7 +6987,7 @@ namespace Mono.CSharp
if (variable_info == null)
return;
if (rc.HasSet (ResolveContext.Options.OmitStructFlowAnalysis))
if (rc.OmitStructFlowAnalysis)
return;
if (!variable_info.IsAssigned (rc)) {

28
ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs

@ -1488,7 +1488,9 @@ namespace Mono.CSharp { @@ -1488,7 +1488,9 @@ namespace Mono.CSharp {
if (targs == null)
throw new ArgumentNullException ("targs");
// this.state = openType.state;
this.state &= ~SharedStateFlags;
this.state |= (openType.state & SharedStateFlags);
this.context = context;
this.open_type = openType;
this.targs = targs;
@ -2289,7 +2291,7 @@ namespace Mono.CSharp { @@ -2289,7 +2291,7 @@ namespace Mono.CSharp {
//
// Checks all type arguments againts type parameters constraints
// NOTE: It can run in probing mode when `mc' is null
// NOTE: It can run in probing mode when `this.mc' is null
//
public bool CheckAll (MemberSpec context, TypeSpec[] targs, TypeParameterSpec[] tparams, Location loc)
{
@ -2342,15 +2344,6 @@ namespace Mono.CSharp { @@ -2342,15 +2344,6 @@ namespace Mono.CSharp {
// Check the class constraint
//
if (tparam.HasTypeConstraint) {
var dep = tparam.BaseType.GetMissingDependencies ();
if (dep != null) {
if (mc == null)
return false;
ImportedTypeDefinition.Error_MissingDependency (mc, dep, loc);
ok = false;
}
if (!CheckConversion (mc, context, atype, tparam, tparam.BaseType, loc)) {
if (mc == null)
return false;
@ -2364,19 +2357,6 @@ namespace Mono.CSharp { @@ -2364,19 +2357,6 @@ namespace Mono.CSharp {
//
if (tparam.Interfaces != null) {
foreach (TypeSpec iface in tparam.Interfaces) {
var dep = iface.GetMissingDependencies ();
if (dep != null) {
if (mc == null)
return false;
ImportedTypeDefinition.Error_MissingDependency (mc, dep, loc);
ok = false;
// return immediately to avoid duplicate errors because we are scanning
// expanded interface list
return false;
}
if (!CheckConversion (mc, context, atype, tparam, iface, loc)) {
if (mc == null)
return false;

18
ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs

@ -835,6 +835,13 @@ namespace Mono.CSharp @@ -835,6 +835,13 @@ namespace Mono.CSharp
import_cache.Add (type, spec);
if (kind == MemberKind.TypeParameter) {
if (canImportBaseType)
ImportTypeParameterTypeConstraints ((TypeParameterSpec) spec, type);
return spec;
}
//
// Two stage setup as the base type can be inflated declaring type or
// another nested type inside same declaring type which has not been
@ -992,7 +999,6 @@ namespace Mono.CSharp @@ -992,7 +999,6 @@ namespace Mono.CSharp
ImportTypeParameterTypeConstraints (tp, tp.GetMetaInfo ());
}
}
}
protected void ImportTypes (MetaType[] types, Namespace targetNamespace, bool hasExtensionTypes)
@ -1796,7 +1802,15 @@ namespace Mono.CSharp @@ -1796,7 +1802,15 @@ namespace Mono.CSharp
// or referenced from the user core in which case compilation error has to
// be reported because compiler cannot continue anyway
//
foreach (var t in types) {
for (int i = 0; i < types.Count; ++i) {
var t = types [i];
//
// Report missing types only once per type
//
if (i > 0 && types.IndexOf (t) < i)
continue;
string name = t.GetSignatureForError ();
if (t.MemberDefinition.DeclaringAssembly == ctx.Module.DeclaringAssembly) {

14
ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs

@ -496,6 +496,20 @@ namespace Mono.CSharp { @@ -496,6 +496,20 @@ namespace Mono.CSharp {
missing.AddRange (m);
}
if (Arity > 0) {
foreach (var tp in GenericDefinition.TypeParameters) {
var m = tp.GetMissingDependencies ();
if (m == null)
continue;
if (missing == null)
missing = new List<TypeSpec> ();
missing.AddRange (m);
}
}
return missing;
}

6
ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs

@ -801,8 +801,10 @@ namespace Mono.CSharp { @@ -801,8 +801,10 @@ namespace Mono.CSharp {
name = mn.Name;
}
var names_container = Parent == null ? Module : (TypeContainer) this;
MemberCore mc;
if (defined_names.TryGetValue (name, out mc)) {
if (names_container.DefinedNames.TryGetValue (name, out mc)) {
if (tc is NamespaceContainer && mc is NamespaceContainer) {
containers.Add (tc);
return;
@ -816,7 +818,7 @@ namespace Mono.CSharp { @@ -816,7 +818,7 @@ namespace Mono.CSharp {
GetSignatureForError (), mn.GetSignatureForError ());
}
} else {
defined_names.Add (name, tc);
names_container.DefinedNames.Add (name, tc);
}
base.AddTypeContainer (tc);

9
ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs

@ -1440,7 +1440,14 @@ namespace Mono.CSharp @@ -1440,7 +1440,14 @@ namespace Mono.CSharp
public override MethodBuilder Define (TypeContainer parent)
{
parameters.Resolve (this);
// Disable reporting, parameters are resolved twice
Report.DisableReporting ();
try {
parameters.Resolve (this);
} finally {
Report.EnableReporting ();
}
return base.Define (parent);
}

5
ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs

@ -644,6 +644,11 @@ namespace Mono.CSharp { @@ -644,6 +644,11 @@ namespace Mono.CSharp {
bool showFullPaths;
public void ClearSession ()
{
session_messages = null;
}
public override void Print (AbstractMessage msg, bool showFullPath)
{
//

2
ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs

@ -1565,7 +1565,7 @@ namespace Mono.CSharp { @@ -1565,7 +1565,7 @@ namespace Mono.CSharp {
" -reference:A1[,An] Imports metadata from the specified assembly (short: -r)\n" +
" -reference:ALIAS=A Imports metadata using specified extern alias (short: -r)\n" +
" -sdk:VERSION Specifies SDK version of referenced assemblies\n" +
" VERSION can be one of: 2, 4 (default) or custom value\n" +
" VERSION can be one of: 2, 4, 4.5 (default) or a custom value\n" +
" -target:KIND Specifies the format of the output assembly (short: -t)\n" +
" KIND can be one of: exe, winexe, library, module\n" +
" -unsafe[+|-] Allows to compile code which uses unsafe keyword\n" +

10
ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs

@ -784,12 +784,10 @@ namespace Mono.CSharp { @@ -784,12 +784,10 @@ namespace Mono.CSharp {
public sealed override bool Resolve (BlockContext ec)
{
if (!DoResolve (ec))
return false;
var res = DoResolve (ec);
unwind_protect = ec.CurrentBranching.AddReturnOrigin (ec.CurrentBranching.CurrentUsageVector, this);
ec.CurrentBranching.CurrentUsageVector.Goto ();
return true;
return res;
}
}
@ -1438,6 +1436,7 @@ namespace Mono.CSharp { @@ -1438,6 +1436,7 @@ namespace Mono.CSharp {
protected FullNamedExpression type_expr;
protected LocalVariable li;
protected List<Declarator> declarators;
TypeSpec type;
public BlockVariableDeclaration (FullNamedExpression type, LocalVariable li)
{
@ -1514,8 +1513,7 @@ namespace Mono.CSharp { @@ -1514,8 +1513,7 @@ namespace Mono.CSharp {
public bool Resolve (BlockContext bc, bool resolveDeclaratorInitializers)
{
if (li.Type == null) {
TypeSpec type = null;
if (type == null && !li.IsCompilerGenerated) {
var vexpr = type_expr as VarExpr;
//

21
ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs

@ -721,6 +721,18 @@ namespace Mono.CSharp @@ -721,6 +721,18 @@ namespace Mono.CSharp
}
}
if (MemberDefinition.TypeParametersCount > 0) {
foreach (var tp in MemberDefinition.TypeParameters) {
var tp_missing = tp.GetMissingDependencies ();
if (tp_missing != null) {
if (missing == null)
missing = new List<TypeSpec> ();
missing.AddRange (tp_missing);
}
}
}
if (missing != null || BaseType == null)
return missing;
@ -1333,7 +1345,7 @@ namespace Mono.CSharp @@ -1333,7 +1345,7 @@ namespace Mono.CSharp
cache = MemberCache.Empty;
// Make all internal types CLS-compliant, non-obsolete
state = (state & ~(StateFlags.CLSCompliant_Undetected | StateFlags.Obsolete_Undetected)) | StateFlags.CLSCompliant;
state = (state & ~(StateFlags.CLSCompliant_Undetected | StateFlags.Obsolete_Undetected | StateFlags.MissingDependency_Undetected)) | StateFlags.CLSCompliant;
}
#region Properties
@ -1454,11 +1466,8 @@ namespace Mono.CSharp @@ -1454,11 +1466,8 @@ namespace Mono.CSharp
{
this.Element = element;
// Some flags can be copied directly from the element
const StateFlags shared_flags = StateFlags.CLSCompliant | StateFlags.CLSCompliant_Undetected
| StateFlags.Obsolete | StateFlags.Obsolete_Undetected | StateFlags.HasDynamicElement;
state &= ~shared_flags;
state |= (element.state & shared_flags);
state &= ~SharedStateFlags;
state |= (element.state & SharedStateFlags);
if (element.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
state |= StateFlags.HasDynamicElement;

Loading…
Cancel
Save