+2008-07-17 Marek Safar <marek.safar@gmail.com>
+
+ A fix for bug #365188
+ * ecore.cs, anonymous.cs, expression.cs, codegen.cs, statement.cs: Don't
+ create anonymous method storey in unreachable block.
+
2008-07-17 Marek Safar <marek.safar@gmail.com>
* generic.cs, typemanager.cs, cs-tokenizer.cs, parameter.cs, namespace.cs,
if (aec == null && !Compatible (ec))
return false;
- // Don't define anything when we are in probing scope (nested anonymous methods)
- if (!ec.IsInProbingMode)
+ //
+ // Don't create anonymous expression method when we are in probing
+ // mode or unreachable block
+ //
+ if (ec.IsVariableCapturingRequired)
method = DoCreateMethodHost (ec);
return true;
public bool IsInCompoundAssignment {
get { return (flags & Flags.InCompoundAssignment) != 0; }
- }
+ }
+
+ public bool IsVariableCapturingRequired {
+ get {
+ return !IsInProbingMode && (CurrentBranching == null || !CurrentBranching.CurrentUsageVector.IsUnreachable);
+ }
+ }
public FlowBranching CurrentBranching {
get { return current_flow_branching; }
if (!li.Resolve (ec))
return null;
- if (ec.MustCaptureVariable (li) && !ec.IsInProbingMode) {
+ if (ec.MustCaptureVariable (li) && ec.IsVariableCapturingRequired) {
AnonymousMethodStorey storey = li.Block.Explicit.CreateAnonymousMethodStorey (ec);
storey.CaptureLocalVariable (ec, li);
}
return null;
}
- if (!ec.IsInProbingMode) {
+ if (ec.IsVariableCapturingRequired) {
AnonymousMethodStorey storey = local_info.Block.Explicit.CreateAnonymousMethodStorey (ec);
storey.CaptureLocalVariable (ec, local_info);
}
return true;
}
- // Don't capture parameters when the probing is on
- if (!ec.IsInProbingMode) {
+ if (ec.IsVariableCapturingRequired) {
AnonymousMethodStorey storey = declared.CreateAnonymousMethodStorey (ec);
storey.CaptureParameter (ec, this);
}
//
// this is hoisted to very top level block
//
- if (!ec.IsInProbingMode) {
+ if (ec.IsVariableCapturingRequired) {
// TODO: it could be optimized
AnonymousMethodStorey scope = TopToplevelBlock.Explicit.CreateAnonymousMethodStorey (ec);
if (HoistedVariable == null) {
public override bool Resolve (EmitContext ec)
{
- ec.CurrentBranching.CurrentUsageVector.Goto ();
-
- if (expr == null)
+ if (expr == null) {
+ ec.CurrentBranching.CurrentUsageVector.Goto ();
return ec.CurrentBranching.CheckRethrow (loc);
+ }
expr = expr.Resolve (ec);
+ ec.CurrentBranching.CurrentUsageVector.Goto ();
+
if (expr == null)
return false;